  function loadfd(form) {
    checkVal = document.DateSelect.fd.selectedIndex;
    if (checkVal == 30){
      checkVal = checkVal-1;
    }
    document.DateSelect.td.options[checkVal+1].selected=1;
  }

  function loadfm(form) {
    checkVal = document.DateSelect.fm.selectedIndex;
    document.DateSelect.tm.options[checkVal].selected=1;
  }

  function loadfy(form) {
    checkVal = document.DateSelect.fy.selectedIndex;
    document.DateSelect.ty.options[checkVal].selected=1;
  }

  //Weekday Array
  var wdArray = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")

  //set weekdays
  function setWkd(form) {

    for (var i = 0; i < document.DateSelect.fy.length; i++) {
      if (document.DateSelect.fy.options[i].selected)
        var fyear = document.DateSelect.fy.options[i].text;
      if (document.DateSelect.ty.options[i].selected)
        var tyear = document.DateSelect.ty.options[i].text;
      }
    var checkinDate = new Date(fyear,document.DateSelect.fm.selectedIndex,document.DateSelect.fd.selectedIndex+1);
    var checkoutDate = new Date(tyear,document.DateSelect.tm.selectedIndex,document.DateSelect.td.selectedIndex+1);

    document.DateSelect.inWd.value = "(" + wdArray[checkinDate.getDay()] + ")"
    document.DateSelect.outWd.value = "(" + wdArray[checkoutDate.getDay()] + ")"

    var numNights = Math.round((checkoutDate - checkinDate) / 86400000)

    if (numNights < 1) numNights = "?????";
    else if (numNights == 1) numNights;
    else numNights;

    form.lengthStay.value = numNights
	document.all["stay"].innerHTML = numNights;
  }

  function submitlangform() {
    document.langform.submit();
  }
  
  
  function chkdaterange() {
	if(document.DateSelect.cross[document.DateSelect.cross.selectedIndex].value == ""){
		alert("Please Selected Hotel");
		return false;
	}

	var ar , de
	errmsg = "";
	
  	ar = (document.DateSelect.fy.value + document.DateSelect.fm.value + document.DateSelect.fd.value) * 1;
  	de = (document.DateSelect.ty.value + document.DateSelect.tm.value + document.DateSelect.td.value) * 1;

	today = 20100305 * 1;
	if ((document.DateSelect.fm.value == 2 && document.DateSelect.fd.value > 29) || (document.DateSelect.tm.value == 2 && document.DateSelect.td.value > 29))
	{
		errmsg = errmsg + "Wrong Date Period.\n"; 
	}
	else if (
		(document.DateSelect.fm.value == 4 && document.DateSelect.fd.value > 30) || 
		(document.DateSelect.fm.value == 6 && document.DateSelect.fd.value > 30) || 
		(document.DateSelect.fm.value == 9 && document.DateSelect.fd.value > 30) || 
		(document.DateSelect.fm.value == 11 && document.DateSelect.fd.value > 30) ||
		(document.DateSelect.tm.value == 4 && document.DateSelect.td.value > 30) || 
		(document.DateSelect.tm.value == 6 && document.DateSelect.td.value > 30) || 
		(document.DateSelect.tm.value == 9 && document.DateSelect.td.value > 30) || 
		(document.DateSelect.tm.value == 11 && document.DateSelect.td.value > 30)
	)
	{
		errmsg = errmsg + "Wrong Date Period.\n"; 
	}
	else if (ar >= de)
	{	
		errmsg = errmsg + "Wrong Date Period.\n"; 
	}
	else if (ar < today || de < today)
	{	
		errmsg = errmsg + "The dates selected are invalid.\nArrival Date entered is prior to today's date.\n"; 
	}
		
	if (errmsg != "")
	{
		alert(errmsg);
		return false;
	}
  }