var gDateDetail = "SUMMARY";
var gDateRange = "RANGE1";
$(pageSetup);
function pageSetup() {
try {
$("#dateRange1").hide();
$("#dateRange2").hide();
$("#summaryRange2").hide();
$(".seatSaleTable input[@name='travelDateSelect']").click(function() {processTravelChange(this);});
$("#viewAllFares").click(function() {processDatesView(this);});
$("#deals").click(function() {setFocus("DEALS");});
$("#dealsTab").click(function() {setFocus("DEALS");});
$("#hotels").click(function() {setFocus("HOTELS");});
$("#hotelsTab").click(function() {setFocus("HOTELS");});
$(".openLink").click(function() {setFocus("HOTELS");});
$(".closeLink").click(function() {setFocus("HOTELS");});
$(".hotelPod .openLink").click(function() {openHotel(this);});
$(".hotelPod .closeLink").click(function() {closeHotel(this);});
$("#depMonth").change(function() {handleDepMonthChange(this);});
$("#retMonth").change(function() {handleRetMonthChange(this);});
}
catch(e) {
alert(e.toString());
}
}
function setFocus(item) {
switch(item) {
case "DEALS" : {
$("#deals").css("z-index", "50");
$("#hotels").css("z-index", "10");
$("#dealsTab").html("<p>Sale fares to London</p>");
$("#hotelsTab").html("<p>View FREE* hotels</p>");
break;
}
case "HOTELS" : {
$("#deals").css("z-index", "10");
$("#hotels").css("z-index", "50");
$("#dealsTab").html("<p>View fares to London</p>");
$("#hotelsTab").html("<p>FREE* hotel nights</p>");
break;
}
}
}
processTravelChange = function(element) {
var requiredRange = element.getAttribute("value");
switch(requiredRange) {
case "RANGE1": {
gDateRange = "RANGE1";
refreshDateTable();
break;
}
default: {
gDateRange = "RANGE2";
refreshDateTable();
}
}
}
refreshDateTable = function() {
if((gDateDetail == "SUMMARY") && (gDateRange == "RANGE1")) {
$("#dateRange1").hide();
$("#dateRange2").hide();
$("#summaryRange2").hide();
$("#summaryRange1").show();
}
else if((gDateDetail == "SUMMARY") && (gDateRange == "RANGE2")) {
$("#dateRange1").hide();
$("#dateRange2").hide();
$("#summaryRange2").show();
$("#summaryRange1").hide();
}
else if((gDateDetail != "SUMMARY") && (gDateRange == "RANGE1")) {
$("#dateRange1").show();
$("#dateRange2").hide();
$("#summaryRange2").hide();
$("#summaryRange1").hide();
}
else {
$("#dateRange1").hide();
$("#dateRange2").show();
$("#summaryRange2").hide();
$("#summaryRange1").hide();
}
}
processDatesView = function(element) {
if(gDateDetail == "SUMMARY") {
gDateDetail = "DETAIL";
element.innerHTML = "Show lead fares only";
}
else {
gDateDetail = "SUMMARY";
element.innerHTML = "Show all fares";
}
refreshDateTable();
}
openHotel = function(hotelLink) {
var hotelPod = "#hotel" + hotelLink.getAttribute("id").substring(4, 6);
$(hotelPod + " .hotelSummary").hide();
$(hotelPod + " .hotelDetail").show();
}
closeHotel = function(hotelLink) {
var hotelPod = "#hotel" + hotelLink.getAttribute("id").substring(5, 7);
$(hotelPod + " .hotelDetail").hide();
$(hotelPod + " .hotelSummary").show();
}
handleDepMonthChange = function() {
var departureMonth = $("#depMonth option:selected")[0].value;
var returnMonth = $("#retMonth option:selected")[0].value;
if(departureMonth > returnMonth) {
$("#retMonth option[@value='" + departureMonth + "']").attr({"selected":"selected"});
}
}
handleRetMonthChange = function() {
var departureMonth = $("#depMonth option:selected")[0].value;
var returnMonth = $("#retMonth option:selected")[0].value;
if(returnMonth < departureMonth) {
$("#depMonth option[@value='" + returnMonth + "']").attr({"selected":"selected"});
}
}
setupForm = function() {
var departureDay = $("#depDay option:selected")[0].value;
var departureMonth = $("#depMonth option:selected")[0].value;
var returnDay = $("#retDay option:selected")[0].value;
var returnMonth = $("#retMonth option:selected")[0].value;
var departureDate = departureMonth + "/" + departureDay + "/08";
var returnDate = returnMonth + "/" + returnDay + "/08";
$("form input[@name='depDate']").attr({"value":departureDate});
$("form input[@name='retDate']").attr({"value":returnDate});
}
