function ValidateDate(StartDate,EndDate)
{

     var dayfrom=StartDate.substring(0,2);
     var monthfrom=StartDate.substring(3,5);
     var yearfrom=StartDate.substring(6,10);
     var FromDate=new Date(yearfrom,monthfrom,dayfrom);
     var dayTo=EndDate.substring(0,2);
     var monthTo=EndDate.substring(3,5);
     var yearTo=EndDate.substring(6,10);
     var ToDate=new Date(yearTo,monthTo,dayTo);
     if(FromDate >= ToDate)
     {
        return false;
     }
     else
     {
        return true;
     }
}

function Validate(theForm)
{
        if(theForm.cboCity.value=="")
        {
            alert('Please select the city');
            theForm.cboCity.focus();
            return false;
        }
        if(theForm.txtCheckIn.value=="")
        {
            alert('Please enter the arrival date');
            theForm.txtCheckIn.focus();
            return false;
        }
        if(theForm.txtCheckOut.value=="")
        {
            alert('Please enter the departure date');
            theForm.txtCheckOut.focus();
            return false;
        }        

        if(theForm.txtCheckIn.value!="" && theForm.txtCheckOut.value!="")
        {
            var arrivaldate = theForm.txtCheckIn.value;
            var departuredate = theForm.txtCheckOut.value;
            var Validate= ValidateDate(arrivaldate,departuredate);
           if(Validate==false)
           {
                alert('Departure date should be greater than arrival date');
                theForm.txtCheckOut.focus();
                return false;
           }
        }
	document.frmSearch.submit();
 }
 

