﻿function bkcheckDate(sender, args) {
   // if (sender._selectedDate < new Date()) {
   //    alert("Please select a date that is not earlier than today.");
   //     sender._selectedDate = new Date();
   //     sender._textbox.set_Value(sender._selectedDate.format(sender._format))
   // }
}

function childAges(childSelector, bookingType) {
    if (childSelector.value == "0") { document.getElementById(bookingType + 'ChildAges').style.display = 'none'; } else { document.getElementById(bookingType + 'ChildAges').style.display = 'block'; }
    for (i = 1; i <= childSelector.value; i++) {
        document.getElementById(bookingType + 'ChildAge' + i).style.display = 'block';
    }
    for (i = parseInt(childSelector.value) + 1; i < 6; i++) {
        document.getElementById(bookingType + 'ChildAge' + i).style.display = 'none';
    }
}

function bkHotelAction(inId, outId) {

    var toVal = document.getElementById('hotel_city').value;
    if (toVal == 'Destination City') document.getElementById('hotel_city').value = 'Denver, CO';
    var childAges = "";
    for (var j = 1; j <= (document.getElementById("hotel_children").selectedIndex - 1); ++j) {
        if (document.getElementById("hotel_child" + j).selectedIndex == 0) {
            alert("you must enter and age for each minor");
            document.getElementById("hotel_child" + j).focus();
            return false;
        }
        childAges = childAges + "&minorsAge" + (j - 1) + "=" + document.getElementById('hotel_child' + j).value;
    }

    var qString = "&avail=Y&smoking_pref=NP&bed_type=NP&src=10011000&currency_id=USD&tab=tab0";
    var doa = document.getElementById(inId).value.split("/");
    var dod = document.getElementById(outId).value.split("/");
    qString = qString + "&doa_mm=" + doa[0];
    qString = qString + "&doa_dd=" + doa[1];
    qString = qString + "&doa_yy=" + doa[2];
    qString = qString + "&dod_mm=" + dod[0];
    qString = qString + "&dod_dd=" + dod[1];
    qString = qString + "&dod_yy=" + dod[2];
    qString = qString + "&city=" + document.getElementById('hotel_city').value;
    qString = qString + "&num_rooms=" + document.getElementById('hotel_rooms').value;
    qString = qString + "&num_adults=" + document.getElementById('hotel_adults').value;
    qString = qString + "&num_children=" + document.getElementById('hotel_children').value;
    qString = qString + childAges;
    qString = qString + "&seniors=0";
    qString += "&sort_order=Ranking";

    //location.href = 'http://www.res99.com/nexres/search/search_results.cgi' + qString;
    location.href = '/default.aspx?tpurl=&spurl=hotel-booking' + qString;
    return false;
}


function getElement(id) {
    if (document.getElementById) {
        getElement = function(id) { return document.getElementById(id); }
    } else if (document.all) {
        getElement = function(id) { return document.all[id]; };
    } else if (document.layers) {
        getElement = function(id) { return document.layers[id]; };
    } else {
        getElement = function() { return null; }
    }
    return getElement(id);
}


