// JavaScript Document  
//DON'T MAKE ANY MODIFICTION IN THIS FILE.
//Trim Function
function Trim(strVal) {
    var strMatch = strVal.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    result = (strMatch == null) ? "" : strMatch[1];
    return result;
}

//Validation for EMAIL
function isEmail(objObject) {
	var regEmail, strValue;	
	regEmail =/^([A-Za-z0-9]{1})([A-Za-z0-9_.\-]*)([A-Za-z0-9]{1})(@)([A-Za-z0-9]{1})([A-Za-z0-9_.\-]*)([A-Za-z0-9]{1})(\.)([A-Za-z]{1})([A-Za-z]*)$/
	strValue = objObject.value;
	if (objObject.value == "") return true;
	if(! regEmail.test(strValue)) {
		objObject.focus();
		return false;
	}
	return true;
}

function doSUBMITRESERVATION(){
	var theForm = document.frmRESERVERATION;
	if(Trim(theForm.txtFULL_NAME.value).length == 0){
		alert("Please enter your full name.");
		theForm.txtFULL_NAME.focus();
		return false;
	}
	if(Trim(theForm.txtPHONE_NO.value).length == 0){
		alert("Please enter your phone number.");
		theForm.txtPHONE_NO.focus();
		return false;
	}
	if(Trim(theForm.txtEMAIL_ADDRESS.value).length == 0){
		alert("Please enter your email address.");
		theForm.txtEMAIL_ADDRESS.focus();
		return false;
	}
	if(isEmail(theForm.txtEMAIL_ADDRESS) == false) {
		alert("Please enter your valid email address.\nFor Example: xyz@xyz.com");
		theForm.txtEMAIL_ADDRESS.focus();
		return false;
	}
	if(Trim(theForm.txaADDRESS.value).length == 0){
		alert("Please enter your contact address.");
		theForm.txaADDRESS.focus();
		return false;
	}
	if(Trim(theForm.txaADDRESS.value).length > 500){
		alert("Please enter only 500 characters in\nyour contact address.");
		theForm.txaADDRESS.focus();
		return false;
	}
	if(Trim(theForm.txtCITY.value).length == 0){
		alert("Please enter your city name.");
		theForm.txtCITY.focus();
		return false;
	}
	if(Trim(theForm.txtZIP_CODE.value).length == 0){
		alert("Please enter your zip code.");
		theForm.txtZIP_CODE.focus();
		return false;
	}
	if(theForm.cmbCOUNTRY.selectedIndex <= 0){
		alert("Please select your country name.");
		theForm.cmbCOUNTRY.focus();
		return false;		
	}
	if((theForm.cmbSINGLE_ROOM.selectedIndex <= 0) && (theForm.cmbDOUBLE_ROOM.selectedIndex <= 0)){
		alert("Please select your no. of rooms\nyou want to reserve.");
		theForm.cmbSINGLE_ROOM.focus();
		return false;
	}
	if((theForm.cmbARRI_DATE_D.selectedIndex <= 0) || (theForm.cmbARRI_DATE_M.selectedIndex <= 0) || (theForm.cmbARRI_DATE_Y.selectedIndex <= 0)){
		alert("Please select your date of arrival.");
		theForm.cmbARRI_DATE_D.focus();
		return false;
	}
	if((theForm.cmbDEPT_DATE_D.selectedIndex <= 0) || (theForm.cmbDEPT_DATE_M.selectedIndex <= 0) || (theForm.cmbDEPT_DATE_Y.selectedIndex <= 0)){
		alert("Please select your date of departure.");
		theForm.cmbDEPT_DATE_D.focus();
		return false;
	}
	if(Trim(theForm.txaCOMMENT.value).length > 4000){
		alert("Please enter only 4000 characters in\nyour additional message.");
		theForm.txaCOMMENT.focus();
		return false;
	}
	theForm.hidACTION.value = "SubmitReservationForm";
	theForm.action = "formaction.php";
	return true;
}
