WLHloadscript1();
//affiliateID = getQueryVariable("aid"); //returns !!!id!!
//affiliateID = affiliateID.replace(/!!!/g,'');
//affiliateID = "5555" //debug code

function getQueryVariable(param) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == param) {
            return pair[1];
        }
    }
}

function WLHloadscript1() {
    document.write('<script src="http://www.warnerleisurehotels.co.uk/affiliatebreaksearch/Common/Scripts/jquery.min.js">' + '<\/script>' + '<script src="http://www.warnerleisurehotels.co.uk/affiliatebreaksearch/AffiliateWindows/Scripts/ui.datepicker_affilwin.js">' + '<\/script>' + '<script src="http://www.warnerleisurehotels.co.uk/affiliatebreaksearch/Common/Scripts/main.js">' + '<\/script>');
    var todaydate = new Date();
    var tday = todaydate.getDate() + 1;
    var tmonth = todaydate.getMonth() + 1;
    var tyear = todaydate.getFullYear();
    var idate = tday + "/" + tmonth + "/" + tyear;

    var searchBoxFormHTML;
    searchBoxFormHTML =
    '<div id="AffiliateSearchBox">' +
        '<div class="formRow">' +
            '<label for="ht"><strong>Select Location</strong></label><br/>' +
            '<select name="ht" id="s_hotel_sel">' +
                '<option value="" >All Locations</option>' +
                '<option value="al">Alvaston Hall Hotel</option>' +
                '<option value="bm">Bembridge Coast Hotel</option>' +
                '<option value="bd">Bodelwyddan Castle Hotel</option>' +
                '<option value="ct">Corton Resort</option>' +
                '<option value="cs">Cricket St Thomas Hotel</option>' +
                '<option value="gh">Gunton Hall Resort</option>' +
                '<option value="hl">Holme Lacy House Hotel</option>' +
                '<option value="lk">Lakeside Resort</option>' +
                '<option value="lc">Littlecote House Hotel</option>' +
                '<option value="nh">Nidd Hall Hotel</option>' +
                '<option value="ng">Norton Grange Resort</option>' +
                '<option value="sw">Sinah Warren Hotel</option>' +
                '<option value="th">Thoresby Hall Hotel</option>' +
            '</select><br/>' +
            '<a onclick="javascript:window.open(\'http://www.warnerleisurehotels.co.uk/affiliatebreaksearch/Common/Images/locationmap.jpg\',\'new_blank\',\'toolbar=no,menubar=0,scrollbars=0,location=0,resizable=no,height=410,width=440\')" style="cursor:pointer">View Location Map ></a>' +
        '</div><br/>' +
        '<div class="formRow">' +
            '<label for="displaydatebasic"><strong>Select Date</strong></label><br/>' +
            '<input type="text" name="sd" id="displaydatebasic" value="' + idate + '"  size="12" class="txtField" />' +
        '</div>' +
        '<div class="formRow">' +
            '<input type="hidden"  name="tp" id="s_promo_text" size="8"  value="25AFX"  class="txtField"  />' +
        '</div> <br />' +
		'<div class="formRow">' +
            '<a href="javascript:redirectToBookingEngine();"><img alt="Search" src="http://www.warnerleisurehotels.co.uk/affiliatebreaksearch/Common/Images/btn_submit.gif" /></a>'
    '</div>' +
    '</div>';

    document.write(searchBoxFormHTML);

    return;
}

function redirectToBookingEngine() {
    var location = "";
    var date = "";
    var ddl;
    var affilURL = "";

    date = document.getElementById('displaydatebasic').value;
    ddl = document.getElementById('s_hotel_sel');
    location = ddl.options[ddl.options.selectedIndex].value;

    //affilURL = affiliateURL + affiliateID + "!!!" + "&p="
    var targetURL;
    targetURL = affiliateURL + wlhBreakListingURL + '?tp=25AFX&sd=' + date + '&ht=' + location;

    //alert(targetURL); //debug code
    //targetURL = wlhBreakListingURL + '?tp=25AFX&sd=' + date + '&ht=' + location;  debug code
    //alert(targetURL);
    window.open(targetURL);
}
