﻿// JScript File

var xmlHttp
var xmlHttpA
var charterSpecCond;

function GetCities2(CountryID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?cid="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function GetCitiesTT(CountryCode)
{
    xmlHttp = GetXmlHttpObject();
    if ( xmlHttp == null )
    {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url="../../../test/AJAX.aspx";
    url=url+"?ttccd="+CountryCode;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=StateChangedGetCitiesTT;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function StateChangedGetCitiesTT()
{
    if (xmlHttp.readyState==4)
    { 
       FillCitiesTours(xmlHttp.responseText);
    }
}
function IsReservationBlocked(ReservationID)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../test/AJAX.aspx";
    url=url+"?rid="+ReservationID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedBlocked;
    xmlHttp.open("GET",url,false);
    xmlHttp.send(null);
    if ( xmlHttp.responseText == "" )
        return true
    else
        return false;
}

function stateChangedBlocked()
{
    if (xmlHttp.readyState==4)
    { 
       ReturnBlocked(xmlHttp.responseText);
    }
}
function ReturnBlocked(response)
{
    if ( response != "" )
    {
        var divb = document.getElementById(blocked);
        if ( null != divb )
        {
            var divText = document.getElementById(tdiv);
            if ( null != divText )
            {
                divText.innerHTML = response;
                divb.style.display = "block";
                MoveMe();
                return false;
            }
        }
    }
    return true;
}

function GetCities3(CountryID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?cid="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged2;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function GetCitiesV(CountryID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?cid="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedV;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


//tours - start
function GetCitiesTours(CountryID)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?cid="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange = StateChangedTours;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function StateChangedTours()
{
    if (xmlHttp.readyState==4)
    { 
        FillCitiesTours(xmlHttp.responseText);
    }
}

function stateChanged()
{
    if (xmlHttp.readyState==4)
    { 
        FillCities2(xmlHttp.responseText);
    }
}

function stateChanged2()
{
    if (xmlHttp.readyState==4)
    { 
        FillCities3(xmlHttp.responseText);
    }
}


function FillCitiesTours(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlCity");
    var _inHtml = '<select id="' + ddlIDTour + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValueTour2(this.value)">';
       
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    try
    {
        SetValueTour2(document.getElementById(ddlIDTour).options[0].value);
    }
    catch(err)
    {
        //alert(err);
    }
}

function SetValueTour2( value)
{
    
    inp = document.getElementById(hCityIdTour);
    inp.value = value;
}

//back
function GetCitiesTourBack(CountryID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?ttccd="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedToursBack;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChangedToursBack() 
{ 
    if (xmlHttp.readyState==4)
    { 
        FillCitiesToursBack(xmlHttp.responseText);
    }
}

function FillCitiesToursBack(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlCity");
    var _inHtml = '<select id="' + ddlIDTour + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValueTour2(this.value)">';
   
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    SelectCityTour();
}
//tours - end

//transfers - start
//pick up
function GetCitiesPickUp(CountryID, city)
{
    SelectCountry(ddlPickUpCountry, ddlDropOffCountry);
    c1 = document.getElementById(ddlPickUpCountry);
        
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?ttccd="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange = StateChangedPickUpCountry;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function StateChangedPickUpCountry()
{
    if (xmlHttp.readyState==4)
    { 
        FillCitiesPickUp(xmlHttp.responseText);
    }
}

function FillCitiesPickUp(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
//    debugger;
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlPickUpCity");
    var _inHtml = '<select id="' + ddlPickUpCity + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValuePickUpCity(this.value)">';
       
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    d = document.getElementById(ddlPickUpCity);
    d1 = document.getElementById(ddlPickUp);
    d.disabled = false;
    d1.disabled = false;
    c1 = document.getElementById(ddlPickUpCountry);
    d2 = document.getElementById(ddlDropOffCity);
   // if (d.value != d2.value)
        GetCitiesDropOff(c1.value, false);
    GetPickUpAirports(d2.value);
    if ( d != null && d.value != null )
        SetValuePickUpCity(d.value);
}

function SelectCountry(country1, country2)
{
    c1 = document.getElementById(country1);
    c2 = document.getElementById(country2);
    c2.selectedIndex = c1.selectedIndex;
    hid1 = document.getElementById(hPickUpCountry);
    hid2 = document.getElementById(hPickUpCountryText);
    hid3 = document.getElementById(hDropOffCountry);
    hid4 = document.getElementById(hDropOffCountryText);
    hid1.value = c1.value;
    hid3.value = c1.value;
    hid2.value = c1.options[c1.selectedIndex].text;
    hid4.value = c1.options[c1.selectedIndex].text;
}

function SetValuePickUpCity(value)
{
    c1 = document.getElementById(ddlPickUpCity);
    c2 = document.getElementById(ddlDropOffCity);
    c2.selectedIndex = c1.selectedIndex;
    c2.value = c1.value;
    hid1 = document.getElementById(hPickUpCity);
    hid2 = document.getElementById(hPickUpCityText);
    hid3 = document.getElementById(hPickUpCityCount);
    hid4 = document.getElementById(hDropOffCity);
    hid5 = document.getElementById(hDropOffCityText);
    hid6 = document.getElementById(hDropOffCityCount);
    hid1.value = c1.value;
    hid4.value = c1.value;
    hid2.value = c1.options[c1.selectedIndex].text;
    hid5.value = c1.options[c1.selectedIndex].text;
    hid3.value = c1.length;
    hid6.value = c1.length;
    c2.disabled = false;
    c3 = document.getElementById(ddlDropOff);
    c3.disabled = false;
    GetPickUpAirports(value);
}

//drop off
function GetCitiesDropOff(CountryID, city)
{
    SelectCountry(ddlDropOffCountry, ddlPickUpCountry);
    c1 = document.getElementById(ddlPickUpCountry);
   
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?ttccd="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange = StateChangedDropOffCountry;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function StateChangedDropOffCountry()
{
    if (xmlHttp.readyState==4)
    { 
        FillCitiesDropOff(xmlHttp.responseText);
    }
}

function FillCitiesDropOff(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlDropOffCity");
    var _inHtml = '<select id="' + ddlDropOffCity + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValueDropOffCity(this.value)">';
       
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    d = document.getElementById(ddlDropOffCity);
    d1 = document.getElementById(ddlDropOff);
    d.disabled = false;
    d1.disabled = false;
    c1 = document.getElementById(ddlPickUpCountry);
    d2 = document.getElementById(ddlPickUpCity);
    if (d.value != d2.value)
        GetCitiesPickUp(c1.value, false);
    GetDropOffAirports(d2.value);
}

function SetValueDropOffCity(value)
{
    c2 = document.getElementById(ddlDropOffCity);
    hid4 = document.getElementById(hDropOffCity);
    hid5 = document.getElementById(hDropOffCityText);
    hid6 = document.getElementById(hDropOffCityCount);
    hid4.value = c2.value;
    hid5.value = c2.options[c2.selectedIndex].text;
    hid6.value = c2.length;
    c2.disabled = false;
    c3 = document.getElementById(ddlDropOff);
    c3.disabled = false;
    GetDropOffAirports(value);
}

//airports
function SetVisibleAirport(cod, ddlAirport, lblAirport)
{
    airport = document.getElementById(ddlAirport);
    lbl = document.getElementById(lblAirport);
    if (cod == "A")
    {
        //airport.disabled = false;
        airport.style.display = 'block';
        //airport.style.visibility = 'visible';
        if (airport.length == 0)
            airport.disabled = true;
        else airport.disabled = false;
        lbl.style.display = 'block';        
        //lbl.style.visibility = 'visible';
    }
    else
    {
        //airport.disabled = true;
        airport.style.display = 'none';
        //airport.style.visibility = 'hidden';
        lbl.style.display = 'none';        
        //lbl.style.visibility = 'hidden';
    }
}

function GetPickUpAirports(CityID)
{
    
    airp = document.getElementById(ddlPickUpAirport);
    for (j = airp.length - 1; j >= 0; j--)
    {
        airp.remove(j);
    }
    SetValuePickUpAirport("");
    xmlHttpA=GetXmlHttpObject();
    if (xmlHttpA==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?air="+CityID;
    url=url+"&sid="+Math.random();
    xmlHttpA.onreadystatechange = StateChangedPickUpAirport;
    xmlHttpA.open("GET",url,true);
    xmlHttpA.send(null);   
}

function StateChangedPickUpAirport()
{
    if (xmlHttpA.readyState==4)
    { 
        FillPickUpAirports(xmlHttpA.responseText);
    }
}

function FillPickUpAirports(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXXX_ROOT_XXXXXX>', '');
    strXML = strXML.replace('</XXXXXX_ROOT_XXXXXX>', '');
    
    var div = document.getElementById(divDdlPickUpAirport);
    //var _inHtml = '<select id="' + ddlPickUpAirport + '" style="width:200px;visibility:hidden" class="ddl" onchange="SetValuePickUpAirport(this.value)">';
    var _inHtml = '<select id="' + ddlPickUpAirport + '" style="width:200px;display:none" class="ddl general_combos" onchange="SetValuePickUpAirport(this.value)">';
    
    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    d = document.getElementById(ddlPickUpAirport);
    if (d.length > 0)
        d.disabled = false;
    else
        d.disabled = true;
    d1 = document.getElementById(ddlPickUp);
    if (d1.value == "A")
        //d.style.visibility = 'visible';
        d.style.display = 'block';
        
    c1 = document.getElementById(ddlPickUpCity);
    c2 = document.getElementById(ddlDropOffCity);
    d2 = document.getElementById(ddlDropOffAirport);
    if (c1.value == c2.value)
        if (d.length == 0)
        {
            for (j = d2.length - 1; j >= 0; j--)
            {
                d2.remove(j);
            }
            d2.disabled = true;
        }
        else if (d2.length == 0 || d.options[0].value != d2.options[0].value)
            GetDropOffAirports(c1.value);
            
    SetValuePickUpAirport(null);
}

function SetValuePickUpAirport(value)
{    
    c2 = document.getElementById(ddlPickUpAirport);
    hid4 = document.getElementById(hPickUpAirport);
    hid5 = document.getElementById(hPickUpAirportText);
    hid6 = document.getElementById(hPickUpAirportCount);
    hid4.value = c2.value;
    if(c2.length > 0)
        hid5.value = c2.options[c2.selectedIndex].text;
    hid6.value = c2.length;
    c2.disabled = false;
}

function GetDropOffAirports(CityID)
{
    airp = document.getElementById(ddlDropOffAirport);
    for (j = airp.length - 1; j >= 0; j--)
    {
        airp.remove(j);
    }
    SetValueDropOffAirport("");
    xmlHttpA=GetXmlHttpObject();
    if (xmlHttpA==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?air="+CityID;
    url=url+"&sid="+Math.random();
    xmlHttpA.onreadystatechange = StateChangedDropOffAirport;
    xmlHttpA.open("GET",url,true);
    xmlHttpA.send(null);   
}

function StateChangedDropOffAirport()
{
    if (xmlHttpA.readyState==4)
    { 
        FillDropOffAirports(xmlHttpA.responseText);
    }
}

function FillDropOffAirports(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXXX_ROOT_XXXXXX>', '');
    strXML = strXML.replace('</XXXXXX_ROOT_XXXXXX>', '');
    
    var div = document.getElementById(divDdlDropOffAirport);
    //var _inHtml = '<select id="' + ddlDropOffAirport + '" style="width:200px;visibility:hidden" class="ddl" onchange="SetValueDropOffAirport(this.value)">';
    var _inHtml = '<select id="' + ddlDropOffAirport + '" style="width:200px;display:none" class="ddl general_combos" onchange="SetValueDropOffAirport(this.value)">';
    
    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    d = document.getElementById(ddlDropOffAirport);
    if (d.length > 0)
        d.disabled = false;
    else
        d.disabled = true;
    d1 = document.getElementById(ddlDropOff);
    if (d1.value == "A")
        //d.style.visibility = 'visible';
        d.style.display = 'block';
        
    c1 = document.getElementById(ddlPickUpCity);
    c2 = document.getElementById(ddlDropOffCity);
    d2 = document.getElementById(ddlPickUpAirport);
    
    if (c1.value == c2.value)
        if (d2.length == 0)
        {
            for (j = d.length - 1; j >= 0; j--)
            {
                d.remove(j);
            }
            d.disabled = true;
        }
        else if (d.length == 0 || d.options[0].value != d2.options[0].value)
            GetPickUpAirports(c1.value);
    SetValueDropOffAirport(null);
}

function SetValueDropOffAirport(value)
{
    c2 = document.getElementById(ddlDropOffAirport);
    hid4 = document.getElementById(hDropOffAirport);
    hid5 = document.getElementById(hDropOffAirportText);
    hid6 = document.getElementById(hDropOffAirportCount);
    hid4.value = c2.value;
    if(c2.length > 0)
        hid5.value = c2.options[c2.selectedIndex].text;
    hid6.value = c2.length;
    c2.disabled = false;
    c2.display = 'block';
}

//back

function GetCitiesTransferBack(CountryID)
{ 
    if (CountryID != null)
    {
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("Your browser does not support AJAX!");
            return;
        } 
        var url="../../../test/AJAX.aspx";
        url=url+"?ttccd="+CountryID;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=stateChangedTransfersBack;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}

function stateChangedTransfersBack() 
{ 
    if (xmlHttp.readyState==4)
    { 
        FillCitiesTransfersBack(xmlHttp.responseText);
    }
}

function FillCitiesTransfersBack(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlPickUpCity");
    var _inHtml = '<select id="' + ddlPickUpCity + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValuePickUpCity(this.value)">';
       
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    
    GetDropOffBack(document.getElementById(ddlDropOffCountry).value);
}

var xmlHttpAux
function GetDropOffBack(CountryID)
{ 
    xmlHttpAux=GetXmlHttpObject();
    if (xmlHttpAux==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?ttccd="+CountryID;
    url=url+"&sid="+Math.random();
    xmlHttpAux.onreadystatechange=stateChangedDropOffBack;
    xmlHttpAux.open("GET",url,true);
    xmlHttpAux.send(null);
}

function stateChangedDropOffBack() 
{ 
    if (xmlHttpAux.readyState==4)
    { 
        FillCitiesDropOffBack(xmlHttpAux.responseText);
    }
}

function FillCitiesDropOffBack(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlDropOffCity");
    var _inHtml = '<select id="' + ddlDropOffCity + '" style="width:200px;" class="ddl capital general_combos" onchange="SetValueDropOffCity(this.value)">';
       
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    
    SelectTransferDetails();
}

function GetBackPickUpAirports(CityID)
{
    airp = document.getElementById(ddlPickUpAirport);
    for (j = airp.length - 1; j >= 0; j--)
    {
        airp.remove(j);
    }
    //SetValuePickUpAirport("");    
    
    xmlHttpA=GetXmlHttpObject();
    if (xmlHttpA==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?air="+CityID;
    url=url+"&sid="+Math.random();
    xmlHttpA.onreadystatechange = StateChangedPickUpAirportBack;
    xmlHttpA.open("GET",url,true);
    xmlHttpA.send(null);   
}

function StateChangedPickUpAirportBack()
{
    if (xmlHttpA.readyState==4)
    { 
        FillPickUpAirportsBack(xmlHttpA.responseText);
    }
}

function FillPickUpAirportsBack(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXXX_ROOT_XXXXXX>', '');
    strXML = strXML.replace('</XXXXXX_ROOT_XXXXXX>', '');
    
    var div = document.getElementById(divDdlPickUpAirport);
    //var _inHtml = '<select id="' + ddlPickUpAirport + '" style="width:200px;visibility:hidden" class="ddl" onchange="SetValuePickUpAirport(this.value)">';
    var _inHtml = '<select id="' + ddlPickUpAirport + '" style="width:200px;display:none" class="ddl" onchange="SetValuePickUpAirport(this.value)">';
    
    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    var xp = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlPickUp");
    var pickUpAirport = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_hidPickUpAirport").value;
    var x2 = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlPickUpAirport");
        
        
   //alert('inainte de pickUp');
        if (xp.value == "A")
        {
            //alert(x2.id);
            x2.style.display = 'block';
            var xpl = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_lblPickUp")
            xpl.style.display = 'block';
            x2.disabled = xp.disabled;
        }
        
        for(var i=0;i<x2.options.length;i++) 
        {
            if( x2.options[i].value == pickUpAirport )
            {
                x2.options[i].selected=true;
            }
        }
}

function SelectTransferDetails()
    {
        var xx = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlPickUpAirport");
        var pickUpCityID = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_hidPickUpCity").value;
        var x1 = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlPickUpCity");
        for(var i=0;i<x1.options.length;i++) 
        {
            if( x1.options[i].value == pickUpCityID )
            {
                x1.options[i].selected=true;
                break;
            }
        }
        if (pickUpCityID == "")
            x1.disabled = true;
        else
            x1.disabled = false;
                
        var dropOffCityID = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_hidDropOffCity").value;
        var x3 = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlDropOffCity");
        for(var i=0;i<x3.options.length;i++) 
        {
            if( x3.options[i].value == dropOffCityID )
            {
                x3.options[i].selected=true;
                break;
            }
        }
        if (dropOffCityID == "")
            x3.disabled = true;
        else
            x3.disabled = false;
            
        var xp = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlPickUp");
        xp.disabled = x1.disabled;
        var xd = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlDropOff");
        xd.disabled = x3.disabled;
        
        GetBackPickUpAirports(pickUpCityID);
        GetBackDropOffAirports(dropOffCityID);
        
        
        
    }

var xmlHttpD
function GetBackDropOffAirports(CityID)
{
    airp = document.getElementById(ddlDropOffAirport);
    for (j = airp.length - 1; j >= 0; j--)
    {
        airp.remove(j);
    }
    //SetValueDropOffAirport("");
    xmlHttpD=GetXmlHttpObject();
    if (xmlHttpD==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?air="+CityID;
    url=url+"&sid="+Math.random();
    xmlHttpD.onreadystatechange = StateChangedDropOffAirportBack;
    xmlHttpD.open("GET",url,true);
    xmlHttpD.send(null);   
}

function StateChangedDropOffAirportBack()
{
    if (xmlHttpD.readyState==4)
    { 
        FillDropOffAirportsBack(xmlHttpD.responseText);
    }
}

function FillDropOffAirportsBack(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    
    var strXML = xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXXX_ROOT_XXXXXX>', '');
    strXML = strXML.replace('</XXXXXX_ROOT_XXXXXX>', '');
    
    var div = document.getElementById(divDdlDropOffAirport);
    //var _inHtml = '<select id="' + ddlDropOffAirport + '" style="width:200px;visibility:hidden" class="ddl" onchange="SetValueDropOffAirport(this.value)">';
    var _inHtml = '<select id="' + ddlDropOffAirport + '" style="width:200px;display:none" class="ddl" onchange="SetValueDropOffAirport(this.value)">';
    
    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    
    var xd = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlDropOff");
    var dropOffAirport = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_hidDropOffAirport").value;
    var x4 = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_ddlDropOffAirport");
        
        
        //alert('inainte de dropOff');
        //alert(xp.value);
        if (xd.value == "A")
        {
            //alert(xp.value);
            x4.style.display = 'block';
            var xdl = document.getElementById("ctl00_ContentPlaceHolder2_ucTransfersSearch_lblDropOff")
            xdl.style.display = 'block';
            x4.disabled = xd.disabled;
        }
        
        for(var i=0;i<x4.options.length;i++) 
        {
            if( x4.options[i].value == dropOffAirport )
            {
                x4.options[i].selected=true;
            }
        }
 }
//transfers - end



function FillCities2(response)
{
//    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//    xmlDoc.async="false";
//    xmlDoc.loadXML(response);
    var strXML = response;//xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlCity");
    
    var _inHtml = '<select id="' + ddlID + '" style="width:200px;" class="ddl capital" onchange="SetValue2(this.value)">';
    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    SetValue2(document.getElementById(ddlID).options[0].value);
}

function FillCities3(response)
{
//    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//    xmlDoc.async="false";
//    xmlDoc.loadXML(response);
    var strXML = response;// xmlDoc.documentElement.xml;
    strXML = strXML.replace('<XXXXX_ROOT_XXXXX>', '');
    strXML = strXML.replace('</XXXXX_ROOT_XXXXX>', '');
    
    var div = document.getElementById("DivDdlCity");
    var _inHtml = '<select id="' + ddlID + '" style="width:200px;" class="ddl capital" onchange="SetValue2(this.value)">';
   
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
//    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//    xmlDoc.async="false";
//    xmlDoc.loadXML(response);
//    var x = xmlDoc.documentElement;
//    var counter = x.childNodes.length;
//    var ddl = document.getElementById("ctl00_ContentPlaceHolder2_ucHotelSearch_ddlCities");
//    ddl.options.length = 0;
//    for ( i = 0; i < counter ; i++)
//    {
//        var value = x.childNodes[i].attributes[0].nodeValue;
//        var text = x.childNodes[i].attributes[1].nodeValue
//        ddl.options.add(new Option(text,value));
//    }
//    if (counter == 0) { ddl.disabled = true; }
//    else { ddl.disabled = false; }
    SelectCity();
}
function AgesOK()
{
    var x;
    for ( x in agesArray )
    {
        var age = document.getElementById(agesArray[x]);
        if ( null != age )
        {
           if ( age.style.display == "block" )
           {
                if ( age.selectedIndex == 0 )
                {
                    Clip(age);
                    return false;
                } 
           }
        }
    } 
    return true;
}

function Clip(ageddl)
{
    var color = ageddl.style.backgroundColor;
    ageddl.style.backgroundColor = "#ff0000";
    var todo = "document.getElementById('" + ageddl.id + "').style.backgroundColor = '" + color + "'";
    setTimeout(todo, 500);
}

function ShowPleaseWait(img, city, checkin, first, second, third)
{
//    debugger;
    
    var country = document.getElementById(city);
    var checkin = document.getElementById(checkin);
    var first   = document.getElementById(first);
    var second  = document.getElementById(second);
    var third   = document.getElementById(third);
    
    var valid = true;
    valid = AgesOK();
    if ( country.value == "" || country.value == undefined  )
    {
        valid = false;
//        bCityCountry.style.visibility = "visible"; 
        bMandFieldsControl.style.display = "block";
    }
    else 
    {
//        bCityCountry.style.visibility = "hidden"; 
        bMandFieldsControl.style.display = "none";
    }
    if ( checkin.value == "" )
    {
        valid = false;
        bDateControl.style.display = "block";
        bMandFieldsControl.style.display = "block";
    }
    else 
    {
        bDateControl.style.display = "none";
        bMandFieldsControl.style.display = "none";
    }
    if ( first.selectedIndex == 0 && second.selectedIndex == 0 && third.selectedIndex == 0 )
    {
    valid = false;
    bRoomControl.style.display = "block";
    bMandFieldsControl.style.display = "block";

    }
    else
    {
        bRoomControl.style.display = "none";
        bMandFieldsControl.style.display = "none";
    }
    
    if ( valid )
    {
        var img = document.getElementById(img);
        img.style.display = "block";
        
//        debugger;
        w2cs(img);
        
        document.getElementById('bimg').className = "fade";
//            alert("scrollHeight " + document.body.scrollHeight);
//            alert("scrollWidth " + document.body.scrollWidth);

//        debugger;
        
        hideResults();
        
        document.getElementById('bimg').style.height = document.body.scrollHeight + "px";
        document.getElementById('bimg').style.width = document.body.scrollWidth + "px";
        
        
        return true;
    }
    else
    {
        return false;
    }
}    
function hideResults()
{
    var srt = document.getElementById('searchResultsTableXXX');
    
    if ( srt != null )
    {
        srt.style.display = "none";
    }
}

function w2cs(div) {

//    debugger;
//    $(window).height();
    
    var divW = $(div).width();
    var divH = $(div).height();
    
    var wndH = $(window).height();
    var wndW = $(window).width();
    
    
    div.style.top   = ( wndH / 2 ) - ( divH / 2 ) + 'px';
    div.style.left  = ( wndW / 2 ) - ( divW / 2 ) + 'px';
//    var wndH = wnd.offsetHeight;
//    var wndW = wnd.offsetWidth;

    div.style.position = "absolute";

//    if (window.innerHeight != null) {
//        pageH = window.innerHeight;
//        pageW = window.innerWidth;
//    }
//    else if (document.documentElement.clientHeight != null) {
//        pageH = document.documentElement.clientHeight;
//        pageW = document.documentElement.clientWidth;
//    }
//    else if (document.body.clientHeight != null) {
//        pageH = document.body.clientHeight;
//        pageW = document.body.clientWidth;
//    }

//    if (pageH == 0 && pageW == 0) {
//        pageH = document.body.clientHeight;
//        pageW = document.body.clientWidth;
//    }
    //alert(document.body.scrollTop);
//    if (wndH > pageH) {
//        wnd.style.top = document.body.scrollTop + "px";
//    }
//    else {
//        wnd.style.top = ((pageH - wndH) / 2) +document.body.scrollTop + "px";
//    }
//    wnd.style.left = (pageW - wndW) / 2 + "px";
}

function FillCitiesV(response)
{
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(response);
    var x = xmlDoc.documentElement;
    var counter = x.childNodes.length;
    var ddl = document.getElementById("ctl00_ContentPlaceHolder2_ddlCities");
    ddl.options.length = 0;
    for ( i = 0; i < counter ; i++)
    {
        var value = x.childNodes[i].attributes[0].nodeValue;
        var text = x.childNodes[i].attributes[1].nodeValue
        ddl.options.add(new Option(text,value));
        if ( i == 0 )
        {
            SetValueV('ctl00_ContentPlaceHolder2_iCity',value);
        }
    }
    if (counter == 0) { ddl.disabled = true; }
    else { ddl.disabled = false; }
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function SetValue2( value)
{
    
    inp = document.getElementById(hCityId);
    inp.value = value;
}

function SetValueV(iCity, value)
{
    inp = document.getElementById(iCity);
    alert(iCity + " " + value);
    inp.value = value;
}

function SetValues(hid1, hid2, hid3, val1, val2, val3)
{
    h1 = document.getElementById(hid1);
    h2 = document.getElementById(hid2);
    h3 = document.getElementById(hid3);
    h1.value = val1;
    h2.value = val2;
    h3.value = val3;
}

function SetValuesA(source, hid1, hid2)
{
    s = document.getElementById(source);
    h1 = document.getElementById(hid1);
    h2 = document.getElementById(hid2);
    h1.value = s.value;
    h2.value = s.options[s.selectedIndex].text;
}
function GetPorts(DestinationID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?destid="+DestinationID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged4Ports;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function GetPortsWithSelect(DestinationID, selectedID)
{ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?destid="+DestinationID+"&selid="+selectedID;    
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged4Ports;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChanged4Ports()
{
    if (xmlHttp.readyState==4)
    { 
        FillPorts(xmlHttp.responseText);
    }
}

function FillPorts(response)
{
    var strXML = response;    
    var div = document.getElementById("divPort");    
    var _inHtml = '<select id="' + ddlPortsID + '" style="width:200px;" class="ddl" onchange="SetPortValue(this.value)">';    
    _inHtml += strXML;
    _inHtml += "</select>";
    div.innerHTML = _inHtml;
    SetPortValue(document.getElementById(ddlPortsID).options[0].value);
}

function DiscountsCheckedChanged(checked, divDiscountSeniorID, discountSeniorID, discountResidentID, divResidentAreasDivID)
{ 
    var div = document.getElementById(divDiscountSeniorID);
    var discSenior = document.getElementById(discountSeniorID);
    var discResident = document.getElementById(discountResidentID);
    var divAreas = document.getElementById(divResidentAreasDivID);
    if (div != null)
    {
        if (checked)   
        {     
            div.style.display  = 'inline';             
        }             
        else
        {
            div.style.display  = 'none';
            discSenior.checked = false;
            discResident.checked = false;
        }
        
        divAreas.style.display = 'none';
    }
}

function DiscountResidentCheckedChanged(checked, divResidentAreasDivID)
{
    var div = document.getElementById(divResidentAreasDivID);
    if (div != null)
    {
        if (checked)        
            div.style.display  = 'inline';              
        else
        {
            div.style.display  = 'none';
        }
    }
}

function SetPortValue(hidPort, value)
{    
    inp = document.getElementById(hidPort);
    inp.value = value;
}


//CHARTERS
function GetCharterSpecialConditions(ProviderID, departureDate, departureTime)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    var url="../../../test/AJAX.aspx";
    url=url+"?prvid="+ encodeURIComponent(ProviderID);
    url=url+"&depDate="+ encodeURIComponent(departureDate);
    url=url+"&depTime="+ encodeURIComponent(departureTime);
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedChartersGetSpecialConditions;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChangedChartersGetSpecialConditions() 
{ 
    if (xmlHttp.readyState==4)
    { 
        FillCharterCancelationPolicy(xmlHttp.responseText);
    }
}

function FillCharterCancelationPolicy(response)
{
    if (response != null && response != '')
    {
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async="false";
        xmlDoc.loadXML(response);
        
        var specialConditions = xmlDoc.getElementsByTagName("SpecialConditions")[0].nodeTypedValue;
        var lastRow = xmlDoc.getElementsByTagName("SpecialConditionsLastRow")[0].nodeTypedValue;
        var optionDate = xmlDoc.getElementsByTagName("OptionDate")[0].nodeTypedValue;
        var providerOptionDate = xmlDoc.getElementsByTagName("ProviderOptionDate")[0].nodeTypedValue;
        
        var lblCancellationPolLastRow = document.getElementById(lblCancellationPolicyLastRow);
        var lblSpecialCond = document.getElementById(lblSpecialConditions);
        var lblProvOptionDate = document.getElementById(lblProviderOptionDate); 
        var lblOptionDate = document.getElementById(lblOptionDateText);
        
        lblCancellationPolLastRow.innerHTML = lastRow;
        lblSpecialCond.innerHTML = specialConditions;
        lblProvOptionDate.value = providerOptionDate;
        lblOptionDate.innerHTML = optionDate;
    }
    else
    {
        var divPol = document.getElementById(divCP);
        divPol.style.display = 'none';
    }
}

function TogleShowHide(divId, linkShowId, linkHideId)
{
    divShow = document.getElementById(divId);
    linkShow = document.getElementById(linkShowId);
    linkHide = document.getElementById(linkHideId);
    
    if (divShow.style.display == "none")
    {
        divShow.style.display = "block";
        linkShow.style.display = "none";
        linkHide.style.display = "block";
    }
    else
    {
        divShow.style.display = "none";
        linkShow.style.display = "block";
        linkHide.style.display = "none";
    }
}

function ChangeStyle() 
{
    var tbl = document.getElementById("x"); if (tbl != null) tbl.cssClass = "";
}
