var $j = jQuery.noConflict(), childAgesExist = false; function getCombinedDate(a, b) { return b.length == 2 ? new Date(b[0] + "/" + a + "/" + b[1]) : new Date("01/01/0001") } function getSelectedDate() { var a = "", b = ""; $j("#StartDay") && (a = $j("#StartDay").children("[selected]").val()); $j("#StartMonthYearCombination") && (b = $j("#StartMonthYearCombination").children("[selected]").val().split("-")); return getCombinedDate(a, b) }
function showDayName(a, b) { b ? $j("#dayOfWeek").replaceWith('<span id="dayOfWeek" class="calWeekDay">' + a + "</span>") : $j("#dayOfWeek").replaceWith('<span id="dayOfWeek" class="calWeekDay">' + a.getDayName(true) + "</span>") }
$j(document).ready(function () {
	initForm(); $j("#StartDay").change(function () { var a = getSelectedDate(); showDayName(a); setCookie("dayOfWeek", a.getDayName(true)); setCookie("selectedDate", $j("#StartDay").attr("selectedIndex")); setCookie("selectedMonthYear", $j("#StartMonthYearCombination").attr("selectedIndex")) }); $j("#StartMonthYearCombination").change(function () {
		var a = getSelectedDate(); showDayName(a); setCookie("dayOfWeek", a.getDayName(true)); setCookie("selectedDate", $j("#StartDay").attr("selectedIndex"));
		setCookie("selectedMonthYear", $j("#StartMonthYearCombination").attr("selectedIndex"))
	})
});
function getRooms(a) {
	for (var b = "", c = 1; c <= a; c++) b += '<div id="room' + c + '"><div class="row3SubCell"><div>Room:</div><div><span class="roomNum" id="room' + c + '">' + c + '</span></div></div><div class="row3SubCell"><div>Adults</div><div class="roomOption"><select name="stayDetails.roomRequests[' + (c - 1) + '].Adults" id="ftAdults' + c + '"><option value="0">0</option><option value="1">1</option><option value="2" selected="selected">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option></select></div></div><div class="row3SubCell"><div>Children</div><div class="roomOption"><select name="stayDetails.roomRequests[' + (c -
1) + '].Children" id="ftChildren' + c + '"><option value="0" selected="selected">0</option>\t<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option></select></div></div><div id="childAges_' + c + '"></div></div>'; return b
}
function getChildAges(a, b) { var c = ""; if (b > 0) for (var c = "<label>Child Ages</label>", d = 1; d <= b; d++) c = c + '<select class="childAge" id="ftChildAges_' + a + "_" + d + '" name="stayDetails.roomRequests[' + (a - 1) + "].childAges[" + (d - 1) + ']""><option value="-1">--</option><option value="0">< 1</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option></select>&nbsp;'; return c }
function attachOccupancyHelper(a, b) { if (jQuery != "undefined") { var c = jQuery(a).attr("selectedIndex") + 1; jQuery(b).empty().append(getRooms(c)); for (var d = 1; d <= c; d++) attachChildAgeHelper("#ftChildren" + d) } }
function attachChildAgeHelper(a) { if (jQuery != "undefined") { var b = parseInt(jQuery(a).attr("name").match("[0-9]+")); isNaN(b) ? b = 1 : b += 1; childAgesExist == false && navigator.appName.toLowerCase() == "netscape" && jQuery("#ftRooms").attr("selectedIndex") == 0 && jQuery("#ftChildren1").attr("selectedIndex") != 0 && (jQuery("#childAges_" + b).empty().append(getChildAges(b, jQuery("#ftChildren1").attr("selectedIndex"))), childAgesExist = true); jQuery(a).change(function () { jQuery("#childAges_" + b).empty().append(getChildAges(b, jQuery(a).attr("selectedIndex"))) }) } }
function initForm() {
	var a = new Date; a.setDate(a.getDate() + 1); $j("#companyCode").val().toUpperCase() == "IN049" && VisitLondonDepartureStations(); initDateDropDowns("fastTrackForm"); var b = getCookie("dayOfWeek"), c = getCookie("selectedDate"), d = getCookie("selectedMonthYear"); b.length ? showDayName(b, true) : showDayName(a); c.length && $j("#StartDay").attr("selectedIndex", parseInt(c)); d.length && $j("#StartMonthYearCombination").attr("selectedIndex", parseInt(d)); if (jQuery != "undefined") {
		jQuery("#ftRooms").change(function () {
			attachOccupancyHelper("#ftRooms",
"#bookingParty")
		}); jQuery("#bookingParty").empty().append(getRooms(jQuery("#ftRooms").attr("selectedIndex") + 1)); for (a = 1; a <= 4; a++) jQuery("#ftChildren" + a).change(function () { attachChildAgeHelper(this) })
	} 
} function RemoveInvalidAvailabilityDates(a) { $j("#StartMonthYearCombination") && $j("#StartMonthYearCombination option").each(function () { availOption = $j(this).val(); availDate = new Date(availOption.replace("-", "/28/")); availDate > a && $j(this).remove() }) };
