// JavaScript Document

/*function init(){
	var imagesNormal = new Array("images/homeButton.gif", "images/guestRoomsButton.gif", "images/facilitiesButton.gif", "images/contactUsButton.gif");
	var imagesOver = new Array("images/homeButtonOver.gif", "images/guestRoomsButtonOver.gif", "images/facilitiesButtonOver.gif", "images/contactUsButtonOver.gif");
	function changeOver(imageIndex){
		document.images[imageIndex].src = imagesOver[imageIndex];	
	}
	function changeBack(imageIndex){
		document.images[imageIndex].src = imagesNormal[imageIndex];
	}
}*/
var imagesNormal = new Array("images/homeButton.gif", "images/guestRoomsButton.gif", "images/facilitiesButton.gif", "images/contactUsButton.gif");
var imagesOver = new Array("images/homeButtonOver.gif", "images/guestRoomsButtonOver.gif", "images/facilitiesButtonOver.gif", "images/contactUsButtonOver.gif");
//var imagesDown = new Array("images/homeButtonDown.gif", "images/guestRoomsButtonDown.gif", "images/facilitiesButtonDown.gif", "images/contactUsButtonDown.gif");
	function changeOver(imageIndex){
		document.images[imageIndex+2].src = imagesOver[imageIndex];	
	}
	function changeBack(imageIndex){
		document.images[imageIndex+2].src = imagesNormal[imageIndex];
	}
	//function changeDown(imageIndex){
//		document.images[imageIndex+2}.src = imagesDown[imageIndex];
//	}
	
//can't get the following function to validate so I've commented it out and started again below
	/*function checkData(formObj){
	if(emptyField(formObj.firstName)){  //check to see if field is empty
		formObj.firstName.focus();	//not valid, so set focus to correct field
		alert("Please enter your first name");
		return false;  //stops the form being submitted
	}
//you only get here if the filed name is valid
	else if(emptyField(formObj.surname)){  //check if last name field is empty
		formObj.surname.focus();  //set focus to last name
		alert("Please enter your last name");
		return false;	
	}
//you only get here if both names have been entered

		return true;	//allows form to be submitted	

}

function emptyField(fieldObj){ //used to check if a field contains valid data
		// returning true means there's no entry, or blank or tab spaces
		// returning false means 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 only reached if there is some kind of entry (even if tab)

	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"){
				//a non-blank, non-tab character has been found, no need to test further
				result = false;
				break;
			}
		}
	}
	return result;


}*/


// Second attempt at validation below - this one works!

//function checkData(){
//	var firstName = document.enquiryForm.firstName;
//	var lastName = document.enquiryForm.lastName;
//	
//	if(firstName.value == " " || firstName.value == "\t" || !isNaN(firstName.value)){  //check to see if field is empty
//		alert("Please enter your first name");
//		firstName.focus();	//not valid, so set focus to correct field
//		return false;  //stops the form being submitted
//	}
////you only get here if the first name is valid
//	else if (lastName.value == " " || lastName.value == "\t" || !isNaN(lastName.value)){  //check if last name field is empty
//		alert("Please enter your last name");
//		lastName.focus();  //set focus to last name
//		return false;	
//	}
////you only get here if both names have been entered
//
//		return true;	//allows form to be submitted	
//
//}



function checkData(){
	var firstName = document.getElementById("firstName"); //this does the same as the text below!!
	var lastName = document.enquiryForm.lastName;
	
	if(firstName.value == " " || firstName.value == "\t" || !isNaN(firstName.value)){  //check to see if field is empty
		alert("Please enter your first name");
		firstName.focus();	//not valid, so set focus to correct field
		return false;  //stops the form being submitted
	}
//you only get here if the first name is valid
	else if (lastName.value == " " || lastName.value == "\t" || !isNaN(lastName.value)){  //check if last name field is empty
		alert("Please enter your last name");
		lastName.focus();  //set focus to last name
		return false;	
	}
//you only get here if both names have been entered

		return true;	//allows form to be submitted	

}




