

//id is a #
//class is a .


function MM_jumpMenu(targ, selObj, restore) { //v3.0
    eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
    if (restore) selObj.selectedIndex = 0;
}

function MapAreaDisplay(r) {

    $(".MapText").hide();
    $("#MapText" + r).show();

}

function popUp2(URL) {
    window.open(URL, 'CallBack', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=755,height=610,left = 240,top = 240');
}

function popUp(URL) {
    window.open(URL, 'CallBack', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=645,height=440,left = 240,top = 240');
}


function alertLinkPackageSearch() {

    if (document.getElementById('datepicker') != null) {

        var currentTime = new Date()
        var month = currentTime.getMonth()
        var day = currentTime.getDate() + 5
        var year = currentTime.getFullYear()

        var mytoday = new Date();
        mytoday.setFullYear(year, month, day);


        var userDate = new Date();
        userDate.setFullYear(document.getElementById('datepicker').value.substr(6, 4), document.getElementById('datepicker').value.substr(3, 2) - 1, document.getElementById('datepicker').value.substr(0, 2));

        if (userDate < mytoday) {

            alert('Please select a departure date 5 days inadvance.');

            return false;
        }


    }

}

function alertLinkSearchBox() {


   

    if (document.getElementById('ddlCityTo') != null) {

        if (document.getElementById('ddlCityTo').value == "") {
            // \n 
            alert('Please select a holiday destination.');

            return false;
        }
    }


  


    if (document.getElementById('datepicker') != null) {

        if (document.getElementById('datepicker').value == "") {

            alert('Please select a departure date.');

            return false;
        }
    }
    //  }

}

function alertLinkDateBox() {
    if (document.getElementById('datepicker') != null) {

        if (document.getElementById('datepicker').value == "") {

            alert('Please select a departure date.');

            return false;
        }
    }
}
function SetNewPriceHotel(ValueString) {
    var ValueString;
    var PriceArray = ValueString.split('*');
    var NewPrice = PriceArray[1];
    var NewPricePP = PriceArray[3];

    //1:2:0:0:DBT-TH1:ST*1077.42*BB*75.65
    document.getElementById('ctl00_ContentPlaceHolder1_Room_TotalPrice1').innerHTML = NewPrice;
    document.getElementById('ctl00_ContentPlaceHolder1_Room_TotalPrice2').innerHTML = NewPrice;
    document.getElementById('ctl00_ContentPlaceHolder1_Room_TotalPrice3').innerHTML = NewPricePP;
}

function DisableDays(date) {
    // var noDisable = $.datepicker.DisableDays(date);
    // return [false, 'CLOSED'];

    var test1 = date.getDate();


    return [true, ''];
}


$(function () {



    $('#datepicker').datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        showOn: 'button',
        buttonImage: '/media/JQuery/UI/calendar.gif',
        buttonText: 'Please select a travel date',
        buttonImageOnly: true,
        duration: 'fast',
        dateFormat: "dd/mm/yy",
        beforeShowDay: DisableDays,

        minDate: 0

    });


    $('#datepicker').click(function () {
        $('#datepicker').datepicker('show');
    });


});


//ADD by waq

function DisableDays2(date) {
    // var noDisable = $.datepicker.DisableDays(date);
    // return [false, 'CLOSED'];
    var date = '16/12/2010';
    return [true, date];
}

function setDatePicker() {
    if (document.getElementById('datepicker1').value == '') {
        document.getElementById('datepicker1').value = document.getElementById('datepicker01').value;
        document.getElementById('datepicker1').style.color = '#FFFFFF';
    }
}
function setDatePicker2() {
    document.getElementById('datepicker1').style.color = '#000000';
}

var date = new Date();
var m = date.getMonth(), d = date.getDate() + 5, y = date.getFullYear();
var m2 = date.getMonth(), d2 = date.getDate() + 6, y2 = date.getFullYear();

$(
    function () {
        $('#datepicker01').datepicker({

            numberOfMonths: 2,
            showButtonPanel: true,
            showOn: 'button',
            buttonImage: 'http://www.bestattravel.co.uk/media/JQuery/UI/calendar.gif',
            buttonText: 'Please select a travel date',
            buttonImageOnly: true,
            duration: 'fast',
            dateFormat: "dd/mm/yy",
            beforeShowDay: DisableDays,
            onSelect: function () { setDatePicker(); },
            minDate: new Date(y, m, d)
        });
    });

$(

    function () {

        $('#datepicker1').datepicker({

            numberOfMonths: 2,
            showButtonPanel: true,
            showOn: 'button',
            buttonImage: 'http://www.bestattravel.co.uk/media/JQuery/UI/calendar.gif',
            buttonText: 'Please select a travel date',
            buttonImageOnly: true,
            duration: 'fast',
            dateFormat: "dd/mm/yy",
            beforeShowDay: DisableDays,
            minDate: new Date(y2, m2, d2),
            onSelect: function () { setDatePicker2(); }

        });

    });
//End ADD by waq

function ChangeRooms() {
    switch ($("#cboRooms option:selected").text()) {

        case "1":
            $('#BSRT-Room2-positioner').hide();

            $('#Room2_Child_Group').hide();
            $('#cboChild1_2_Group').hide();
            $('#cboChild2_2_Group').hide();
            $('#cboChild3_2_Group').hide();


            $('#BSRT-Room3-positioner').hide();

            $('#Room3_Child_Group').hide();
            $('#cboChild1_3_Group').hide();
            $('#cboChild2_3_Group').hide();
            $('#cboChild3_3_Group').hide();

            break;

        case "2":
            $('#BSRT-Room2-positioner').show();
            $('#BSRT-Room3-positioner').hide();

            $('#Room3_Child_Group').hide();
            $('#cboChild1_3_Group').hide();
            $('#cboChild2_3_Group').hide();
            $('#cboChild3_3_Group').hide();

            break;
        case "3":
            $('#BSRT-Room2-positioner').show();
            $('#BSRT-Room3-positioner').show();
            break;

    }
}


$("#cboRooms").change(function () {
    ChangeRooms();
})


$("#cboChild1").change(function () {

    ChangeChild1();

})

function ChangeChild1() {

    switch ($("#cboChild1 option:selected").text()) {
        case "0":
            $('#Room1_Child_Group').hide();
            $('#cboChild1_1_Group').hide();
            $('#cboChild2_1_Group').hide();
            $('#cboChild3_1_Group').hide();
            break;

        case "1":
            $('#Room1_Child_Group').show();
            $('#cboChild1_1_Group').show();
            $('#cboChild2_1_Group').hide();
            $('#cboChild3_1_Group').hide();
            break;
        case "2":
            $('#Room1_Child_Group').show();
            $('#cboChild1_1_Group').show();
            $('#cboChild2_1_Group').show();
            $('#cboChild3_1_Group').hide();
            break;
        case "3":
            $('#Room1_Child_Group').show();
            $('#cboChild1_1_Group').show();
            $('#cboChild2_1_Group').show();
            $('#cboChild3_1_Group').show();
            break;

    }


}

$("#cboChild2").change(function () {
    ChangeChild2();
})


function ChangeChild2() {

    switch ($("#cboChild2 option:selected").text()) {
        case "0":
            $('#Room2_Child_Group').hide();
            $('#cboChild1_2_Group').hide();
            $('#cboChild2_2_Group').hide();
            $('#cboChild3_2_Group').hide();
            break;

        case "1":
            $('#Room2_Child_Group').show();
            $('#cboChild1_2_Group').show();
            $('#cboChild2_2_Group').hide();
            $('#cboChild3_2_Group').hide();
            break;
        case "2":
            $('#Room2_Child_Group').show();
            $('#cboChild1_2_Group').show();
            $('#cboChild2_2_Group').show();
            $('#cboChild3_2_Group').hide();
            break;
        case "3":
            $('#Room2_Child_Group').show();
            $('#cboChild1_2_Group').show();
            $('#cboChild2_2_Group').show();
            $('#cboChild3_2_Group').show();
            break;

    }

}

$("#cboChild3").change(function () {
    ChangeChild3();
})

function ChangeChild3() {

    switch ($("#cboChild3 option:selected").text()) {
        case "0":
            $('#Room3_Child_Group').hide();
            $('#cboChild1_3_Group').hide();
            $('#cboChild2_3_Group').hide();
            $('#cboChild3_3_Group').hide();
            break;

        case "1":
            $('#Room3_Child_Group').show();
            $('#cboChild1_3_Group').show();
            $('#cboChild2_3_Group').hide();
            $('#cboChild3_3_Group').hide();
            break;
        case "2":
            $('#Room3_Child_Group').show();
            $('#cboChild1_3_Group').show();
            $('#cboChild2_3_Group').show();
            $('#cboChild3_3_Group').hide();
            break;
        case "3":
            $('#Room3_Child_Group').show();
            $('#cboChild1_3_Group').show();
            $('#cboChild2_3_Group').show();
            $('#cboChild3_3_Group').show();
            break;

    }

}

// $("#cboAdults1").change(function() {
//      alert('Handler for ' + $("#cboAdults1 option:selected").text() + ' called.');
//})
function checkInOutOptions(jtype) {
    var outbound = document.getElementsByName('SelectOutbound');
    var inbound = document.getElementsByName('SelectInbound');
    var jtype;

    var ocnt = 0;
    var incnt = 0;

    for (var i = 0; i < outbound.length; i++) {
        if (outbound[i].checked) {
            ocnt = 1;
        }
    }

    if (jtype == 'ONEWAY' && ocnt > 0) {
        return true;
    }

    for (var i = 0; i < inbound.length; i++) {
        if (inbound[i].checked) {
            incnt = 1;
        }
    }

    if (ocnt == 0 || incnt == 0) {
        return false;
    }
    return true;

}
function checkInboundOptions(inprice) {
    var outbound = document.getElementsByName('SelectOutbound');
    var outprice;
    var inprice;
    for (var i = 0; i < outbound.length; i++) {
        if (outbound[i].checked) {
            outprice = outbound[i].value;
            outprice = outprice.split("_");
            outprice = outprice[2];

            if (outprice != inprice) {
                outbound[i].checked = false;
            }
        }
    }
}
function checkOutboundOptions(outprice) {
    var inbound = document.getElementsByName('SelectInbound');
    var outprice;
    var inprice;

    for (var i = 0; i < inbound.length; i++) {
        if (inbound[i].checked) {
            inprice = inbound[i].value;
            inprice = inprice.split("_");
            inprice = inprice[2];

            if (outprice != inprice) {
                inbound[i].checked = false;
            }
        }
    }

}
function chooseCheapest(airlinename) {

    var SortAirline = airlinename;
    pathArray = window.location.href.split('?');
    var newPathname = pathArray[pathArray.length - 1];
    newPathname = newPathname.replace('SortAirlineCheapNav', 's' + airlinename);
    var url = newPathname + '&SortAirlineCheapNav=' + SortAirline;
    window.location.replace('?' + url);
    //alert(url);

}

