// JavaScript Document



// Check for empty input



function checkData(formObj){ //check if valid first name

	if (emptyField(formObj.firstName)){

		formObj.firstName.focus(); //not valid so set focus

		alert("Please enter a first name!");

		return false; //stops the form being submitted

	}

	//this point is reached when the first name field contains a valid entry

	else if(emptyField(formObj.lastName)){ //check if valid last name

		formObj.lastName.focus(); //not valid so set focus

		alert("Please enter a last name!");

		return false; //stops the form being submitted

	}	

	//this point is reached when the first and last name fields contains valid entries

	else if(checkEmail(formObj.email)){ //check if valid eMail

		formObj.email.focus(); //not valid so set focus

		alert("Please enter a valid eMail address!");

		return false; //stops the form being submitted

	}	

	else{

		return true; //submits the form

	}

}



function emptyField(fieldObj){ // used to check if a field contains valid data or not

	// returning true will mean there is no entry or only blank

	// or tab spaces, returning false will mean there is at

	// least one non blank or non tab character.

var result = true;

if(fieldObj.value.length == 0){ //check if no entry

	result = true;

}

// this point is reached only if there is some kind of entry,

// which could be just blank spaces

else{

	var i, ch;

	// test each character in the entry

	for (i=0; i< fieldObj.value.length; i++){

		ch = fieldObj.value.charAt(i);

		if(ch !=' ' && ch != '\t'){

			result = false;

			break;

		}

	}

}

return result;

}



function checkEmail(fieldObj){

	// returning true means email address is invalid

	var result = false;

	var emailVal = fieldObj.value; // store email field's value

	if(emailVal.length < 6){

		result = true;// form not submitted

	}

	else if ((emailVal.indexOf("@") == -1) || (emailVal.indexOf(".") == -1)){// checks if both @ and "." are in the Email string

		result = true;// form not submitted

	}

	return result;

}





startListVertical = function() {

if (document.all && document.getElementById) {

navRootVertical = document.getElementById("verticalNavLeft");

for (i=0; i<navRootVertical.childNodes.length; i++) {

  node = navRootVertical.childNodes[i];

  if (node.nodeName=="LI") {

  node.onmouseover=function() {

  this.className+=" over";

    }

  node.onmouseout=function() {

  this.className=this.className.replace

      (" over", "");

   }

   }

  }

 }

 if (document.all && document.getElementById) {

navRootHoriz = document.getElementById("horizontalNav");

for (i=0; i<navRootHoriz.childNodes.length; i++) {

  node = navRootHoriz.childNodes[i];

  if (node.nodeName=="LI") {

  node.onmouseover=function() {

  this.className+=" over";

    }

  node.onmouseout=function() {

  this.className=this.className.replace

      (" over", "");

   }

   }

  }

 }

}

window.onload=startListVertical;

