//date validation
	var ErrDate1="Please enter Arrival / Departure Dates."
	var ErrDate2="Please enter a valid Arrival Date."
	var ErrDate3="The Date entered is in the past. Please enter a valid Arrival Date."
	var ErrDate3a="I am afraid a mimimum of 24 hours is required to process your request."
	var ErrDate4="Please enter a valid Departure Date."
	var ErrDate5="Your period of stay appears to be incorrect as it is longer than a year."
	var ErrDate6="The Departure Date should be later than the Arrival Date."

function validDate(year, month, day) {
	var tempDate = new Date(year, month, day)
	return tempDate.getDate() == day
}

//submit the form
function checkDate(form) {
	//Dates entered?
	if (cInDay.selectedIndex == 0 || cInMonth.selectedIndex == 0 || cInYear.selectedIndex == 0 || cOutDay.selectedIndex == 0 || cOutMonth.selectedIndex == 0 || cOutYear.selectedIndex == 0) {
		alert(ErrDate1)
		cInDay.focus()
		return	false}

	//Arrival date valid?
	if (!validDate(cInYear[cInYear.selectedIndex].text, cInMonth.selectedIndex - 1, cInDay.selectedIndex)) {
		alert(ErrDate2)
		cInDay.focus()
		return	false}
	
	var todayDate = new Date()
	var checkinDate= new Date(cInYear[cInYear.selectedIndex].text, cInMonth.selectedIndex - 1, cInDay.selectedIndex, 0,1,0)

	//var mDiff=	Date.UTC(checkinDate) - Date.UTC(currentDate)
	todayDate.setHours(0)
	todayDate.setMinutes(0)
	// Date is in the past?
	if (checkinDate < todayDate) {
		alert(ErrDate3)
		cInDay.focus()
		return	false}
	// Today?
	checkinDate.setMinutes(0)
	if (checkinDate < todayDate) {
		alert(ErrDate3a)
		cInDay.focus()
		return	false}
	//Departure Date Valid?
	if (!validDate(cOutYear[cOutYear.selectedIndex].text, cOutMonth.selectedIndex - 1, cOutDay.selectedIndex)) {
		alert(ErrDate4)
		cOutDay.focus()
		return	false}

	// Departure - Arrival >1 year?
	var msDifference = Date.UTC(cOutYear[cOutYear.selectedIndex].text, cOutMonth.selectedIndex - 1, cOutDay.selectedIndex) - Date.UTC(cInYear[cInYear.selectedIndex].text, cInMonth.selectedIndex - 1, cInDay.selectedIndex)

	if (msDifference > 31536000000) {  //1 year in milliseconds
		alert(ErrDate5)
		cOutDay.focus()
		return	false}

	// Departure < Arrival?
	if (msDifference <= 0) {
		alert(ErrDate6)
		cOutDay.focus()
		return	false}

//	form.submit()
return true
}

//set checkout date to checkin date + 1 day
function setDate() {
	var checkoutDate = new Date(cInYear[cInYear.selectedIndex].text, cInMonth.selectedIndex - 1, cInDay.selectedIndex + 1)
	var newOutDay = checkoutDate.getDate()
	var newOutMonth = checkoutDate.getMonth()
	var newOutYear = checkoutDate.getYear().toString()

	if (cInDay.selectedIndex !=0 && cOutDay.selectedIndex ==0) cOutDay.selectedIndex = newOutDay
	if (cInMonth.selectedIndex != 0 && cOutMonth.selectedIndex ==0)  cOutMonth.selectedIndex = newOutMonth + 1

	for (var i=1; i<3; i++) {
		if (cOutYear[i].text.charAt(3) == newOutYear.charAt(newOutYear.length - 1)) cOutYear.selectedIndex = i
	}
}
<!-- ValidateEmail
<!-- Form Error
var FErr1 = "Email Address seems Incorrect, please check if '@' or '.' are missing. Eg. tom@aol.com";
var FErr2 = "Email: You may have made a typo error, the username doesn't seem to be valid. Eg. tom@aol.com";
var FErr3 = "Email: You may have made a typo error, destination IP address is invalid! Eg. tom@aol.com";
var FErr4 = "Email: You may have made a typo error, the domain name doesn't seem to be valid. Eg. tom@aol.com";
var FErr5 = "Email: You may have made a typo error, the email must end in a three-letter,\n or two letter country. Eg. tom@aol.com OR tom@yahoo.com.sg";
var FErr6 = "Email: You may have made a typo error, the email is missing a hostname. Eg. tom@aol.com";
var FErr7 = "Please enter numbers only. Eg. 12";
var FErr8 = "Please enter a valid Telephone number.\nWe will only call you if we were unable to reach you by Email or Fax.";
var FErr9 = "Age of Children: Please enter only numbers separated by commas. Eg. 3,10,11";
var FErr10 = " field is required. Please select or fill in completely.";
// Validate Email
function emailCheck (emailS) {
var emailStr=emailS.value;
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

//if (emailStr=='')
//	return true;
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
 	alert(FErr1)
	emailS.focus();
	emailS.select();
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
 
if (user.match(userPat)==null) {
    alert(FErr2)
	emailS.focus();
	emailS.select();
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
 	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert(FErr3)
			emailS.focus();
			emailS.select();
			return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert(FErr4)
	emailS.focus();
	emailS.select();
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   alert(FErr5)
   emailS.focus();
	emailS.select();
   return false
}

if (len<2) {
   alert(FErr6)
   emailS.focus();
	emailS.select();
   return false
}

return true;
}

// Validate
function validate(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert(FErr7);
field.focus();
field.select();
   }
}

function validatephone(field) 
{
	var valid = "0123456789()-+. "
	var ok = "yes";
	var temp;
	var i=0;
	for (; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no" || i < 5) 
	{
		alert(FErr8);
		field.focus();
		field.select();
		return false;
   }
   return true;
}

function validatechildages(field) {
var valid = "0123456789, "
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
	alert(FErr9);
	field.focus();
	field.select();
	return false;
   }
   return true;
}

// Check rq
function checkrq(which) {
var pass=true;
	if (!checkDate(this))
		return false;

	if (document.images) 
	{
		for (i=0;i<which.length;i++) 
		{
			var tempobj=which.elements[i];
			if (tempobj.name=="rqtelephone") 
			{
				if (validatephone(tempobj)==false)
				{
					return false;
				}
			}
			if (tempobj.name=="rqemail") 
			{
				if (emailCheck(tempobj)==false) 
				{
					return false;
				}
			}
			if (tempobj.name=="childrenage")
			{
				if (validatechildages(tempobj)==false) 
				{
					return false;
				}
			}
			if (tempobj.name.substring(0,2)=="rq") 
			{
				if (((tempobj.type=="text" || tempobj.type=="textarea")&&
						tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
						tempobj.selectedIndex==0)) 
				{
					pass=false;
					break;
				}
			}
	   }
	}
	if (!pass) 
	{
		shortFieldName=tempobj.name.substring(2,22).toUpperCase();
		alert(shortFieldName+FErr10);
		tempobj.focus();

		return false;
	}
//	else
//	{
//		if (CheckCardNumber(which)==false)
//			return false;
//		else
//			return true;
//	}
}

function ignoreSpaces(string) {
var temp = "";
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];

return temp;
}

function openhotellist(string, field) {
window.open(string,'popuppage','width=350,height=200,top=100,left=100');
	
}
//  End -->
