function validate(theForm){
	
	if(!theForm){
		theForm = document.form_booking;
	}
	//---------------------check year--------------------------
	today = new Date();
	todayDay = today.getDate()
	todayYear = today.getFullYear();
	todayMonth = today.getMonth() + 1;
	
	if(theForm.monthfrom.value >= todayMonth){
		theForm.yearfrom.value = todayYear;
	}else if(theForm.monthfrom.value < todayMonth){
		theForm.yearfrom.value = parseInt(todayYear) + 1;
	}
	if(theForm.monthend.value >= todayMonth){
		theForm.yearend.value = todayYear;
	}else if(theForm.monthend.value < todayMonth){
		theForm.yearend.value = parseInt(todayYear) + 1;
	}
	
}

function booking_validate(theForm){
	if(!theForm){
		theForm = document.form_booking;
	}
	var message ='please enter or select again: \n';
		var tf = 'true';
		
		var atmark = "@";
		var dot = ".";
		var gemial = theForm.email.value;
		
		if (theForm.fullname.value == '') {
			message = message + ' --> first name and last name\n';					
			tf = 'false';
		}

		if ((gemial.indexOf(atmark)	==	-1) || (gemial.indexOf(dot)==-1)){ 
			message = message + " --> email address\n";
			tf = 'false';
		}

		if (theForm.country.selectedIndex == 0) {
			message = message + ' --> your country\n';					
			tf = 'false';
		}
		
		if (theForm.comments.value == '') {
			message = message + ' --> your comment or inquiry\n';					
			tf = 'false';
		}
		
		if(theForm.chk_advertise.checked == false && theForm.chk_searchengine.checked == false && theForm.chk_media.checked == false && theForm.chk_directmail.checked == false && theForm.chk_friend.checked == false && theForm.chk_exhibition.checked == false && theForm.chk_visited.checked == false && theForm.chk_ggpsales.checked == false && theForm.chk_staybefore.checked == false && theForm.chk_bisnews.checked == false && theForm.chk_knowother.checked == false){
			message = message + ' --> How did you know about Grace Gardens ?\n';					
			tf = 'false';
		}else{
			if(theForm.chk_advertise.checked == true){
				if(theForm.advertise.value == ""){
					message = message + ' --> Please Choose Online Advertising\n';					
					tf = 'false';
				}else if(theForm.advertise.value == "Other" && theForm.txt_advertise.value == ""){
					message = message + ' --> Please Specify Online Advertising\n';					
					tf = 'false';
				}				
			}
			
			if(theForm.chk_searchengine.checked == true){
				if(theForm.searchengine.value == ""){
					message = message + ' --> Please Choose Online Search Engine\n';					
					tf = 'false';
				}else if(theForm.searchengine.value == "Other" && theForm.txt_searchengine.value == ""){
					message = message + ' --> Please Specify Online Search Engine\n';					
					tf = 'false';
				}				
			}
			
			if(theForm.chk_media.checked == true){
				if(theForm.media.value == ""){
					message = message + ' --> Please Choose Published Media\n';					
					tf = 'false';
				}else if(theForm.media.value == "Other" && theForm.txt_media.value == ""){
					message = message + ' --> Please Specify Published Media\n';					
					tf = 'false';
				}				
			}
			
			if(theForm.chk_friend.checked == true && theForm.txt_friend.value == ""){
				message = message + ' --> Please Specify Your Friend Name\n';					
				tf = 'false';
			}
			
			if(theForm.chk_knowother.checked == true && theForm.txt_knowother.value == ""){
				message = message + ' --> Please Specify How did you know about Grace Gardens\n';					
				tf = 'false';
			}
			
		}
		
		if(theForm.chk_internet.checked == false && theForm.chk_faciltity.checked == false && theForm.chk_service.checked == false && theForm.chk_price.checked == false && theForm.chk_promotion.checked == false && theForm.chk_location.checked == false && theForm.chk_whyother.checked == false){
			message = message + ' --> Why do you choose Grace Gardens ?\n';					
			tf = 'false';
		}else if(theForm.chk_whyother.checked == true && theForm.txt_whyother.value == ""){
			message = message + ' --> Please Specify Why do you choose Grace Gardens\n';					
			tf = 'false';
		}
		
		if(theForm.chk_business.checked == false && theForm.chk_vacation.checked == false && theForm.chk_relative.checked == false && theForm.chk_honeymoon.checked == false && theForm.chk_purposeother.checked == false){
			message = message + ' --> What is your travelling purpose ?\n';					
			tf = 'false';
		}else if(theForm.chk_purposeother.checked == true && theForm.txt_purposeother.value == ""){
			message = message + ' --> Please Specify What is your travelling purpose\n';					
			tf = 'false';
		}
		
		if( tf != 'true') {
			alert(message);
			return false;
		}
		else {
			return true;
		}

}
