﻿function submitBooking(){
	if(chkform()){
		document.frmbooking.method="POST";
		document.frmbooking.hdEvent.value="SUBMIT";
		document.frmbooking.action="booking.php";
		document.frmbooking.submit();
	}
}

function chkform(){
	if(Trim(document.frmbooking.txt_dmy.value)==""){		
		document.frmbooking.txt_dmy.focus();
		document.frmbooking.txt_dmy.style.background = 'red';
		return false;
	}else{
		document.frmbooking.txt_dmy.style.background = 'white';
	}

	if(Trim(document.frmbooking.txtname.value)==""){
		document.frmbooking.txtname.focus();
		document.frmbooking.txtname.style.background = 'red';
		return false;
	}else{
		document.frmbooking.txtname.style.background = 'white';
	}
	
	if(Trim(document.frmbooking.txtemail.value)==""){
		document.frmbooking.txtemail.focus();
		document.frmbooking.txtemail.style.background = 'red';
		return false;
	}else{
		if(!isEmail(document.frmbooking.txtemail.value)){
			document.frmbooking.txtemail.style.background = 'red';
			return false;
		}else{
			document.frmbooking.txtemail.style.background = 'white';
		}
	}
	
	if(Trim(document.frmbooking.txtmobile.value)==""){
		document.frmbooking.txtmobile.focus();
		document.frmbooking.txtmobile.style.background = 'red';
		return false;
	}else{
		document.frmbooking.txtmobile.style.background = 'white';
	}
	
	if (Trim(document.frmbooking.txtpersons.value) == "") {
		document.frmbooking.txtpersons.focus();
		document.frmbooking.txtpersons.style.background = 'red';
		return false;
	} else {
		document.frmbooking.txtpersons.style.background = 'white';
	}
	
	return true;
}

function clearForm(){
	document.frmbooking.txt_dmy.value='';
	document.frmbooking.txt_dmy.style.background = 'white';
	document.frmbooking.txtrequest.value='';
	document.frmbooking.txtrequest.style.background = 'white';
	document.frmbooking.txtname.value='';
	document.frmbooking.txtname.style.background = 'white';
	document.frmbooking.txtemail.value='';
	document.frmbooking.txtemail.style.background = 'white';
	document.frmbooking.txtmobile.value='';
	document.frmbooking.txtmobile.style.background = 'white';
	document.frmbooking.txtpersons.value='';
	document.frmbooking.txtpersons.style.background = 'white';
}
