// JavaScript Document

function checkForm () { 
	//Initialise variables
	var errorMsg = "";
	var thanks = "";
	thanks = "Thank you for contacting with us.\nWe shall respond you as soon as we receive your enquiry.";
	//Check for a first name
	if (document.book.fname.value == ""){
		errorMsg += "\n\tFirst Name \t- Enter your First Name";	
	}
	
	//Check for a last name
	if (document.book.lname.value == ""){
		errorMsg += "\n\tLast Name \t- Enter your Last Name";
	}
	if ((document.book.email.value == "") || (document.book.email.value.length > 0 && (document.book.email.value.indexOf("@",0) == - 1 || document.book.email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
	}
	if( document.book.persons.value == "" ){
		errorMsg += "\n\tPersons \t- Enter the number of persons";
	}
	if( document.book.rooms.value == "" ){
		errorMsg += "\n\tRooms \t- Enter the number of rooms";
	}

	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your enquiry has not been sent because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	} 
	else {
	thanks += alert(thanks + "\n\n");
	return true;
		}
}	
