﻿    var status="true";
    // JScript File
    function checknull()
    {
    var	to_day =	new	Date()
    to_day.setDate(to_day.getDate()+2)
    var dtCity=document.getElementById('txtFrom');
    //alert(dtCity.value);
    if(trim(dtCity.value)=="")
    {
    alert("Enter a ‘from’ city/airport.");
    dtCity.focus();
    return false;
    }
    var arcity=document.getElementById('txtTo');
    if(trim(arcity.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity.focus();
    return false;
    }
    if(trim(dtCity.value)==trim(arcity.value))
    {
    alert("Both the cities are same.");
    arcity.focus();
    return false;
    }

      // By Sachin to check for Domestic vacation results (flight +Hotel)
      
    /*if(dtCity.value!="")
    {        
        var source=dtCity.value;        
        var source1=arcity.value;        
	    var country=source.substring(source.lastIndexOf("-")+1,source.length);
	    var country1=source1.substring(source1.lastIndexOf("-")+1,source1.length);	
	    country= trim(country);
	    country1=trim(country1);	    
	    if(country != "UNITED STATES")
	    {	       
		    alert("Flight + Hotel is available for US domestic travel only, please buy flight and hotel seperately for travelling outside USA");		    
		    return true;
	    }
	    if(country1 != "UNITED STATES")
	    {	       
		    alert("Flight + Hotel is available for US domestic travel only, please buy flight and hotel seperately for travelling outside USA");		    
		    return true;
	    }
	 } */ 
    //END

    var ddate=document.getElementById('txtDepart');

        if(trim(ddate.value)=="")
        {
        alert("Enter depart date.");
        ddate.focus();
        return false;
        }
        if (isDate(ddate.value)==false){
        ddate.focus()
        return false
        }
//        if(searchTypeCal=='Intlflight' || searchTypeCal=='IntlflightResult'|| searchTypeCal=='multicity')
//        {
//        }
//        else
//        {
//            if(Date.parse(ddate.value)<=Date.parse(to_day))
//            {
//            alert("At least 48 hours prior to departure.");
//            ddate.focus();
//            return false;
//            }
//        }
    if(document.getElementById('rdRound').checked)
    {
        var adate=document.getElementById('txtReturn');
        if(trim(adate.value)=="")
        {
        alert("Enter return date.");
        adate.focus();
        return false;
        }
        if (isDate(adate.value)==false)
        {
        adate.focus()
        return false
        }
        if(Date.parse(ddate.value)>Date.parse(adate.value))
        {
        alert("Return date should be greater than depart date.");
        adate.focus();
        return false;
        }
    }

   
    var passAdult=document.getElementById('ddlAdult');
    var passChild=document.getElementById('ddlChild');
    var passInfants=document.getElementById('ddlInfants');
    var Travelers=parseInt(passAdult.value)+parseInt(passChild.value)+parseInt(passInfants.value);
    if(searchTypeCal=='Intlflight' || searchTypeCal=='IntlflightResult' || searchTypeCal=='multicity')
    {
    if(parseInt(passInfants.value)>parseInt(passAdult.value))
    {
    alert("No. of infants can not be greater than no. of adults.");
    return false;
    }
    }
    if(Travelers>8)
    {
    alert("Travelers can not be more than 8.");
    return false;
    }
    childCodes();
    }

    // JScript File
    function checkMulticity()
    {

    var	to_day =	new	Date()
    to_day.setDate(to_day.getDate()+2)
    var dtCity=document.getElementById('txtFrom1');
    if(trim(dtCity.value)=="")
    {
    alert("Enter a ‘from’ city/airport.");
    dtCity.focus();
    return false;
    }
    var arcity=document.getElementById('txtTo1');
    if(trim(arcity.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity.focus();
    return false;
    }
    if(trim(dtCity.value)==trim(arcity.value))
    {
    alert("Flight1: Both the cities are same.");
    arcity.focus();
    return false;
    }
    var ddate=document.getElementById('txtDepart1');
    if(trim(ddate.value)=="")
    {
    alert("Enter depart date.");
    ddate.focus();
    return false;
    }

   var dtCity2=document.getElementById('txtFrom2'); 
    var arcity2=document.getElementById('txtTo2');
    if(trim(dtCity2.value)!="")
    {
    
     if(trim(arcity2.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity2.focus();
    return false;
    }
   
    }
  
    if(trim(arcity2.value)!="")
    {
         if(trim(dtCity2.value)=="")
        {
        alert("Enter a ‘from’ city/airport.");
        dtCity2.focus();
        return false;
        }
    }
    if(trim(dtCity2.value)==trim(arcity2.value))
    {
    alert("Flight2: Both the cities are same.");
    arcity2.focus();
    return false;
    }
    var ddate2=document.getElementById('txtDepart2');
    if(trim(ddate2.value)=="")
    {
    alert("Enter depart date.");
    ddate2.focus();
    return false;
    }

    var dtCity3=document.getElementById('txtFrom3'); 
    var arcity3=document.getElementById('txtTo3');
    if(trim(dtCity3.value)!="")
    {
    
     if(trim(arcity3.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity3.focus();
    return false;
    }
   
    }
  
    if(trim(arcity3.value)!="")
    {
         if(trim(dtCity3.value)=="")
        {
        alert("Enter a ‘from’ city/airport.");
        dtCity3.focus();
        return false;
        }
    }
    if(trim(dtCity2.value)==trim(arcity2.value))
    {
    alert("Flight3: Both the cities are same.");
    arcity.focus();
    return false;
    }
    var ddate3=document.getElementById('txtDepart3');
    if(trim(ddate3.value)=="")
    {
    alert("Enter depart date.");
    ddate3.focus();
    return false;
    }



  
    var passAdult=document.getElementById('ddlAdult');
    var passChild=document.getElementById('ddlChild');
    var passInfants=document.getElementById('ddlInfants');
    var Travelers=parseInt(passAdult.value)+parseInt(passChild.value)+parseInt(passInfants.value);
    if(parseInt(passInfants.value)>parseInt(passAdult.value))
    {
    alert("No. of infants can not be greater than no. of adults.");
    return false;
    }

    if(Travelers>8)
    {
    alert("Travelers can not be more than 8.");
    return false;
    }
    childCodes();
    }

    function validatehotelcar()
    {
    var City=document.getElementById('txtCityHC');
    if(trim(City.value)=="")
    {
    alert("City name can not be blank.");
    City.focus();
    return false;
    }
    var Checkin=document.getElementById('txtCheckin');
    if(trim(Checkin.value)=="")
    {
    alert("Enter Check-in date.");
    Checkin.focus();
    return false;
    }
    if (isDate(Checkin.value)==false)
    {
    Checkin.focus()
    return false
    }
    var Checkout=document.getElementById('txtCheckout');

    if(trim(Checkout.value)=="")
    {
    alert("Enter Check-out date.");
    Checkout.focus();
    return false;
    }
    if (isDate(Checkout.value)==false)
    {
    Checkout.focus()
    return false
    }
    if(Date.parse(Checkin.value)>=Date.parse(Checkout.value))
    {
    alert("Check-in date must be prior to check-out date.");
    Checkout.focus();
    return false;
    }
    date1 = new Date(Checkin.value);
    date2 = new Date(Checkout.value);
    var day=((date2-date1)/ (60*60*24)) / 1000;
    if(day>26)
    {
    alert("Hotel can be booked for a maximum of 26 nights. Please change the dates of your stay.");
    Checkout.focus();
    return false;
    }
    return true;
    }
    function childCodesVac()
    {
  
    var childSelects=document.getElementById('ddlChild');
    var InfantsSelects=document.getElementById('ddlInfants');
    var childCount=parseInt(childSelects.value);
    var InfantsCount=parseInt(InfantsSelects.value);
    var divInfants=document.getElementById('div_infant');
    var childCodes="";
  
    for(var i=1;i<=InfantsCount;i++)
    { 
    var InfantsSeat=document.getElementById("rd_infants_w"+ i);
    var InfantsWithoutSeat=document.getElementById("rd_infants_wo"+ i);
    if(InfantsSeat.checked)
    { 
    childCodes+="INS,";
    }
    if(InfantsWithoutSeat.checked)
    {
    childCodes+="INF,";
    }
    }
    for(var i=0;i<=childCount-1;i++)
    {  
    var chcode=1+i;
    var childSelects=document.getElementsByName("child" + chcode);
    var chidAge=childSelects[0].value;
    if(childCount>1)
    {
    childCodes+="C"+chidAge+",";
    }
    else
    {
    childCodes+="C"+chidAge;
    }
    }
   
    document.getElementById("hdd_childcodes").value=childCodes;   
    return true;
    }
    
    
    function childCodes()
    {
  
    var childSelects=document.getElementById('ddlChild');
    var InfantsSelects=document.getElementById('ddlInfants');
    var childCount=parseInt(childSelects.value);
    var InfantsCount=parseInt(InfantsSelects.value);
    var divInfants=document.getElementById('div_infant');
    var childCodes="";

    for(var i=1;i<=InfantsCount;i++)
    {
    childCodes+="INF,";
    }

    for(var i=0;i<=childCount-1;i++)
    {  
    childCodes+="C06,";
    }

    document.getElementById("hdd_childcodes").value=childCodes;   
    return true;
    }
    
    
    
    function showFlightAges(CCode)
    {
     try
    {
    status=document.getElementById('hdd_setIntl').value;
    }
    catch(exception){
    }
    if(status!="false")
    {
    //alert("In showFlightAges");
    var Code,chdCode,infts,infantsC;
    if(CCode=='index')
    Code="";
    else
    Code=document.getElementById("hdd_childcodes").value;
    if(Code!="")
    {
    chdCode = Code.indexOf('C');
    if(chdCode>=0)
    {
    chld = Code.substring(chdCode);
    childC = chld.split(',');
    }
    }

    var AgeTable = document.getElementById("FAgesTable");
    deleteTable(AgeTable);
    var childSelects = document.getElementsByName("ddlChild");
    var v = 0;
    for (var count=0;count<childSelects.length;count++)
    {      
    var childAge = childSelects[count].value;
    if (childAge>0)
    {
    var row = AgeTable.insertRow( v++);
    var cell = row.insertCell(0);
    cell.className = "whiteText"
    var str = "";
    var childStr = "";
    str += "<table border=0><tr><td colspan='4' class='Ar_bold_black_12'> Age of children :</td></tr><tr valign=top>";
    var dupCnt=0;
    for(var childCount=1;childCount<=childAge;childCount++)
    {
    var selectName="child"+childCount;
    if(searchTypeCal!="flightResult")
    {
         if(searchTypeCal=="vacResult")
        {
        if(childCount==3||childCount==5)
        str += "</tr><tr>";
        }
        else
        {
        if(childCount==6)
        str += "</tr><tr>";
        }
    }
    
    str += "<td style='padding-left:5px' class='MatrixLogoHeadingText'>Child" + childCount + "<br></br>";
    str += "<SELECT class='MatrixLogoHeadingText' style='width:50px;' name='" + selectName+"'>";
    for (var ageCount=2;ageCount<=12;ageCount++)
    {
    if(ageCount<10)
    {
        ageCount="0"+ageCount;
    }
    if(Code!="")
    {
         if(chdCode>=0)
           {

            if(childC[childCount-1].replace('C','')==ageCount)
             str += "<option value=" + ageCount + " SELECTED>" + ageCount + "</option>";
            else
             str += "<option value=" + ageCount + ">" + ageCount + "</option>";
           }
    }
    else
    {
        str += "<option value=" + ageCount + ">" + ageCount + "</option>";
    }
    }
    str += "</select>";
    str += "</td>";
    dupCnt++;
    }
    str += "</tr></table>";
    cell.innerHTML = str;

    }
    }
    }
    }
    function showInfants(CCode)
    {
    
    try
    {
    status=document.getElementById('hdd_setIntl').value;
    }
    catch(exception){
    }
    if(status!="false")
    {
    var Code,chdCode,infts,infantsC;
    if(CCode=='index')
    Code="";
    else
    Code=document.getElementById("hdd_childcodes").value;
    if(Code!="")
    {
    chdCode = Code.indexOf('C');
    if(chdCode>0)
    {
    infts = Code.substring(0, chdCode-1);
    infantsC = infts.split(',');
    }
    else if(chdCode=0)
    {
    infts="";
    }
    else
    {
    infts=Code;
    infantsC = infts.split(',');
    }
    }

    var AgeTable = document.getElementById("FInfantsTable");
    deleteTable(AgeTable);
    var InfantsSelects = document.getElementsByName("ddlInfants");

    var v = 0;
    for (var count=0;count<InfantsSelects.length;count++)
    {
    var Infants = InfantsSelects[count].value;
    if (Infants>0)
    {
    var row = AgeTable.insertRow( v++);
    var cell = row.insertCell(0);
    cell.className = "whiteText"
    var str = "";
    var InfantsStr = "";
    str += "<table border=0 cellpadding='3' cellspacing='1'><tr><td colspan='4' class='Ar_bold_black_12'> Infants:</td></tr><tr valign=top>";
    for(var InfantsCount=1;InfantsCount<=Infants;InfantsCount++)
    {

    var selectName="Infants "+InfantsCount;
  
    if(searchTypeCal!="flightResult" || searchTypeCal!="IntlflightResult")
    {
     
    if(searchTypeCal=="vacResult")
    {
     if(InfantsCount==2 ||InfantsCount==3 ||InfantsCount==4||InfantsCount==5 ||InfantsCount==6)
     str += "</tr><tr>";
    }
    else
    {
    if(InfantsCount==4)
    str += "</tr><tr>";
    }
    }
    
   
    if(Code!="")
    {
    str += "<td class='MatrixLogoHeadingText'>#" + InfantsCount + "<br></br>";
    if(infantsC[InfantsCount-1]=="INS")
    {
        str += "<input type='radio' checked='true' id='rd_infants_w"+ InfantsCount +"' name='group"+ InfantsCount +"' /><span class='MatrixLogoHeadingText' >with&nbsp;seat</span><br />";
        str += " <input type='radio'  id='rd_infants_wo"+ InfantsCount +"' name='group"+ InfantsCount +"'  /><span class='MatrixLogoHeadingText' >without seat</span>";
    }
    else
    {
        str += "<input type='radio' id='rd_infants_w"+ InfantsCount +"' name='group"+ InfantsCount +"' /><span class='MatrixLogoHeadingText' >with&nbsp;seat</span><br />";
        str += " <input type='radio' checked='true' id='rd_infants_wo"+ InfantsCount +"' name='group"+ InfantsCount +"'  /><span class='MatrixLogoHeadingText' >without&nbsp;seat</span>";
    }
    str += "</td>";
    }
    else
    {
    str += "<td class='Ar_11'>#" + InfantsCount + "<br></br>";
    str += "<input type='radio' checked='true' id='rd_infants_w"+ InfantsCount +"' name='group"+ InfantsCount +"' /><span class='MatrixLogoHeadingText' >with&nbsp;seat</span><br />";
    str += " <input type='radio'  id='rd_infants_wo"+ InfantsCount +"' name='group"+ InfantsCount +"'  /><span class='MatrixLogoHeadingText' >without&nbsp;seat</span>";
    str += "</td>";
    }

    }
    str += "</tr></table>";
    cell.innerHTML = str;
    }
    }
    }
    }


    function deleteTable(table)
    {
    if (table==null)
    return;
    for (var count=table.rows.length-1;count>=0;count--)
    {
    table.deleteRow(count);
    }
    }


    function trim(str)
    {
    return str.replace(/^\s+|\s+$/g,'');
    }

    function chkTrip(tType)
    {
        if(tType=="O")
        {
        if(document.getElementById("rdFlightOnly").checked)
        {
        document.getElementById("divReturn").style.display = "none";
        document.getElementById("divReturn1").style.display = "none";
       try
        {
        document.getElementById("divFlexi").style.display = "none";
        }
        catch(exception){}
        }
        }
        else if(tType=="OW")
        {      
        document.getElementById("divReturn").style.display = "none";
        document.getElementById("divReturn1").style.display = "none";
        try
        {
        document.getElementById("divFlexi").style.display = "none";
        }
        catch(exception){}

        }
        else
        {
        document.getElementById("divReturn").style.display = "block";
        document.getElementById("divReturn1").style.display = "block";
        try
        {
        if(document.getElementById("rdFlightOnly").checked==true)
        document.getElementById("divFlexi").style.display = "block";
        }
        catch(exception){}
        }
    }
    function chkTripIntl(tType)
    {
        if(tType=="O")
        {
        if(document.getElementById("rdFlightOnly").checked)
        {
        document.getElementById("divReturn").style.display = "none";
        document.getElementById("divReturn1").style.display = "none";
        //document.getElementById("divReturn2").style.display = "none";
        }
        }
        else if(tType=="OW")
        {      
        document.getElementById("divReturn").style.display = "none";
        document.getElementById("divReturn1").style.display = "none";
       // document.getElementById("divReturn2").style.display = "none";

        }
        else
        {
        document.getElementById("divReturn").style.display = "block";
        document.getElementById("divReturn1").style.display = "block";
       // document.getElementById("divReturn2").style.display = "block";
        }
    }

    function chkTrip1(tType,rHide)
    {

    if(tType=="O")
    {
    document.getElementById("lbl_rtrn").style.display = "none";
    document.getElementById("div_FRtrn").style.display = "none";
    document.getElementById("ddlAtime").style.display = "none";
    document.getElementById("div_RTime").style.display="none";
    //document.getElementById("div_lblRen").style.display = "none";
    }
    else
    {
    document.getElementById("lbl_rtrn").style.display = "block";
    document.getElementById("div_FRtrn").style.display = "block";
    document.getElementById("ddlAtime").style.display = "block";
    document.getElementById("div_RTime").style.display="block";
    //document.getElementById("div_lblRen").style.display = "block";
    }
    }
    function displayFlexi(type)
    {
    if(type=="oneway")
    {
    document.getElementById("divFlexi").style.display = "none";
    }
    else
    {
    document.getElementById("divFlexi").style.display = "block";
    }
    }

    function validate()
    {
    var City=document.getElementById('txtCity');

    if(trim(City.value)=="")
    {
    alert("City name can not be blank.");
    City.focus();
    return false;
    }


    var Checkin=document.getElementById('txtCheckin');
    if(trim(Checkin.value)=="")
    {
    alert("Enter Check-in date.");
    Checkin.focus();
    return false;
    }
    if (isDate(Checkin.value)==false){

    Checkin.focus()
    return false
    }


    var Checkout=document.getElementById('txtCheckout');

    if(trim(Checkout.value)=="")
    {
    alert("Enter Check-out date.");
    Checkout.focus();
    return false;
    }
    if (isDate(Checkout.value)==false){

    Checkout.focus()
    return false
    }

    if(Date.parse(Checkin.value)>=Date.parse(Checkout.value))
    {
    alert("Check-out date should be greater than check-in date.");
    Checkout.focus();
    return false;

    }
    date1 = new Date(Checkin.value);
    date2 = new Date(Checkout.value);
    var day=((date2-date1)/ (60*60*24)) / 1000;
    if(day>26)
    {
    alert("Hotel can be booked for a maximum of 26 nights. Please change the dates of your stay.");
    Checkout.focus();
    return false;
    }
    return true;
    }

    function checknullcar()
    {
    var dtCity=document.getElementById('txtairport'); 
    if(trim(dtCity.value)=="")
    {
    alert("Enter depart City/Airport.");
    dtCity.focus();
    return false;
    } 
    var dtFrom=document.getElementById('txtcarDepart');
    if(trim(dtFrom.value)=="")
    {
    alert("Enter pickup Date.");
    dtFrom.focus();
    return false;
    } 
    if (isDate(dtFrom.value)==false)
    {
    dtFrom.focus()
    return false
    }
    var dtTo=document.getElementById('txtcarReturn');
    if(trim(dtTo.value)=="")
    {
    alert("Enter drop off Date.");
    dtTo.focus();
    return false;
    }
    if (isDate(dtTo.value)==false)
    {
    dtTo.focus()
    return false
    }
    var dtCity=document.getElementById('deptime');
    if(trim(dtCity.value)=="")
    {
    alert("Enter depart Time.");
    dtCity.focus();
    return false;
    }
    var dtCity=document.getElementById('arrtime');
    if(trim(dtCity.value)=="")
    {
    alert("Enter Arrival Time.");
    dtCity.focus();
    return false;
    }
    if(document.getElementById('txtcarReturn').value!="")
    {
    if(Date.parse(document.getElementById('txtcarDepart').value)>Date.parse(document.getElementById('txtcarReturn').value))
    {
    alert("Drop off date should be grater than Pickup date.");
    dtCity.focus();
    return false; 
    }
    }
    return true;
    }

    function showcarsearch(){
    document.getElementById("flightdiv").style.display='none';
    document.getElementById("cardiv").style.display='block';
    }

    function showflightsearch(){
    document.getElementById("flightdiv").style.display='block';
    document.getElementById("cardiv").style.display='none';
    }
    function showcity(){


    }

    function showcityap(){    
    if(document.frmIndex.SearchBy.value=='city'){
    document.getElementById('showair').style.display='none';      
    document.getElementById('showcity').style.display='block'; 
    document.getElementById('dropofflbl').style.display='none';
    document.getElementById('droptxt').style.display='none';     
    }
    else  {document.getElementById('showcity').style.display='none';
    document.getElementById('showair').style.display='block';
    document.getElementById('dropofflbl').style.display='block';
    document.getElementById('droptxt').style.display='block';
    }
    }
    function check_vacation()
    {
    var	to_day =	new	Date()
    to_day.setDate(to_day.getDate()+2)
    var dtCity=document.getElementById('txtFrom');
    if(trim(dtCity.value)=="")
    {
    alert("Enter a ‘from’ city/airport.");
    dtCity.focus();
    return false;
    }
    var arcity=document.getElementById('txtTo');
    if(trim(arcity.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity.focus();
    return false;
    }
    if(trim(dtCity.value)==trim(arcity.value))
    {
    alert("Both the cities are same.");
    arcity.focus();
    return false;
    }
    var ddate=document.getElementById('txtDepart');

    if(trim(ddate.value)=="")
    {
    alert("Enter depart date.");
    ddate.focus();
    return false;
    }
    if (isDate(ddate.value)==false){

    ddate.focus()
    return false
    }
    if(Date.parse(ddate.value)<=Date.parse(to_day))
    {
    alert("At least 48 hours prior to departure.");
    ddate.focus();
    return false;
    }
    var adate=document.getElementById('txtReturn');
    if(trim(adate.value)=="")
    {
    alert("Enter return date.");
    adate.focus();
    return false;
    }
    if (isDate(adate.value)==false)
    {
    adate.focus()
    return false
    }
    if(Date.parse(ddate.value)>Date.parse(adate.value))
    {
    alert("Return date should be greater than depart date.");
    adate.focus();
    return false;
    }
    
    var passAdult=document.getElementById('ddlAdult');
    var passChild=document.getElementById('ddlChild');
    var passInfants=document.getElementById('ddlInfants');
    var Travelers=parseInt(passAdult.value)+parseInt(passChild.value)+parseInt(passInfants.value);
    if(Travelers>8)
    {
    alert("Travelers can not be more than eight.");
    return false;
    }
    childCodes();
    }
    function validate_vaccation()
    {
    var	to_day =	new	Date()
    to_day.setDate(to_day.getDate()+2)
    var dtCity=document.getElementById('txtFrom');
    if(trim(dtCity.value)=="")
    {
    alert("Enter a ‘from’ city/airport.");
    dtCity.focus();
    return false;
    }
    var arcity=document.getElementById('txtTo');
    if(trim(arcity.value)=="")
    {
    alert("Enter a ‘to’ city/airport.");
    arcity.focus();
    return false;
    }
    if(trim(dtCity.value)==trim(arcity.value))
    {
    alert("Both the cities are same.");
    arcity.focus();
    return false;
    }

    var ddate=document.getElementById('txtDepart');

    if(trim(ddate.value)=="")
    {
    alert("Enter depart date.");
    ddate.focus();
    return false;
    }
    if (isDate(ddate.value)==false){

    ddate.focus()
    return false
    }
    if(Date.parse(ddate.value)<=Date.parse(to_day))
    {
    alert("At least 48 hours prior to departure.");
    ddate.focus();
    return false;
    }


    var adate=document.getElementById('txtReturn');
    if(trim(adate.value)=="")
    {
    alert("Enter return date.");
    adate.focus();
    return false;
    }
    if (isDate(adate.value)==false)
    {
    adate.focus()
    return false
    }
    if(Date.parse(ddate.value)>=Date.parse(adate.value))
    {
    alert("Return date should be greater than depart date.");
    adate.focus();
    return false;
    }

    date1 = new Date(adate.value);
    date2 = new Date(ddate.value);
    var day=((date1-date2)/ (60*60*24)) / 1000;

    if(day>26)
    {
    alert("Vacation packages can be booked for a maximum of 26 nights. Please change the dates of your stay.");
    adate.focus();
    return false;
    }

   
    var passAdult=document.getElementById('ddlAdult');
    var passChild=document.getElementById('ddlChild');
    var passInfants=document.getElementById('ddlInfants');
    var Travelers=parseInt(passAdult.value)+parseInt(passChild.value)+parseInt(passInfants.value);
    if(Travelers>8)
    {
    alert("Travelers can not be more than eight.");
    return false;
    }

    childCodes();

    }

    function showOption(type)
    {
    if(type=='flight')
    {
    var div_option=document.getElementById("div_optionF");
    div_option.style.display = "block"
    }
    else if(type=='hotel')
    {
    var div_option=document.getElementById("div_optionH");
    div_option.style.display = "block"
    }
    else if(type=='car')
    {
    var div_option=document.getElementById("div_optionC");
    div_option.style.display = "block"
    }
    }
    function vacationBookingValidation()
    {
    var from=document.getElementById('txtFrom');
    var to=document.getElementById('txtTo');
    var Checkin=document.getElementById('txtDepart');
    var Checkout=document.getElementById('txtReturn');
    var hotelCarRD=document.getElementById('rdbFlightCarH');

    if(trim(from.value)=="")
    {
    alert("Please enter a ‘from’ city/airport.");
    from.focus();
    return false;
    }
    if(hotelCarRD!=null)
    {
        if(hotelCarRD.checked==false)
        {
            if(trim(to.value)=="")
            {
            alert("Please enter a ‘to’ city/airport.");
            to.focus();
            return false;
            }
        }
    }
    
    
    if(trim(Checkin.value)=="")
    {
    alert("Please enter departing date.");
    Checkin.focus();
    return false;
    }
    if(trim(Checkout.value)=="")
    {
    alert("Please enter returning date.");
    Checkout.focus();
    return false;
    }
    var date1 = new Date(Checkin.value);
    var date2 = new Date(Checkout.value);

    if(Date.parse(date1)>=Date.parse(date2))
    {
    alert("Return date should be greater than depart date.");
    Checkout.focus();
    return false;
    }
    var day=((date2-date1)/ (60*60*24)) / 1000;
        if(day>26)
            {
            alert("Vacation packages can be booked for a maximum of 26 nights. Please change the dates of your stay.");
            Checkout.focus();
            return false;
            }

   
    var passAdult=document.getElementById('ddlAdult');
    var passChild=document.getElementById('ddlChild');
    var passInfants=document.getElementById('ddlInfants');
    var Travelers=parseInt(passAdult.value)+parseInt(passChild.value)+parseInt(passInfants.value);
   
    if(parseInt(passInfants.value)>parseInt(passAdult.value))
    {
    alert("No. of infants can not be greater than no. of adults.");
    return false;
    }
    
    if(Travelers>8)
    {
    alert("Travelers can not be more than 8.");
    return false;
    }
   
    childCodes();
    }
    
    
    function rblCustomerCheck(rblid)
    {
    var radioButtons = document.getElementsByName(rblid);
    var rblSelectedVal ="";
      for (var x = 0; x < radioButtons.length; x ++)
       {
        if (radioButtons[x].checked)
         {
          rblSelectedVal=radioButtons[x].value;
            }
        }
        

        var HdfEmailId=document.getElementById('HdfEmailId');
           if (rblSelectedVal == "Customer")
            {
                        
                document.getElementById('txtEmail').value =HdfEmailId.value;
                document.getElementById('txtEmail').disabled=true;
            }
           else
            {
            document.getElementById('txtEmail').value= "";
            document.getElementById('txtEmail').disabled=false;
            }
    }
    function validate_email()
   {
    
     var txtbx_emladd=document.getElementById('txtEmail');
      if(trim(txtbx_emladd.value)=="")
      {
      
          document.form1.elements['txtEmail'].focus();
         alert('Enter e-mail address');
               
          return false;
      }
     
     else if(!isEmail(trim(txtbx_emladd.value)))
      {
          document.form1.elements['txtEmail'].focus();
          alert('E-mail address is invalid');
                   
          return false;
      }
          
     else
     {
         return true;
     }
   }
    function isEmail(str)
    {
        var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
        return regex.test(str);
    }
  function trim(AnyString) {
        return AnyString.replace(/^\s+|\s+$/g, '')
        }
