//ajax

var xmlHttp
var arrCityNames = new Array();
var arrCityValues = new Array();

function showCities(str)
{
    if(document.Form1.ddlCountry.value == "- Select Country -")
    {
	   document.Form1.ddlCountry.focus()
	   document.Form1.DdlDestination.options.length =1;
	   return false;
    }
    else
    {
        if (str.length==0)
        { 
            document.getElementById("spData").innerHTML=""
            return
        }
        
        var citiesList = document.getElementById("DdlDestination");
            citiesList.options.length = 0; // to empty the list
            citiesList.options[citiesList.options.length] =  new Option("Loading cities...","-1");
            xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
           {
            alert ("Browser does not support HTTP Request")
            return
           } 
        var url="getCities.aspx"
            url=url+"?q="+str
            url=url+"&sid="+Math.random()
            //onreadystatechange :: Event handler for an event that fires at every state change 
            xmlHttp.onreadystatechange=stateChanged   // stateChanged is user define Javascript funtion
            xmlHttp.open("GET",url,true)
            xmlHttp.send(null)
    }        
} 

// Amit Bhatnagar
//For this application “stateChanged” is the event-handler for the client side. Now inside the 
//event-handler (“stateChanged”) use readyState property to get various states. The value 4 is used 
//to indicate the completion of certain processing. Now before processing the result one should check the 
//status or statusText to determine the success or failure of the operation. In this application I did it 
//in the following way: 



function stateChanged() 
{ 
        //    0 = uninitialized
        //    1 = loading
        //    2 = loaded
        //    3 = interactive
        //    4 = complete 
        
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        var citiesList = document.getElementById("DdlDestination");
        var response = xmlHttp.responseText; // responseText :: Data returned from server in string form
        //        alert(response);

        var strValuesCombination= new Array();
        strValuesCombination = response.split('@');

        var strCityNames = strValuesCombination[0];
        var strCityValues = strValuesCombination[1];

        arrCityNames = strCityNames.split('|');
        arrCityValues = strCityValues.split('|');

        if(arrCityNames.length>0)
        {
            for (var i = 0; i < arrCityNames.length; i++)
            {
                citiesList.options[citiesList.options.length] =  new Option(arrCityNames[i], arrCityValues[i]);
            }

        citiesList.options[0]=new Option("- Select Destination -","-1"); 
        citiesList.options[0].selected = true;
 
        }
        else
        {
            citiesList.options[0] = null; 
            citiesList.options[citiesList.options.length] =  new Option("No Destination Found","-1");
        }
 } 

}

function GetXmlHttpObject()
{ 
    var objXMLHttp=null
        if (window.XMLHttpRequest)
        {
            objXMLHttp=new XMLHttpRequest()
        }
        else if (window.ActiveXObject)
        {
            objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
        }
return objXMLHttp
} 

function saveSelectedData()
{
    document.getElementById("hdnCity").value = "";
    var ctlCountry = document.getElementById("ddlCountry");
    var obj=document.getElementById("DdlDestination");
    var pos = parseInt(obj.selectedIndex)-1
    document.getElementById("hdnCity").value = arrCityValues[pos] + "|" + arrCityNames[pos] +"|"+ ctlCountry.options[ctlCountry.selectedIndex].value +"|"+ ctlCountry.options[ctlCountry.selectedIndex].innerHTML;
    //alert(document.getElementById("hdnCity").value);
}

 function divwrite()
 {
 
    var aheight=600
    var awidth=800
     varloadingtxt='<div id="prepage1" style="position: absolute; font-family: arial; font-size: 30; left: 0px;top: 0px; background-color: white; layer-background-color: white; height:' + parseInt(screen.availHeight) + 'px; width:'+ (screen.availWidth-100) +'px;visibility:hidden">';
     varloadingtxt=varloadingtxt+'<table align="center" height="100%" width="100%" border=0>';
     varloadingtxt=varloadingtxt+'      <tr>';
     varloadingtxt=varloadingtxt+'        <td align="center" valign="top" height="'+aheight+'">';
     varloadingtxt=varloadingtxt+'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + awidth + '" HEIGHT="' + aheight + '" ALIGN=""><PARAM NAME=movie VALUE="/Media/loading page.swf" WIDTH="500" HEIGHT="200"> <PARAM name="wmode" value="opaque"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="/Media/loading page.swf" wmode="opaque" quality=high bgcolor=#FFFFFF  WIDTH="500" HEIGHT="200" NAME="progress" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
     varloadingtxt =varloadingtxt+'           </b></td>'
     varloadingtxt=varloadingtxt+'  </tr>';
     varloadingtxt=varloadingtxt + '</table>';
     varloadingtxt=varloadingtxt + '</div>';
    document.write(varloadingtxt);
 }
 
 function divwriteTaxi()
 {
    //alert('taxi');
    var aheight=600
    var awidth=800
     varloadingtxt='<div id="prepage2" style="position: absolute; font-family: arial; font-size: 30; left: 0px;top: 0px; background-color: white; layer-background-color: white; height:' + parseInt(screen.availHeight) + 'px; width:'+ (screen.availWidth-100) +'px;visibility:hidden">';
     varloadingtxt=varloadingtxt+'<table align="center" height="100%" width="100%" border=0>';
     varloadingtxt=varloadingtxt+'      <tr>';
     varloadingtxt=varloadingtxt+'        <td align="center" valign="top" height="'+aheight+'">';
     varloadingtxt=varloadingtxt+'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + awidth + '" HEIGHT="' + aheight + '" ALIGN=""><PARAM NAME=movie VALUE="../Media/loading page.swf" WIDTH="500" HEIGHT="200"> <PARAM name="wmode" value="opaque"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="../Media/loading page.swf" wmode="opaque" quality=high bgcolor=#FFFFFF  WIDTH="500" HEIGHT="200" NAME="progress" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
     varloadingtxt =varloadingtxt+'           </b></td>'
     varloadingtxt=varloadingtxt+'  </tr>';
     varloadingtxt=varloadingtxt + '</table>';
     varloadingtxt=varloadingtxt + '</div>';
    document.write(varloadingtxt);
 }
 //function for Taxi block
function TaxiShowHideTables(tblid,wht) 
{ 
    document.getElementById('tblcontents').style.display='none';
    document.getElementById('tblInsurance').style.display='none';
    document.getElementById('tblflights').style.display='none';
    document.getElementById('tblHotels').style.display='none';
    document.getElementById('tblApartments').style.display='none';

    document.getElementById('tr_Taxi1').style.display='none';
    document.getElementById('tr_Taxi2').style.display='none';
    document.getElementById('tr_Taxi3').style.display='none';
    document.getElementById('tr_Apart1').style.display='none';
    document.getElementById('tr_Apart2').style.display='none';

    var objTaxiSubmit = document.getElementById("ImageButton2")
    var objApartmentSubmit = document.getElementById("ImageButton3")
    objTaxiSubmit.style.display="none";
    objApartmentSubmit.style.display="none";

    var objApartment = document.getElementById("tblSubApartment")
    objApartment.style.display="none";

    if(tblid=="tblApartments")
    {
        objTaxiSubmit.style.display="none";
        objApartmentSubmit.style.display="block";
        document.getElementById('tblcontents').style.display='block';
        document.getElementById('tblApartments').style.display='block';
        document.getElementById('tr_Apart1').style.display='block';
        document.getElementById('tr_Apart2').style.display='block';
    }
    else if(tblid=="tblHotels")
    {
         document.getElementById('tblHotels').style.display='block';
    }
    else if(tblid=="tblcontents")
    {
        objTaxiSubmit.style.display="block";    
        objApartmentSubmit.style.display="none";
         document.getElementById('tblcontents').style.display='block';
         document.getElementById('tr_Taxi1').style.display='block';
         document.getElementById('tr_Taxi2').style.display='block';
         document.getElementById('tr_Taxi3').style.display='block';
        objApartment.style.display="none";
    }
    else (document.getElementById)
    {
        document.getElementById(tblid).style.display=wht;
    }
}

function InsuranceShowHideTables(tblid,wht) 
{ 
/*tbltaxis,tblflights,tblapartment,tblcontents,tblinsurance==taxis,flights,*/
    document.getElementById('tblcontents').style.display='none';
    document.getElementById('tblTaxis').style.display='none';
    document.getElementById('tblflights').style.display='none';
    document.getElementById('tblHotels').style.display='none';
    document.getElementById('tblApartments').style.display='none';

    document.getElementById('tr_Taxi1').style.display='none';
    document.getElementById('tr_Taxi2').style.display='none';
    document.getElementById('tr_Taxi3').style.display='none';
    document.getElementById('tr_Apart1').style.display='none';
    document.getElementById('tr_Apart2').style.display='none';


    var objTaxiSubmit = document.getElementById("ImageButton2")
    var objApartmentSubmit = document.getElementById("ImageButton3")
    objTaxiSubmit.style.display="none";
    objApartmentSubmit.style.display="none";

    var objApartment = document.getElementById("tblSubApartment")
    objApartment.style.display="none";

    if(tblid=="tblApartments")
    {
        objTaxiSubmit.style.display="none";
        objApartmentSubmit.style.display="block";
        document.getElementById('tblTaxis').style.display='block';
        document.getElementById('tblApartments').style.display='block';
        document.getElementById('tr_Apart1').style.display='block';
        document.getElementById('tr_Apart2').style.display='block';
    }
    else if(tblid=="tblHotels")
    {
        document.getElementById('tblHotels').style.display='block';
    }
    else if(tblid=="tblTaxis")
    {
        objTaxiSubmit.style.display="block";    
        objApartmentSubmit.style.display="none";
        document.getElementById('tblTaxis').style.display='block';
        document.getElementById('tr_Taxi1').style.display='block';
        document.getElementById('tr_Taxi2').style.display='block';
        document.getElementById('tr_Taxi3').style.display='block';
        objApartment.style.display="none";
    }
    else (document.getElementById)
    {
        document.getElementById(tblid).style.display=wht;
    }
}
//function for insurance block
function ShowHideTables(tblid,wht) 
{ 
/*tbltaxis,tblflights,tblapartment,tblcontents,tblinsurance==taxis,flights,*/
    document.getElementById('tblTaxis').style.display='none';
    document.getElementById('tblflights').style.display='none';
    document.getElementById('tblApartments').style.display='none';
    document.getElementById('tblcontents').style.display='none';
    document.getElementById('tblInsurance').style.display='none';

    document.getElementById('tr_Taxi1').style.display='none';
    document.getElementById('tr_Taxi2').style.display='none';
    document.getElementById('tr_Taxi3').style.display='none';
    document.getElementById('tr_Apart1').style.display='none';
    document.getElementById('tr_Apart2').style.display='none';

    var objTaxiSubmit = document.getElementById("ImageButton2")
    var objApartmentSubmit = document.getElementById("ImageButton3")
    objTaxiSubmit.style.display="none";
    objApartmentSubmit.style.display="none";

    //chaman
    var objApartment = document.getElementById("tblSubApartment")
    objApartment.style.display="none";
    //chaman

    if(tblid=="tblApartments")
    {
        objTaxiSubmit.style.display="none";
        objApartmentSubmit.style.display="block";
        document.getElementById('tblTaxis').style.display='block';
        document.getElementById('tblApartments').style.display='block';
        document.getElementById('tr_Apart1').style.display='block';
        document.getElementById('tr_Apart2').style.display='block';
    }
    else if(tblid=="tblcontents")
    {
        objApartmentSubmit.style.display="none";
        document.getElementById('tblcontents').style.display='block';
        objApartment.style.display="none";
    }
    else if(tblid=="tblTaxis")
    {
        objTaxiSubmit.style.display="block";    
        objApartmentSubmit.style.display="none";
        document.getElementById('tblTaxis').style.display='block';
        document.getElementById('tr_Taxi1').style.display='block';
        document.getElementById('tr_Taxi2').style.display='block';
        document.getElementById('tr_Taxi3').style.display='block';
        objApartment.style.display="none";
    }

    else (document.getElementById)
    {
        document.getElementById(tblid).style.display=wht;
    }
}
//function for insurance block
function waitPreloadPage1() 
{ //DOM
    window.scroll(0,0);
    if (document.getElementById)
    {
        document.getElementById('prepage1').style.visibility='visible';

//alert("Test Message:" + document.getElementById('prepage1').style.height);
        document.getElementById('prepage1').style.height = 1500;
        if(document.getElementById('tblcontents') != null)
        {
            document.getElementById('tblcontents').style.visibility='hidden';
        }
        else
        {
            document.getElementById('testToT').style.visibility='hidden';
            document.getElementById('testToT1').style.visibility='hidden';
            
        }
    }
    else
    {
        if (document.layers)
        { //NS4
            document.prepage1.visibility = 'visible';
            document.prepage1.height=1500;
            document.prepage1.visibility='hidden';
        }
        else
        { //IE4
            document.all.prepage1.style.visibility = 'visible';
            document.getElementById('prepage1').style.height = 1500;
            document.prepage1.style.visibility='hidden';
        }
    }
}

function waitPreloadPage2() { //DOM
window.scroll(0,0);
if (document.getElementById){
document.getElementById('prepage1').style.visibility='visible';

//alert("Test Message:" + document.getElementById('prepage1').style.height);
document.getElementById('prepage1').style.height = 1500;
//document.getElementById('tblcontents').style.visibility='hidden';
}else{
if (document.layers){ //NS4
document.prepage1.visibility = 'visible';
document.prepage1.height=1500;
document.prepage1.visibility='hidden';

}
else { //IE4
document.all.prepage1.style.visibility = 'visible';
document.getElementById('prepage1').style.height = 1500;
document.prepage1.style.visibility='hidden';
}
}
}


