var hotelSearchType; /* $(document).ready(function(){ $("#frmLogin").validate(); //add datepicker to all date fields $.datepicker.setDefaults({ showOn: 'both', buttonImageOnly: true, buttonImage: '/images/img_calendar.gif', buttonText: 'Calendar', dateFormat: 'dd/mm/yy' }); //initialize the hotel slim search form according to search type //search type is saved in cookie to keep state between pages hotelSearchType = $.cookie("hotelsearchtype"); if (hotelSearchType == "" || hotelSearchType == null) { hotelSearchType = "hotelSearchFields"; } $("#hotelsearchfields").load("/slimquicksearch/" + hotelSearchType + ".htm", function(){ setupSearchFields(); }); $("#searchtype_" + hotelSearchType).attr("checked","checked"); $("input[name='searchtype']").change(function(){ hotelSearchType = this.value; $.cookie("hotelsearchtype", this.value, { path: '/', expires: 10 }); $("#hotelsearchfields").load("/slimquicksearch/" + this.value + ".htm", function(){ setupSearchFields(); }); }); });*/ function doQuickHotelSearch(){ if ($("#frmHotelSearch").valid()) { document.forms["frmHotelSearch"].submit(); } } // sets up search forms according to selected search type function setupSearchFields(){ //Inject searchTypeTitle to hotelOffers_slimquicksearch.htm $("h2.searchTypeTitle").hide(); $("#searchTypeHolder").html($("h2.searchTypeTitle").html()); /* $(".dateinput").datepicker({ onClose: function() {$(this).valid();} }); */ loadAutocomplete("#hotelsDestination" , "/ajax/accomodationDestinations.txt" ,2 ); var totalRooms = $.cookie("totalRooms"); if (totalRooms == "" || totalRooms == null) { totalRooms = 1; } totalRooms = eval(totalRooms); initializeRoomFields(totalRooms , "#frmHotelSearch"); switch (hotelSearchType) { /*ONLY HOTELS*/ case "hotelSearchFields": $("#frmHotelSearch").validate(); break; /*HOTEL - FLIGHTS*/ case "hotelFlightsSearchFields": setuphotelFlightsSearchFields("#frmHotelSearch"); $("#frmHotelSearch").validate({ rules: { returnDate: { required: function(){ return $("#flightType_roundTrip").is(":checked"); } } } }); break; /*CAR - HOTELS*/ case "hotelCarSearchFields": setuphotelCarSearchFields("#frmHotelSearch"); $("#frmHotelSearch").validate(); break; /*HOTEL - CAR - FLIGHTS*/ case "hotelFlightCarSearchFields": setuphotelFlightsCarSearchFields("#frmHotelSearch"); $("#frmHotelSearch").validate({ rules: { returnDate: { required: function(){ return $("#flightType_roundTrip").is(":checked"); } } } }); break; } } function setuphotelCarSearchFields(formId){ loadAutocomplete("#carPickUp,#carDropOff" , "/ajax/carpickup.txt" ,2 ); } function setuphotelFlightsSearchFields(formId){ $("input[name='flightType']").change(function(){ if ($("#flightType_roundTrip").is(":checked")) { $(".trReturnDate").show(); } else{ $(".trReturnDate").hide(); } }); loadAutocomplete("#flightOrigin, #flightDestination" , "/ajax/airports.txt" ,2 ); loadAutocomplete("#airline" , "/ajax/airlines.txt" ,2 ); } function setuphotelFlightsCarSearchFields(formId){ $("input[name='flightType']").change(function(){ if ($("#flightType_roundTrip").is(":checked")) { $(".trReturnDate").show(); } else{ $(".trReturnDate").hide(); } }); loadAutocomplete("#flightOrigin, #flightDestination" , "/ajax/airports.txt" ,2 ); loadAutocomplete("#airline" , "/ajax/airlines.txt" ,2 ); loadAutocomplete("#carPickUp,#carDropOff" , "/ajax/carpickup.txt" ,2 ); } //takes formId in order to enable the page to have multiple room - flight selectors with the same script function initializeRoomFields(totalRooms , formId) { for (var count = 1; count <= 4; ++count) { $(formId + " .childrenRoom" + count).change(function(){ updateChildrenOptions($(this),formId); }); $(formId + " .infantsRoom" + count).change(function(){ updateFlightInfantOptions($(this),formId); }); $(formId + " .tdRoom" + count + "childrenages").hide(); if (count > totalRooms) { $(formId + " .room" + count).hide(); } } showHideRoomOptions(totalRooms,formId); $(formId + " .totalRooms").change(function(){ var totalRooms = eval($(formId + " .totalRooms").val()); $.cookie("totalRooms", totalRooms, { path: '/', expires: 10 }); showHideRoomOptions(totalRooms ,formId); }); } //takes formId in order to enable the page to have multiple room - flight selectors with the same script function showHideRoomOptions(totalRooms , formId){ for (var i=1;i<=totalRooms;++i) { $(formId + " .room" + i).show(); $(formId + " .childrenRoom" + i).change(); $(formId + " .infantsRoom" + i).change(); } for (var i=totalRooms + 1;i<=4;++i) { $(formId + " .room" + i).hide(); } $(formId + " .totalRooms").val(totalRooms); } //takes formId in order to enable the page to have multiple room - flight selectors with the same script function updateChildrenOptions(control,formId) { var totalChildren = eval($(control).val()); var roomNo = eval($(control).attr("class").substring(12,13)); if (totalChildren == 0) { $(formId + " .tdRoom" + roomNo + "childrenages").hide(); } else { $(formId + " .tdRoom" + roomNo + "childrenages").show(); for (var i=1;i<=totalChildren;++i){ $(formId + " .room" + roomNo + "child" + i + "age").show(); } for (var i=totalChildren + 1;i<=4;++i){ $(formId + " .room" + roomNo + "child" + i+ "age").hide(); } } } function updateFlightInfantOptions(control,formId) { var totalInfants = eval($(control).val()); var roomNo = eval($(control).attr("class").substring(11,12)); var selectedInfant = eval($(formId + " .infantSeatsRoom" + roomNo).val()); if (totalInfants == 0) { $(formId + " .tdInfantSeatsRoom" + roomNo).hide(); } else { $(formId + " .tdInfantSeatsRoom" + roomNo).show(); var options = ""; for (var i=0;i<=totalInfants;++i) { if(i==selectedInfant) options += "
"; else options += "
"; } } $(formId + " .infantSeatsRoom" + roomNo).html(options); }