﻿
var destination = new Array();
destination[0] = ["Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Stansted Airport|Stansted (London)"];
destination[1] = ["Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[2] = ["Your address|A chosen address", "City Airport|City (London)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[3] = ["Your address|A chosen address", "City Airport|City (London)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[4] = ["Your address|A chosen address", "City Airport|City (London)", "Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[5] = ["Your address|A chosen address", "City Airport|City (London)", "Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[6] = ["Your address|A chosen address", "City Airport|City (London)", "Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[7] = ["Your address|A chosen address", "City Airport|City (London)", "Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Luton Airport|Luton (London)", "Stansted Airport|Stansted (London)"];
destination[8] = ["City Airport|City (London)", "Gatwick Airport - South Terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Stansted Airport|Stansted (London)"];
destination[9] = ["Your address|A chosen address", "City Airport|City (London)", "Gatwick Airport - South terminal|Gatwick (South Terminal)", "Gatwick Airport - North Terminal|Gatwick (North Terminal)", "Heathrow Airport - Terminal 1|Heathrow (Terminal 1)", "Heathrow Airport - Terminal 3|Heathrow (Terminal 3)", "Heathrow Airport - Terminal 4|Heathrow (Terminal 4)", "Heathrow Airport - Terminal 5|Heathrow (Terminal 5)", "Luton Airport|Luton (London)"];

function checkCountry() {
    var cph = "ctl00_ContentPlaceHolder1_Sagepay_";
    if (gotId(cph + "ddl_sagepay_country")) {        
        var country = document.getElementById(cph + "ddl_sagepay_country");
        var index = country.selectedIndex;

        if (country.options[index].value == "US") {
            document.getElementById(cph + "sagepay_country_label").style.display = "none";
            document.getElementById(cph + "sagepay_country_input").style.display = "none";
            document.getElementById(cph + "sagepay_state_label").style.display = "block";
            document.getElementById(cph + "sagepay_state_input").style.display = "block";
        } else {
        document.getElementById(cph + "sagepay_country_label").style.display = "block";
        document.getElementById(cph + "sagepay_country_input").style.display = "block";
        document.getElementById(cph + "sagepay_state_label").style.display = "none";
        document.getElementById(cph + "sagepay_state_input").style.display = "none";
        }
    }
}

function checkHearAboutUs() {
    var cph = "ctl00_ContentPlaceHolder1_Sagepay_";
    if (gotId(cph + "ddl_sagepay_hear_about_us")) {
        var hearaboutus = document.getElementById(cph + "ddl_sagepay_hear_about_us");
        var index = hearaboutus.selectedIndex;

        if (hearaboutus.options[index].value == "Other") {
            document.getElementById(cph + "sagepay_hear_about_us_other_label").style.display = "block";
            document.getElementById(cph + "sagepay_hear_about_us_other_text").style.display = "block";
        } else {
        document.getElementById(cph + "sagepay_hear_about_us_other_label").style.display = "none";
        document.getElementById(cph + "sagepay_hear_about_us_other_text").style.display = "none";
        }
    }
}


function updateTransferToDDL() {
    // activated when a user selects an option from the FROM DDL
    // get a reference to the from and to ddl
    var ddlFromName = "ctl00_ContentPlaceHolder1_ProductTransfer_" + "ddl_transfer_from";
    var ddlToName = "ctl00_ContentPlaceHolder1_ProductTransfer_" + "ddl_arrival_to";
    var ddlToListId = "ctl00_ContentPlaceHolder1_ProductTransfer_" + "hidden_ddl_arrival_to_listId";
    
    var fromObj = document.getElementById(ddlFromName);
    var toObj = document.getElementById(ddlToName);
    
    // what has the user just selected in the FROM DDL
    var selIndex = fromObj.selectedIndex;
    var from = fromObj.options[selIndex].value;

    // what list are we going to load
    var listIdToLoad = selIndex;
    // what is the first item in that list set it to the default picked
    // alert('list to load=' + selIndex);
    saveSelectedToLocation(destination[listIdToLoad][0].split("|")[1]);
    
    
    // clear the drop down list entries
    toObj.options.length = 0;
    for (i = 0; i < destination[listIdToLoad].length; i++)
        toObj.options[toObj.options.length] = new Option(destination[listIdToLoad][i].split("|")[0], destination[listIdToLoad][i].split("|")[1])

    // store the list id
    // alert('sel list=' + selIndex);
    document.getElementById(ddlToListId).value = selIndex;
}

function saveSelectedToLocation(selectedValue) {
    // save the location chosen in stage 1 of the transfer form
    var ddlToListValue = "ctl00_ContentPlaceHolder1_ProductTransfer_" + "hidden_ddl_arrival_to_value";
    // alert('sel value=' + selectedValue);
    document.getElementById(ddlToListValue).value = selectedValue;
}

// checks if enter key pressed then submits the form
// usage onKeyPress="checkEnter(event)"
function checkEnter(e, buttonId) {
    // e is event object passed from function invocation
    // literal character code will be stored in this variable
    var characterCode;

    //if which property of event object is supported (NN4)
    if (e && e.which){
        e = e;
        //character code is contained in NN4's which property
        characterCode = e.which;
    }
    else {
        e = event;
        //character code is contained in IE's keyCode property
        characterCode = e.keyCode;
    }

    if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
        // document.forms["aspnetForm"].submit() //submit the form
        var aspButtonId = "" + buttonId;
        // alert('clicking button ' + document.getElementById(aspButtonId).text);
        document.getElementById(aspButtonId).click();
        return false 
    }
    else {
        return true 
    }
}


function clearDateTemplate(whichId) {
    // clear the date template
    if (document.getElementById(whichId).value == 'dd-mm-yyyy') document.getElementById(whichId).value = '';
}

function copyPostcode() {
    // copies the postcode from the outward journey to the return journey
    // from: transfer_postcode_out_pc_to_airport
    // to: transfer_postcode_return_airport_to_pc
    if (document.getElementById("ctl00_ContentPlaceHolder1_ProductTransfer_transfer_postcode_return_airport_to_pc").value == "") {
        document.getElementById("ctl00_ContentPlaceHolder1_ProductTransfer_transfer_postcode_return_airport_to_pc").value =
            document.getElementById("ctl00_ContentPlaceHolder1_ProductTransfer_transfer_postcode_out_pc_to_airport").value;
    }
}

function copyInputData(productPageFrom, inputFrom, productPageTo, inputTo) {
    // copies data on the product page from -> to provided it is blank
    var qualifiedFrom = "ctl00_ContentPlaceHolder1_" + productPageFrom + "_" + inputFrom;
    var qualifiedTo = "ctl00_ContentPlaceHolder1_" + productPageTo + "_" + inputTo;
    // check the ids exist
    if (gotId(qualifiedFrom) && gotId(qualifiedTo)) {
        if (document.getElementById(qualifiedTo).value == "") {
            document.getElementById(qualifiedTo).value = document.getElementById(qualifiedFrom).value;
        }
    } else {
        // alert('id not found from: ' + qualifiedFrom + ' to: ' + qualifiedTo);
    }
}

function copyInputDataCombo(productPageFrom, inputFrom, productPageTo, inputTo) {
    // copies data on the product page from -> to combo box
    var qualifiedFrom = "ctl00_ContentPlaceHolder1_" + productPageFrom + "_" + inputFrom;
    var qualifiedTo = "ctl00_ContentPlaceHolder1_" + productPageTo + "_" + inputTo;
    // check the ids exist
    if (gotId(qualifiedFrom) && gotId(qualifiedTo)) {
        document.getElementById(qualifiedTo).selectedIndex = document.getElementById(qualifiedFrom).selectedIndex;        
    } else {
        // alert('id not found from: ' + qualifiedFrom + ' to: ' + qualifiedTo);
    }
}
function copyInputDataCheckPostcode(productPageFrom, inputFrom, productPageTo, inputTo) {
    // copies data on the product page from -> to provided it is blank and that the postcodes are the same
    var qualifiedFrom = "ctl00_ContentPlaceHolder1_" + productPageFrom + "_" + inputFrom;
    var qualifiedTo = "ctl00_ContentPlaceHolder1_" + productPageTo + "_" + inputTo;

    // all the postcode fields
    var postcodeOutwardFrom = "ctl00_ContentPlaceHolder1_" + productPageFrom + "_" + "transfer_outward_postcode";
    var postcodeOutwardTo = "ctl00_ContentPlaceHolder1_" + productPageTo + "_" + "transfer_outward_dropoff_postcode";
    var postcodeReturnFrom = "ctl00_ContentPlaceHolder1_" + productPageFrom + "_" + "transfer_return_postcode";
    var postcodeReturnTo = "ctl00_ContentPlaceHolder1_" + productPageTo + "_" + "transfer_return_dropoff_postcode";

    // which ones exist
    var postcodeFrom = "";
    var postcodeTo = "";
    if (gotId(postcodeOutwardFrom)) postcodeFrom = postcodeOutwardFrom;
    if (gotId(postcodeOutwardTo)) postcodeFrom = postcodeOutwardTo;
    if (gotId(postcodeReturnFrom)) postcodeTo = postcodeReturnFrom;
    if (gotId(postcodeReturnTo)) postcodeTo = postcodeReturnTo;

    // check the ids exist
    if (gotId(qualifiedFrom) && gotId(qualifiedTo) && gotId(postcodeFrom) && gotId(postcodeTo)) {
        if (document.getElementById(postcodeFrom).innerHTML == document.getElementById(postcodeTo).innerHTML) {
            // alert('From: ' + document.getElementById(postcodeFrom).innerHTML + ' To: ' + document.getElementById(postcodeTo).innerHTML);
            if (document.getElementById(qualifiedTo).value == "") {
                document.getElementById(qualifiedTo).value = document.getElementById(qualifiedFrom).value;
            }
        } else {
            // alert('postcodes different');
        }
    } else {
        if (1 == 0) {
            if (!gotId(qualifiedFrom)) alert('id not found qualifiedFrom: ' + qualifiedFrom);
            if (!gotId(qualifiedTo)) alert('id not found qualifiedTo: ' + qualifiedTo);
            if (!gotId(postcodeFrom)) alert('id not found postcodeFrom: ' + postcodeFrom);
            if (!gotId(postcodeTo)) alert('id not found postcodeTo: ' + postcodeTo);
        }
    }
}

function clearBillingFields() {
    var prefix = "ctl00$ContentPlaceHolder1$Sagepay$";
    if (gotId(prefix + "sagepay_address1")) document.getElementById(prefix + "sagepay_address1").value = "";
    if (gotId(prefix + "sagepay_address2")) document.getElementById(prefix + "sagepay_address2").value = "";
    if (gotId(prefix + "sagepay_town")) document.getElementById(prefix + "sagepay_town").value = "";
    if (gotId(prefix + "sagepay_county")) document.getElementById(prefix + "sagepay_county").value = "";
    if (gotId(prefix + "sagepay_country")) document.getElementById(prefix + "sagepay_country").value = "";
    if (gotId(prefix + "sagepay_postcode")) document.getElementById(prefix + "sagepay_postcode").value = "";
}

function clearTransferOutwardFields() {
    var prefix = "ctl00_ContentPlaceHolder1_ProductTransfer_";
    if (gotId(prefix + "transfer_outward_address1")) document.getElementById(prefix + "transfer_outward_address1").value = "";
    if (gotId(prefix + "transfer_outward_address2")) document.getElementById(prefix + "transfer_outward_address2").value = "";
    if (gotId(prefix + "transfer_outward_town")) document.getElementById(prefix + "transfer_outward_town").value = "";
    if (gotId(prefix + "transfer_outward_county")) document.getElementById(prefix + "transfer_outward_county").value = "";
    if (gotId(prefix + "transfer_outward_country")) document.getElementById(prefix + "transfer_outward_country").value = "";
    if (gotId(prefix + "transfer_outward_postcode")) document.getElementById(prefix + "transfer_outward_postcode").value = "";
    
    if (gotId(prefix + "transfer_outward_dropoff_address1")) document.getElementById(prefix + "transfer_outward_dropoff_address1").value = "";
    if (gotId(prefix + "transfer_outward_dropoff_address2")) document.getElementById(prefix + "transfer_outward_dropoff_address2").value = "";
    if (gotId(prefix + "transfer_outward_dropoff_town")) document.getElementById(prefix + "transfer_outward_dropoff_town").value = "";
    if (gotId(prefix + "transfer_outward_dropoff_county")) document.getElementById(prefix + "transfer_outward_dropoff_county").value = "";
    if (gotId(prefix + "transfer_outward_dropoff_country")) document.getElementById(prefix + "transfer_outward_dropoff_country").value = "";
    if (gotId(prefix + "transfer_outward_dropoff_postcode")) document.getElementById(prefix + "transfer_outward_dropoff_postcode").value = "";
    // alert('cleared fields');
}

function clearTransferReturnFields() {
    var prefix = "ctl00_ContentPlaceHolder1_ProductTransfer_";
    if (gotId(prefix + "transfer_return_address1")) document.getElementById(prefix + "transfer_return_address1").value = "";
    if (gotId(prefix + "transfer_return_address2")) document.getElementById(prefix + "transfer_return_address2").value = "";
    if (gotId(prefix + "transfer_return_town")) document.getElementById(prefix + "transfer_return_town").value = "";
    if (gotId(prefix + "transfer_return_county")) document.getElementById(prefix + "transfer_return_county").value = "";
    if (gotId(prefix + "transfer_return_country")) document.getElementById(prefix + "transfer_return_country").value = "";
    if (gotId(prefix + "transfer_return_postcode")) document.getElementById(prefix + "transfer_return_postcode").value = "";

    if (gotId(prefix + "transfer_return_dropoff_address1")) document.getElementById(prefix + "transfer_return_dropoff_address1").value = "";
    if (gotId(prefix + "transfer_return_dropoff_address2")) document.getElementById(prefix + "transfer_return_dropoff_address2").value = "";
    if (gotId(prefix + "transfer_return_dropoff_town")) document.getElementById(prefix + "transfer_return_dropoff_town").value = "";
    if (gotId(prefix + "transfer_return_dropoff_county")) document.getElementById(prefix + "transfer_return_dropoff_county").value = "";
    if (gotId(prefix + "transfer_return_dropoff_country")) document.getElementById(prefix + "transfer_return_dropoff_country").value = "";
    if (gotId(prefix + "transfer_return_dropoff_postcode")) document.getElementById(prefix + "transfer_return_dropoff_postcode").value = "";
    // alert('cleared fields');
}

function close_iframe() {
    // hide the iframe
    document.getElementById("ctl00_ContentPlaceHolder1_sagepay_iframe_div").style.display = "none";
    // hide the sagepay div
    document.getElementById("ctl00_ContentPlaceHolder1_sagepay_div").style.display = "none";
    // show the product divs
    document.getElementById("ctl00_ContentPlaceHolder1_products_page_div").style.display = "block";
    // now tidy up the display
    document.getElementById("ctl00_ContentPlaceHolder1_empty_basket_and_tidyup").value = "YES";
    // check if we are in a test mode i.e. ?paymentno=nn
    var action = document.forms["aspnetForm"].action;
    if ((action.indexOf("paymentno=") > 0) && (action.indexOf("clear=yes") == 0)) {
        // action is made from the fully qualified domain and fixed at no1traveller but for testing we might need a local url
        document.forms["aspnetForm"].action = action + "&clear=yes";
    }
    // now submit this form
    document.forms["aspnetForm"].submit();
}

function pdq_iframe(doWhat) {
    // there can be 4 possible visible divs;
    // 1. products_page_div
    // 2. sagepay_iframe_div
    // 3. pdq_iframe_div
    // 4. sagepay_div
    //
    // Usually it is going to be the products_page_div or sagepay_div, but might be the sage iframe
    // store which one is visible then hide it and show this div then reverse on the hide
    if (doWhat == "HIDE") {
        // show what was previously being shown
        if (document.getElementById("ctl00_ContentPlaceHolder1_current_active_div_for_pdq").value == "SAGEPAYIFRAME") {
            document.getElementById("ctl00_ContentPlaceHolder1_sagepay_iframe_div").style.display = "block";
        } else if (document.getElementById("ctl00_ContentPlaceHolder1_current_active_div_for_pdq").value == "SAGEPAY") {
            document.getElementById("ctl00_ContentPlaceHolder1_sagepay_div").style.display = "block";
        } else {
            document.getElementById("ctl00_ContentPlaceHolder1_products_page_div").style.display = "block"
        }
        // hide the iframe
        document.getElementById("ctl00_ContentPlaceHolder1_pdq_iframe_div").style.display = "none";
    } else {
        // store the current active div in current_active_div_for_pdq
        if (document.getElementById("ctl00_ContentPlaceHolder1_sagepay_iframe_div").style.display == "block") {
            document.getElementById("ctl00_ContentPlaceHolder1_sagepay_iframe_div").style.display = "none";
            document.getElementById("ctl00_ContentPlaceHolder1_current_active_div_for_pdq").value = "SAGEPAYIFRAME";
        } else if (document.getElementById("ctl00_ContentPlaceHolder1_sagepay_div").style.display == "block") {
            document.getElementById("ctl00_ContentPlaceHolder1_sagepay_div").style.display = "none";
            document.getElementById("ctl00_ContentPlaceHolder1_current_active_div_for_pdq").value = "SAGEPAY";
        } else {
            document.getElementById("ctl00_ContentPlaceHolder1_current_active_div_for_pdq").value = "PRODUCTS";
            document.getElementById("ctl00_ContentPlaceHolder1_products_page_div").style.display = "none"
        }    
        // show the iframe
        document.getElementById("ctl00_ContentPlaceHolder1_pdq_iframe_div").style.display = "block";
        document.getElementById("ctl00_ContentPlaceHolder1_pdq_iframe_div").height = "100%";
        document.getElementById("ctl00_ContentPlaceHolder1_pdq_iframe_div").width = "100%";
    }
}

// show or hide the product div
function showProduct(prodDiv) {    
    // check if the product div is already visible then toggle it
    // change the image as well to either down or up arrow
    if (document.getElementById(thisDiv(prodDiv)).style.display.toLowerCase() == 'none') {
        // show this div
        document.getElementById(thisDiv(prodDiv)).style.display = "block";
        document.getElementById(thisDivImg(prodDiv)).src = "images/" + prodDiv + "_ON.png";
        document.getElementById(thisDivStatus(prodDiv)).value = prodDiv;

        // hide any messages that might have been visible
        var id = thisMessageDiv(prodDiv, "member_login_message");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "transfer_message_part_a");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "transfer_message_part_b");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "transfer_book_message");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "booking_message");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "giftcard_message");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        id = thisMessageDiv(prodDiv, "member_join_message");
        if (gotId(id)) document.getElementById(id).style.display = "none";
        
        // alert(thisDivStatus(prodDiv) + ' = ' + document.getElementById(thisDivStatus(prodDiv)).value);
        // hide all the others membership, booking, giftcard, transfer, member
        // var tabs = new Array("Membership", "Booking", "Giftcard", "Transfer", "Member");
        var tabs = new Array("Booking", "Giftcard", "Transfer", "Member", "Info", "DrivewayToRunway");
        for (i=0;i<tabs.length;i++) {
            if (prodDiv != tabs[i]) {
                document.getElementById(thisDiv(tabs[i])).style.display = "none";
                document.getElementById(thisDivImg(tabs[i])).src = "images/" + tabs[i] + "_OFF.png";
            }         
        }
    } else {
        // allready visible do nothing
    }
}

function gotId(thisId) {
    if (document.getElementById(thisId) != null) {
        return true;
    } else {
        // alert('not found:' + thisId);
        return false;
    }
}

function thisDiv(prodDiv) {
    return 'ctl00_ContentPlaceHolder1_Product' + prodDiv + '_product_portal';
}

function thisMessageDiv(prodDiv,msgDiv) {
    return 'ctl00_ContentPlaceHolder1_Product' + prodDiv + '_' + msgDiv;
}

function thisDivImg(prodDiv) {
    return 'ctl00_ContentPlaceHolder1_product_banner_image_' + prodDiv;
}

function thisDivStatus(prodDiv) {
    return 'ctl00_ContentPlaceHolder1_tab_visible';
}

function showProductOriginal(prodDiv) {

    var thisDiv = 'ctl00_ContentPlaceHolder1_Product' + prodDiv + '_product_portal';
    var thisDivImg = 'ctl00_ContentPlaceHolder1_Product' + prodDiv + '_product_banner_image';
    var thisDivStatus = 'ctl00_ContentPlaceHolder1_Product' + prodDiv + '_portal_hidden';

    // check if the product div is already visible then toggle it
    // change the image as well to either down or up arrow
    if (document.getElementById(thisDiv).style.display.toLowerCase() == 'none') {
        document.getElementById(thisDiv).style.display = "block";
        document.getElementById(thisDivImg).src = "images/arrow_up.png";
        document.getElementById(thisDivStatus).value = "block";
    } else {
        document.getElementById(thisDiv).style.display = "none";
        document.getElementById(thisDivImg).src = "images/arrow_down.png";
        document.getElementById(thisDivStatus).value = "none";
    }
}

function showCalendar(dateFieldCS) {
    // show the transfer calendar div
    var thisDiv = 'ctl00_Calendar_public_datePicker';
    var thisLeft = 'ctl00_Calendar_public_datepicker_left';
    var thisTop = 'ctl00_Calendar_public_datepicker_top';
    var thisVisible = 'ctl00_Calendar_public_datepicker_visible';
    var thisTextBox = 'ctl00_Calendar_public_target_textbox';
    // store the name of the target field so the datapicker knows where to update
    
    try {
        document.getElementById(thisTextBox).value = dateFieldCS;
    }
    catch (err) {
        alert('not found');
    }
       
    var obj = document.getElementById(dateFieldCS);
    
    // get the position of the datefield
    var t = 0;
    var lbit = 0;

    if (obj.offsetParent) {
        do {
            lbit += obj.offsetLeft;
            t += obj.offsetTop;
        } while (obj = obj.offsetParent)
    }

    // alert('top = ' + t + ' left = ' + lbit + ' thisLeft = ' + thisLeft);
    // save the divs position
    document.getElementById(thisLeft).value = lbit;
    document.getElementById(thisTop).value = t + 20;
    document.getElementById(thisVisible).value = "block";
    //alert('here 1');
    // move the div to this location
    document.getElementById(thisDiv).style.left = lbit + "px";
    document.getElementById(thisDiv).style.top = (t + 20) + "px";
    document.getElementById(thisDiv).style.display = "block";
    //alert('here 2');
}

function showTransferCalendar() {
    // show the transfer calendar div
    var thisDiv = 'ctl00_ContentPlaceHolder1_ProductTransfer_pickup_calendar';
    document.getElementById(thisDiv).style.display = "block";
}

function showLoungeDateCalendar() {
    // show the transfer calendar div
    var thisDiv = 'ctl00_ContentPlaceHolder1_ProductBooking_loungeDate_calendar';
    document.getElementById(thisDiv).style.display = "block";
}

