1var today = new Date(); 2var defaultDate = new Date(); 3var defaultEndDate = new Date(); 4var todayTime = today.getTime(); 5var dateTime = defaultDate.getTime(); 6var endDateTime = defaultEndDate.getTime(); 7var date_format = "D d M yy"; 8jQuery(document).ready(function (){ 9 if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod'){ 10 $('html').addClass('ios'); 11 }; 12 var TS = {}; 13 $(function(){ 14 TS.book.init(); 15 TS.highlight.init(); 16 // setLangCurrency(); 17 // loadCurrencyCode(); 18 }); 19 /* 20 quirksmode cookie read and write port [http://www.quirksmode.org/js/cookies.html] 21 */ 22 TS.cookie = { 23 create: function(name, value, days){ 24 if (days){ 25 var _oDate = new Date(); 26 _oDate.setTime(_oDate.getTime() + (days * 24 * 60 * 60 * 1000)); 27 var _sExpires = '; expires=' + _oDate.toGMTString(); 28 } 29 else var _sExpires = ''; 30 document.cookie = name + '=' + value + _sExpires + '; path=/'; 31 }, 32 read: function(name){ 33 var nameEQ = name + "="; 34 var ca = document.cookie.split(';'); 35 for(var i=0;i < ca.length;i++) { 36 var c = ca[i]; 37 while (c.charAt(0)==' ') c = c.substring(1,c.length); 38 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 39 } 40 return null; 41 }, 42 erase: function(name){ 43 TS.cookie.create(name, '', -1); 44 } 45 } 46 /* 47 anchor based highlighter: 48 displays overlay, takes user to top of page via anchor and highlights the element referenced by the activating anchor's href 49 */ 50 TS.highlight = { 51 sHighlighterCssClass: 'ts-book-highlight', 52 sPageId: 'ts-page', 53 sOverlayId: 'ts-overlay', 54 sAboveOverlayCssClass: 'ts-above-overlay', 55 sBookClass: 'ts-book-horiz', 56 nFadeDuration: 888, 57 init: function(){ 58 var _eElement = $('.' + TS.highlight.sBookClass).first(); 59 var _eOverlay = $('#' + TS.highlight.sOverlayId); 60 var _eHighlighter = $('.' + TS.highlight.sHighlighterCssClass); 61 if (_eHighlighter){ 62 $('.' + TS.highlight.sHighlighterCssClass).click(function(e){ 63 (e.preventDefault) ? e.preventDefault() : e.returnValue = false; 64 _eElement.addClass(TS.highlight.sAboveOverlayCssClass); 65 _eOverlay.css('filter', 'alpha(opacity=50)'); // ie7 bug workaround: redefine opacity before fade 66 _eOverlay.fadeIn(TS.highlight.nFadeDuration); 67 var new_position = $('#' + TS.highlight.sPageId).offset(); 68 window.scrollTo(new_position.left,new_position.top); 69 }); 70 if (_eOverlay) _eOverlay.click(function(){ 71 _eOverlay.fadeOut(TS.highlight.nFadeDuration); 72 $('#' + TS.highlight.sBookId).removeClass(TS.highlight.sAboveOverlayCssClass); 73 }); 74 } 75 } 76 }; 77 /* 78 datepicker / booking component 79 please note extended ISO 8601 local date format yyyy-mm-dd 80 */ 81 TS.book = { 82 nDaysOffset: 1, // number days between current user selected checkin and auto checkout update 83 nFirstCheckinDaysOffset: 0, // number days between today and earliest possible checkin - set to zero to allow checkin today 84 nSundays: 0, // 0 = disable and resort to supplied default date, 1 = this sunday, 2 = next sunday, 3 = sunday after next sunday, etc. 85 nDefaultOffset: 10, // number days between today and default checkin (only works in absence of default date and sunday feature disabled) 86 bOnValidationFailChangeDate: true, 87 checkoutUpdated: false, 88 bAlwaysUpdateCheckout: true,// WTF? 89 sSubmitId: 'ts-book-submit', 90 sDatepickerSelector: '.ts-datepicker', 91 sInDateInputId: 'ts-checkin-date', 92 sLocation: 'ts-location', 93 sOutDateInputId: 'ts-checkout-date', 94 sIconSpanCssClass: 'ts-calendar-icon', 95 sIconTitleText: 'Click to display calendar', 96 sMonthYearSelectCssClass: 'ts-month', 97 sDaySelectCssClass: 'ts-day', 98 sInDayId: 'ts-checkin-day', 99 sOutDayId: 'ts-checkout-day', 100 sInMonthYearId: 'ts-checkin-month', 101 sOutMonthYearId: 'ts-checkout-month', 102 sNumberGuestsId: 'ts-guest', 103 sDefaultDateId: 'hdnCheckinDateFromGeneric', 104 sSubmissionUrl: 'http://secure.travelstay.com/servlet/TravelStay.ResevationSearch', 105 sLanguage: document.forms['styleForm'].language.value, // supports: en,fr,de,es,it,pl - datepicker and validation messaging localisation 106 sLocalisationPath: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/i18n/', 107 sCookieName: 'ts-search-date', 108 oDays:{ 109 'aDaysEn': ['Sun.','Mon.','Tue.','Wed.','Thu.','Fri.','Sat.'], 110 'aDaysFr': ['Dim.','Lun.','Mar.','Mec.','Jeu.','Ven.','Sam.'], 111 'aDaysDe': ['Son.','Mon.','Die.','Mit.','Don.','Fre.','Sam.'], 112 'aDaysEs': ['Dom.','Lun.','Mar.','Mié.','Jue.','Vie.','Sáb.'], 113 'aDaysIt': ['Dom.','Lun.','Mar.','Mer.','Gio.','Ven.','Sab.'],
114 'aDaysPl': ['Nie.','Pon.','Wto.','Åro.','Czw.','PiÄ .','Sob.'] 115 }, 116 oValidationMsg:{ 117 'msgEn' : 'To view prices and availability, please enter your dates!', 118 'msgFr' : 'Pour voir les prix et la disponibilité, s\'il vous plaît entrer vos dates!', 119 'msgDe' : 'Um die Preise und die Verfügbarkeit anzuzeigen, geben Sie bitte Ihre Daten!', 120 'msgEs' : 'Para ver los precios y la disponibilidad, por favor, introduzca las fechas!', 121 'msgIt' : 'Per visualizzare i prezzi e disponibilità , si prega di inserire le date!', 122 'msgPl' : 'Aby zobaczyÄ ceny i dostÄpnoÅÄ, wpisz daty!', 123 'msgCheckoutEn' : 'Check out date must be after check in date!', 124 'msgCheckoutFr' : 'Date de départ doit être postérieure à date d\'arrivée!', 125 'msgCheckoutDe' : 'Der Abreisetag muss nach dem Check-in Datum sein!', 126 'msgCheckoutEs' : 'Fecha de salida debe ser posterior a fecha de check in!', 127 'msgCheckoutIt' : 'Data di partenza deve essere successiva data di check-in!', 128 'msgCheckoutPl' : 'Data wyjazdu musi byÄ późniejsza sprawdziÄ w terminie!', 129 'msgCheckinEn' : 'Please check your dates.\n\nYour requested check-in date has already passed!', 130 'msgCheckinFr' : 'S\'il vous plaît vérifier vos dates.\n\nVotre check-in date demandée est déjà passée!', 131 'msgCheckinDe' : 'Bitte überprüfen Sie Ihre Termine.\n\nIhr Wunsch-Check-in-Datum ist bereits verstrichen!', 132 'msgCheckinEs' : 'Por favor revise las fechas.\n\nEl check-in requerido fecha ya ha pasado!', 133 'msgCheckinIt' : 'Si prega di verificare le date.\n\nIl vostro check-in data di richiesta è già passata!', 134 'msgCheckinPl' : 'ProszÄ sprawdziÄ daty.\n\nTwój wniosek datÄ check-in już minÄ Å!' 135 }, 136 init: function(){ 137 var _eSubmit = $('a#' + TS.book.sSubmitId); 138 TS.book.aMonthSelects = $('select.' + TS.book.sMonthYearSelectCssClass); 139 TS.book.aDaySelects = $('select.' + TS.book.sDaySelectCssClass); 140 TS.book.eCheckinInput = $('input#' + TS.book.sInDateInputId); 141 TS.book.eCheckoutInput = $('input#' + TS.book.sOutDateInputId); 142 TS.book.locationInput = $('select#' + TS.book.sLocation); 143 TS.book.eNumberGuests = $('select#' + TS.book.sNumberGuestsId); 144 TS.book.generateMonths(); 145 TS.book.loadDefaults(); 146 if (_eSubmit){ 147 TS.book.aMonthSelects.change(function(){ 148 TS.book.rebuildDays(this); 149 TS.book.updateDatePicker(this); 150 TS.book.updateNightsStay(); 151 }); 152 TS.book.aDaySelects.change(function(){ 153 TS.book.updateDatePicker(this); 154 TS.book.updateNightsStay(); 155 }); 156 TS.book.localise(); 157 TS.book.loadDefaults(); 158 $(TS.book.sDatepickerSelector).datepicker({ 159 beforeShowDay: TS.book.highlight, 160 changeMonth: true, changeYear:true, 161 closeText: 'close calendar', 162 dateFormat: 'yy-mm-dd', 163 firstDay: 1, 164 minDate: TS.book.earliestCheckin(), 165 maxDate:"+2Y +1D", 166 numberOfMonths: 2, 167 onClose: function(dateText, inst){ 168 TS.book.rebuildDays(inst, dateText); 169 TS.book.datepickerUpdateSelects(dateText, inst); 170 }, 171 showButtonPanel: true 172 }); 173 // custom sprite based datepicker icon to avoid additional http request 174 // $('.date-label').datepicker().after( 175 // $("<span/>", { 'class': TS.book.sIconSpanCssClass, 'title': TS.book.sIconTitleText, 'text': TS.book.sIconTitleText}).click(function(){ 176 // $(this).prev('input').datepicker('show'); 177 // }) 178 // ); 179 $('#show-checkin').click(function(event) { 180 $('#ts-checkin-date').datepicker('show'); 181 }); 182 $('#show-checkout').click(function(event) { 183 $('#ts-checkout-date').datepicker('show'); 184 }); 185 _eSubmit.click(function(e){ 186 (e.preventDefault) ? e.preventDefault() : e.returnValue = false;
187 if ( TS.book.validate() ){ 188 TS.book.storeDates(); 189 //TS.book.fakeFormSubmit(); // testing 190 TS.book.realFormSubmit(); // deployment 191 } 192 }); 193 } 194 TS.book.updateNightsStay(); 195 }, 196 generateMonths: function () { 197 var now = new Date(); 198 var i; 199 var lang = TS.book.sLanguage; 200 var thisMonth; 201 var formattedMonth; 202 var textDate; 203 var langArray = 0; 204 var months = [ 205 ['January','February','March','April','May','June','July','August','September','October','November','December'], 206 ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'], 207 ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'], 208 ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'], 209 ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','N
209ovembre','Dicembre'], 210 ['StyczeÅ','Luty','Marzec','KwiecieÅ','Maj','Czerwiec','Lipiec','SierpieÅ;','WrzesieÅ','Październik','Listopad','GrudzieÅ'] 211 ]; 212 if (lang == 'en') { 213 langArray = 0; 214 } else if(lang == 'fr') { 215 langArray = 1; 216 } else if(lang == 'de') { 217 langArray = 2; 218 } else if(lang == 'es') { 219 langArray = 3; 220 } else if(lang == 'it') { 221 langArray = 4; 222 } else if(lang == 'pl') { 223 langArray = 5; 224 } 225 for (i=0; i<25; i++) { 226 if (i == 0) { 227 thisMonth = now; 228 } else { 229 thisMonth = (new Date(now.setMonth(now.getMonth() + 1,1))); 230 } 231 // console.log((thisMonth.getMonth() + 1)); 232 textDate = (months[langArray][thisMonth.getMonth()] + "'" +($.datepicker.formatDate( "y", thisMonth ))); 233 formattedDate= thisMonth.getFullYear() + '-' + ("0" + (thisMonth.getMonth() + 1)).slice(-2); 234 TS.book.aMonthSelects.append($('<option>', { 235 value: formattedDate, 236 text: textDate 237 })); 238 } 239 }, 240 /* 241 helper function - store user search dates to single session cookie 242 */ 243 storeDates: function(){ 244 var exisitingCooking = TS.cookie.read(TS.book.sCookieName); 245 var studentDiscount = $('#ts-student-discount').prop("checked") ? "Y" : "N"; 246 // console.log(document.getElementById("HID_SELECTEDHOTEL_val")); 247 // TS.book.checkoutUpdated = true; 248 if (sDocCookie){ 249 savedCity = sDocCookie.split(',',11)[7]; 250 savedLocation = sDocCookie.split(',',11)[2]; 251 savedHotel = sDocCookie.split(',',11)[6]; 252 savedHotelType = sDocCookie.split(',',11)[8]; 253 savedAttraction = sDocCookie.split(',',11)[9]; 254 savedAttractionCode = sDocCookie.split(',',11)[10]; 255 if ($('#ts-city').val() != null) { 256 savedCity = $('#ts-city').val(); 257 }; 258 if ($('#ts-hotel-type').val() != null) { 259 savedHotelType = $('#ts-hotel-type').val(); 260 }; 261 if ($('#ts-attraction').val() != null) { 262 savedAttraction = $('#ts-attraction').val(); 263 savedAttractionCode = $('#HID_SELECTEDHOTEL_val').val(); 264 }; 265 if ($('#ts-hotel-name').val() != null) { 266 savedHotel = $('#ts-hotel-name').val(); 267 }; 268 if ($('#ts-location').val() != null) { 269 savedLocation = $('#ts-location').val(); 270 }; 271 var sDates = TS.book.eCheckinInput.val() + ',' + TS.book.eCheckoutInput.val() + ',' + savedLocation + ',' + $('#ts-room-type').val() + ',' + studentDiscount + ',' + TS.book.eNumberGuests.val() + ',' + savedHotel + ',' + savedCity + ',' + savedHotelType + ',' + savedAttraction + ',' + savedAttractionCode; 272 } else { 273 var sDates = TS.book.eCheckinInput.val() + ',' + TS.book.eCheckoutInput.val() + ',' + TS.book.locationInput.val() + ',' + $('#ts-room-type').val() + ',' + studentDiscount + ',' + TS.book.eNumberGuests.val() + ',' + $('#ts-hotel-name').val() + ',' + $('#ts-city').val() + ',' + $('#ts-hotel-type').val() + ',' + $('#ts-attraction').val() + ',' + $('#HID_SELECTEDHOTEL_val').val(); 274 } 275 TS.cookie.create(TS.book.sCookieName, sDates); 276 }, 277 /* 278 helper function - returns (and stores to 'dEarliestCheckin') earliest possible checkin date 279 */ 280 earliestCheckin: function(){ 281 var _oToday = new Date(); 282 TS.book.dEarliestCheckin = TS.book.addDaysToDate(_oToday, TS.book.nFirstCheckinDaysOffset); 283 return TS.book.addDaysToDate(_oToday, TS.book.nFirstCheckinDaysOffset); 284 }, 285 /* 286 helper function - load default dates 287 if session cookie present - use it 288 if default date is supplied via hidden input - use it - else default to today + nDefaultOffset 289 if nSundays is enabled - use it - else default to above default date condition 290 checkout date is automatically updated to the day after currently selected checkin date + nDaysOffset 291 */ 292 loadDefaults: function(){ 293 var sCheckin, sCheckout; 294 var sDocCookie = TS.cookie.read(TS.book.sCookieName); 295 var _eDefaultDate = $('input#' + TS.book.sDefaultDateId); 296 var _oDefaultDate; 297 var _oToday = new Date(); 298 var _inDateFromUrl = new Date(TS.book.isoToDate($('input#' + TS.book.sInDateInputId).val())); 299 // console.log(_inDateFromUrl); 300 var _outDateFromUrl = new Date(TS.book.isoToDate($('input#' + TS.book.sOutDateInputId).val())); 301 if(_oToday.getDay() == 2 || _oToday.getDay() == 3) { 302 if (_oToday.getDay() == 2) { 303 var days = parseInt(10 + 2); 304 } else { 305 var days = parseInt(10 + 1); 306 } 307 _oToday.setDate(_oToday.getDate() + days); 308 } 309 if (TS.book.nSundays == 0){ 310 if ((_eDefaultDate.length > 0) && (_eDefaultDate.val() != '')){ 311 _oDefaultDate = new Date(TS.book.isoToDate(_eDefaultDate.val())); 312 } 313 else{ 314 _oDefaultDate = TS.book.addDaysToDate(_oToday, TS.book.nDefaultOffset); 315 } 316 } 317 else{ 318 _oDefaultDate = TS.book.getSunday(); 319 } 320 TS.book.updateCheckin(_inDateFromUrl); 321 TS.book.updateCheckout(_outDateFromUrl); 322 TS.book.rebuildDays($('select#ts-checkin-month')[0]); 323 TS.book.rebuildDays($('select#ts-checkout-month')[0]); 324 var cityQuery = getUrlParameter('C'); 325 var locQuery = getUrlParameter('L'); 326 var hotQuery = getUrlParameter('H'); 327 if (cityQuery != null) { 328 TS.book.updateCity(cityQuery); 329 }; 330 if (locQuery != null) { 331 TS.book.updateLocation(locQuery); 332 }; 333 if (hotQuery != null) { 334 TS.book.updateHotel(hotQuery); 335 }; 336 TS.book.updateNightsStay(); 337 }, 338 /* 339 localisation 340 */ 341 localise: function(){ 342 // jQuery getScript does not provide access to cache control (caching is disabled by default) so following override is required 343 $.getScript = function(url, callback, cache){ 344 $.ajax({ 345 type: 'GET', 346 url: url, 347 success: callback,
348 dataType: 'script', 349 cache: true 350 }); 351 }; 352 353 if (!TS.book.sLanguage) { 354 TS.book.sLanguage = 'en'; 355 } 356 if (TS.book.sLanguage != 'en'){ 357 $.getScript(TS.book.sLocalisationPath + 'jquery.ui.datepicker-' + TS.book.sLanguage + '.js', function(){ 358 loadMobileCal(); 359 $(TS.book.sDatepickerSelector).datepicker($.datepicker.regional[TS.book.sLanguage]); 360 $('#inline-ci-datepicker').datepicker($.datepicker.regional[TS.book.sLanguage]); 361 $('#inline-co-datepicker').datepicker($.datepicker.regional[TS.book.sLanguage]); 362 }); 363 } else { 364 loadMobileCal(); 365 } 366 }, 367 /* 368 validate: 369 checkin date is equal to or later than earliest allowable 370 on failure - set checkin date to earliest allowable 371 checkout date is after checkin date 372 on failure - set checkout date to 1 day after checkin 373 */ 374 validate: function(element){ 375 var _sMsg, _sOutMsg, _sInMsg; 376 switch(TS.book.sLanguage){ 377 case 'fr': 378 _sMsg = TS.book.oValidationMsg.msgFr; 379 _sOutMsg = TS.book.oValidationMsg.msgCheckoutFr; 380 _sInMsg = TS.book.oValidationMsg.msgCheckinFr; 381 break; 382 case 'de': 383 _sMsg = TS.book.oValidationMsg.msgDe; 384 _sOutMsg = TS.book.oValidationMsg.msgCheckoutDe; 385 _sInMsg = TS.book.oValidationMsg.msgCheckinDe; 386 break; 387 case 'es': 388 _sMsg = TS.book.oValidationMsg.msgEs; 389 _sOutMsg = TS.book.oValidationMsg.msgCheckoutEs; 390 _sInMsg = TS.book.oValidationMsg.msgCheckinEs; 391 break; 392 case 'it': 393 _sMsg = TS.book.oValidationMsg.msgIt; 394 _sOutMsg = TS.book.oValidationMsg.msgCheckoutIt; 395 _sInMsg = TS.book.oValidationMsg.msgCheckinIt; 396 break; 397 case 'pl': 398 _sMsg = TS.book.oValidationMsg.msgPl; 399 _sOutMsg = TS.book.oValidationMsg.msgCheckoutPl; 400 _sInMsg = TS.book.oValidationMsg.msgCheckinPl; 401 break; 402 default: 403 _sMsg = TS.book.oValidationMsg.msgEn; 404 _sOutMsg = TS.book.oValidationMsg.msgCheckoutEn; 405 _sInMsg = TS.book.oValidationMsg.msgCheckinEn; 406 } 407 var _dCheckinDate = TS.book.eCheckinInput.datepicker('getDate'); 408 var _dCheckoutDate = TS.book.eCheckoutInput.datepicker('getDate'); 409 var _bValidate = false; 410 if ( (_dCheckinDate == null) || (_dCheckinDate == '0') || (_dCheckoutDate == null) || (_dCheckoutDate == '0') ){ 411 alert(_sMsg); 412 _bValidate = false; 413 return; 414 } 415 if (_dCheckinDate < TS.book.dEarliestCheckin){ 416 _dCheckinDate = TS.book.dEarliestCheckin; 417 if (TS.book.bOnValidationFailChangeDate){ 418 TS.book.updateCheckin(_dCheckinDate); 419 } 420 alert(_sInMsg); 421 _bValidate = false; 422 } 423 else{ 424 if (_dCheckinDate >= _dCheckoutDate){ 425 alert(_sOutMsg); 426 _bValidate = false; 427 } 428 else{ 429 _bValidate = true; 430 } 431 } 432 if ( (_dCheckinDate == null) || (_dCheckinDate == '0') || (_dCheckoutDate == null) || (_dCheckoutDate == '0') ){ 433 alert(_sMsg); 434 _bValidate = false; 435 } 436 return _bValidate; 437 }, 438 /* 439 helper function - highlight weekends, start, end and start to end period on calendar 440 */
441 highlight: function(oDate){ 442 var _sState = ''; 443 var _dStartDate = TS.book.isoToDate( TS.book.eCheckinInput.val() ).getTime(); 444 var _dEndDate = TS.book.isoToDate( TS.book.eCheckoutInput.val() ).getTime(); 445 var _dCurrentDate = oDate.getTime(); 446 if (oDate.getDay() == 6 || oDate.getDay() == 0) _sState += ' ui-state-highlight'; 447 if (_dCurrentDate == _dStartDate){ 448 _sState += ' ui-state-startDate'; 449 } 450 if (_dCurrentDate == _dEndDate){ 451 _sState += ' ui-state-endDate'; 452 } 453 if (_dCurrentDate > _dStartDate && _dCurrentDate < _dEndDate){ 454 _sState += ' ui-state-midDate'; 455 } 456 return [true, _sState]; 457 }, 458 /* 459 helper function - rebuilds date select options with shortened day names prefixed to date 460 if bAuto is true then function called by auto setting of checkout date - in which case we need to rebuild days for checkout!! 461 */ 462 rebuildDays: function(eElement, sDate, bAuto){ 463 /* 464 if called by month select - element = select#ts-checkin-month 465 if called by datepicker - element = hidden input#ts-checkin-date 466 */ 467 var _sYearMonth, _sType, _this; 468 var _nDaysInMonth = 0; 469 if (bAuto){ 470 _this = $('#ts-checkout-month'); 471 _sType = 'checkout'; 472 } 473 else{ 474 _this = $('#' + eElement.id); 475 _sType = eElement.id.split('-',2)[1]; 476 } 477 if (!sDate){ 478 // console.log(_this); 479 _sYearMonth = _this.val(); 480 } 481 else{ 482 _sYearMonth = sDate.substring(0,7); 483 } 484 // console.log(_sYearMonth); 485 _nDaysInMonth = TS.book.getDaysInMonth(_sYearMonth); 486 var _eDaySelect = $('select#ts-' + _sType + '-day'); 487 var currentDay = _eDaySelect.prop('value'); 488 var _nSelectedIndex = _eDaySelect.prop('selectedIndex'); 489 var _aDays = []; 490 var _aMonths = []; 491 var month = _sYearMonth.substring(5,7); 492 var today = new Date(); 493 var selectedYear = _sYearMonth.substring(0,4); 494 var currentDay = $("#ts-checkin-day :selected").attr('value'); 495 var currentYear = today.getFullYear(); 496 switch(TS.book.sLanguage){ 497 case 'fr': 498 _aDays = TS.book.oDays.aDaysFr; 499 break; 500 case 'de': 501 _aDays = TS.book.oDays.aDaysDe; 502 break; 503 case 'es': 504 _aDays = TS.book.oDays.aDaysEs; 505 break; 506 case 'it': 507 _aDays = TS.book.oDays.aDaysIt; 508 break; 509 case 'pl': 510 _aDays = TS.book.oDays.aDaysPl; 511 break; 512 default: 513 _aDays = TS.book.oDays.aDaysEn; 514 } 515 if (!isNaN(_nDaysInMonth)){ 516 _eDaySelect.children().remove(); 517 for (k=1;k<=_nDaysInMonth;k++){ 518 // console.log(eElement.id); 519 if ((month == TS.book.handleZeros(today.getMonth()+1)) && (eElement.id == "ts-checkin-month") && (currentYear == selectedYear)) { 520 if (k >= today.getDate()) { 521 _eDaySelect.append('<option value="' + TS.book.handleZeros(k) + '">' + k + '</option>'); 522 }; 523 } else { 524 _eDaySelect.append('<option value="' + TS.book.handleZeros(k) + '">' + k + '</option>'); 525 } 526 } 527 _eDaySelect.children('option').each(function(){ 528 var _eOption = $(this); 529 var _sDay = _eOption.prop('value'); 530 var _sDate = _sYearMonth + '-' + _sDay; 531 _oDate = new Date(TS.book.isoToDate(_sDate)); 532 if (_eOption.val() != 0) _eOption.prop('text', _aDays[_oDate.getDay()] + ' ' + _eOption.prop('text')); 533 }); 534 var dayCount = _eDaySelect.find('option').length;
535 _eDaySelect.prepend('<option value="0">Day</option>'); 536 if((_nSelectedIndex < 0) || (_nSelectedIndex == "") || (dayCount < _nSelectedIndex) || (_nSelectedIndex > _nDaysInMonth)) { 537 // console.log('selected_index: ' + _nSelectedIndex); 538 // console.log('days in month: ' + _nDaysInMonth); 539 // console.log('day count: ' + dayCount); 540 _nSelectedIndex = 1; 541 _eDaySelect[0].selectedIndex = 1; 542 } else { 543 _eDaySelect[0].selectedIndex = _nSelectedIndex; 544 } 545 } 546 var selectedMonth = today.getFullYear() +"-" + TS.book.handleZeros(today.getMonth()+1); 547 // if(selectedMonth == _sYearMonth) { 548 if($("#ts-checkin-day option[value="+currentDay+"]").length != 0) { 549 $("#ts-checkin-day").val(currentDay); 550 } else { 551 _eDaySelect[0].selectedIndex = 1; 552 } 553 // } 554 mobSCheckin = new Date($('#ts-checkin-date').val()); 555 mobSCheckout = new Date($('#ts-checkout-date').val()); 556 $("#inline-ci-datepicker").datepicker( "setDate", mobSCheckin); 557 $("#inline-co-datepicker").datepicker( "setDate", mobSCheckout); 558 $('#mobile-checkin-date').attr('value',$('#inline-ci-datepicker').val()); 559 $('#mobile-checkout-date').attr('value',$('#inline-co-datepicker').val()); 560 $('#in-date').html($('#inline-ci-datepicker').val()); 561 $('#out-date').html($('#inline-co-datepicker').val()); 562 TS.book.updateNightsStay(); 563 }, 564 updateNightsStay: function() { 565 var _oInDate = $('#' + TS.book.sInDateInputId).datepicker('getDate'); 566 var _oOutDate = $('#' + TS.book.sOutDateInputId).datepicker('getDate'); 567 $('.number-nights').html(TS.book.dayDiff( _oOutDate, _oInDate )); 568 }, 569 updateMobileNightsStay: function() { 570 var _oInDate = $("#inline-ci-datepicker").datepicker('getDate'); 571 var _oOutDate = $("#inline-co-datepicker").datepicker('getDate'); 572 $('.number-nights-mobile').html(TS.book.dayDiff( _oOutDate, _oInDate )); 573 }, 574 /* 575 helper function - accepts date as string YYYY-MM = returns number of days in that month 576 */ 577 getDaysInMonth: function(sYearMonth){ 578 //console.log('Year Month:' + sYearMonth); 579 //console.log(new Date(sYearMonth.split('-',2)[0], sYearMonth.split('-',2)[1], 0).getDate()); 580 return new Date(sYearMonth.split('-',2)[0], sYearMonth.split('-',2)[1], 0).getDate(); 581 582 583 }, 584 /* 585 helper function - returns sunday (according to configuration) as date - falls back to today if sunday function is disabled 586 */ 587 getSunday: function(){ 588 var _nStep = 7 * TS.book.nSundays; 589 var _dToday = new Date(); 590 var _nDif = _nStep - _dToday.getDay(); 591 var _oDate; 592 (_nStep >= 7) ? _oDate = new Date(_dToday.getFullYear(), _dToday.getMonth(), _dToday.getDate()+_nDif, 0, 0, 0, 0) : _oDate = _dToday; 593 return(_oDate); 594 }, 595 /* 596 helper function - handle missing leading zeros 597 */ 598 handleZeros: function(nNumber){ 599 return ('0' + nNumber).slice(-2); 600 }, 601 /* 602 helper function - parse ISO 8601 local date format yyyy-mm-dd to date object 603 */ 604 isoToDate: function(sDate){ 605 var _xIso = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/, 606 _oDate = new Date(NaN), month, 607 _aParts = _xIso.exec(sDate); 608 if (_aParts){ 609 month = + _aParts[2]; 610 _oDate.setFullYear(_aParts[1], month - 1, _aParts[3]); 611 if (month != _oDate.getMonth() + 1){ 612 _oDate.setTime(NaN); 613 } 614 } 615 return _oDate; 616 }, 617 /* 618 helper function - parse date object to ISO 8601 local date format yyyy-mm-dd 619 */
620 dateToIso: function(oDate){ 621 var _sDate = ''; 622 _sDate += oDate.getFullYear() + '-'; 623 _sDate += TS.book.handleZeros(oDate.getMonth() + 1) + '-'; 624 _sDate += TS.book.handleZeros(oDate.getDate()); 625 return _sDate.toString(); 626 }, 627 /* 628 helper function - add x days to date object 629 */ 630 addDaysToDate: function(oDate, nDays){ 631 var _oDate = new Date( oDate.getFullYear(), oDate.getMonth(), oDate.getDate() + nDays ); 632 return _oDate; 633 }, 634 /* 635 helper function - add x days to iso date 636 */ 637 addDaysToIsoDate: function(sDate, nDays){ 638 var _oTempDate = new Date ( TS.book.isoToDate(sDate) ); 639 var _oDate = new Date( _oTempDate.getFullYear(), _oTempDate.getMonth(), _oTempDate.getDate() + nDays ); 640 return TS.book.dateToIso(_oDate); 641 }, 642 /* 643 helper function - checks if date is bonafied date object 644 */ 645 isDate: function(date){ 646 if ( Object.prototype.toString.call(date) !== '[object Date]' ) 647 return false; 648 return !isNaN(date.getTime()); 649 }, 650 /* 651 helper function - accepts iso date OR date object and updates checkin selects and datepicker 652 */ 653 updateCheckin: function(date){ 654 var _sDay, _sYearMonth; 655 if (TS.book.isDate(date)){ 656 // console.log(date); 657 _sDay = TS.book.dateToIso(date).split('-',3)[2]; 658 _sYearMonth = TS.book.dateToIso(date).split('-',3)[0] + '-' + TS.book.dateToIso(date).split('-',3)[1]; 659 TS.book.eCheckinInput.val(TS.book.dateToIso(date)); 660 } 661 else{ 662 // console.log(date); 663 _sDay = date.split('-',3)[2]; 664 _sYearMonth = date.split('-',3)[0] + '-' + date.split('-',3)[1]; 665 // console.log(_sDay); 666 TS.book.eCheckinInput.val(date); 667 } 668 $('select#ts-checkin-day').val(_sDay); 669 $('select#ts-checkin-month').val(_sYearMonth); 670 }, 671 updateLocation: function(loc) { 672 if ($('select#ts-location').find("option[value="+loc+"]").length == 0) { 673 loc = "all"; 674 }; 675 $('select#ts-location-mobile').val(loc); 676 $('select#ts-location').val(loc); 677 }, 678 updateHotel: function(loc) { 679 if ($('select#ts-hotel-name').find("option[value="+loc+"]").length == 0) { 680 loc = "all"; 681 }; 682 $('select#ts-hotel-name-mobile').val(loc); 683 $('select#ts-hotel-name').val(loc); 684 }, 685 updateGuests: function(loc) { 686 $('select#ts-guest').val(loc); 687 $('select#mobile-guests').val(loc); 688 }, 689 updateRoomType: function(loc) { 690 $('select#ts-room-type').val(loc); 691 $('select#ts-room-type-mobile').val(loc); 692 if (loc != "none") { 693 $('.advanced-fields').show(); 694 $('.mobile-advanced-fields').show(); 695 if ($('.mobile-search-container').is(':visible')) { 696 $('.main-content-left-container').css('margin-top', '425px'); 697 } else { 698 $('.main-content-left-container').css('margin-top', '320px'); 699 } 700 } 701 }, 702 updateStudent: function(loc) { 703 if (loc == "Y") { 704 $('#ts-student-discount').prop('checked', true); 705 $('#ts-student-discount-mobile').prop('checked', true); 706 } 707 }, 708 updateCity: function(loc) { 709 if (loc != "undefined") { 710 $('select#ts-city').val(loc); 711 $('select#ts-city-mobile').val(loc); 712 }; 713 }, 714 updateHotelType: function(loc) { 715 if (loc != "undefined") { 716 $('select#ts-hotel-type').val(loc); 717 $('select#ts-hotel-type-mobile').val(loc); 718 }; 719 }, 720 updateAttraction: function(loc) { 721 if (loc != "undefined") { 722 $('#ts-attraction').val(loc); 723 $('#ts-attraction-mobile').val(loc); 724 }; 725 }, 726 updateAttractionCode: function(loc) { 727 // console.log(loc); 728 if (loc != "undefined") { 729 $('#HID_SELECTEDHOTEL_val').val(loc); 730 }; 731 }, 732 /* 733 helper function - accepts iso date OR date object and updates checkout selects and datepicker via hidden input
733s 734 */ 735 updateCheckout: function(date){ 736 var _sDay, _sYearMonth, _mDate; 737 if (TS.book.isDate(date)){ 738 _sDay = TS.book.dateToIso(date).split('-',3)[2]; 739 _sYearMonth = TS.book.dateToIso(date).split('-',3)[0] + '-' + TS.book.dateToIso(date).split('-',3)[1]; 740 TS.book.eCheckoutInput.val(TS.book.dateToIso(date)); 741 } 742 else{ 743 _sDay = date.split('-',3)[2]; 744 _sYearMonth = date.split('-',3)[0] + '-' + date.split('-',3)[1]; 745 TS.book.eCheckoutInput.val(date); 746 } 747 // console.log(_sDay); 748 $('select#ts-checkout-day').val(_sDay); 749 $('select#ts-checkout-month').val(_sYearMonth); 750 }, 751 /* 752 helper function - accepts iso date or date object - returns day and year/month 753 */ 754 dateToDayYearMonth: function(date){ 755 var _sDay, _sYearMonth; 756 if (TS.book.isDate(date)){ 757 _sDay = TS.book.dateToIso(date).split('-',3)[2]; 758 _sYearMonth = TS.book.dateToIso(date).split('-',3)[0] + '-' + TS.book.dateToIso(date).split('-',3)[1]; 759 } 760 else{ 761 _sDay = date.split('-',3)[2]; 762 _sYearMonth = date.split('-',3)[0] + '-' + date.split('-',3)[1]; 763 } 764 return [_sDay, _sYearMonth]; 765 }, 766 /* 767 called by date and month/year select element change 768 if valid date selections exists - update datepickers (via hidden inputs) from respective select values 769 if checkin >= checkout and user has changed checkin - then move checkout to checkin + 1 (this allows user to set checkout date before checking date) 770 if no checkout date has been selected - set checkout date to checkin date + 1 day 771 */ 772 updateDatePicker: function(element){ 773 var _sInMonthYear = $('select#' + TS.book.sInMonthYearId).val(); 774 var _sInDay = $('select#' + TS.book.sInDayId).val(); 775 var _sOutMonthYear = $('select#' + TS.book.sOutMonthYearId).val(); 776 var _sOutDay = $('select#' + TS.book.sOutDayId).val(); 777 var _sInDate = _sInMonthYear + '-' + _sInDay; 778 var _sOutDate = _sOutMonthYear + '-' + _sOutDay; 779 var _sType = element.id.split('-',2)[1]; 780 if (_sType == "checkout") { 781 TS.book.checkoutUpdated = true; 782 }; 783 if ((_sInMonthYear != '0') && (_sInDay != '0')){ 784 TS.book.eCheckinInput.val(_sInDate); 785 } 786 if ((_sOutMonthYear != '0') && (_sOutDay != '0')){ 787 if (_sType == 'checkin'){ 788 if (!TS.book.checkoutUpdated) { 789 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 790 TS.book.rebuildDays($('select#ts-checkout-month')[0]); 791 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 792 } else if(TS.book.isoToDate(_sInDate).getTime() >= TS.book.isoToDate(_sOutDate).getTime() ) { 793 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 794 TS.book.rebuildDays($('select#ts-checkout-month')[0]); 795 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 796 } 797 } 798 else{ 799 if (TS.book.bAlwaysUpdateCheckout){ 800 if (_sType == "checkout") { 801 TS.book.updateCheckout( _sOutDate ); 802 } else { 803 if (!TS.book.checkoutUpdated) { 804 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 805 } else if(TS.book.isoToDate(_sInDate).getTime() >= TS.book.isoToDate(_sOutDate).getTime() ) { 806 TS.book.updateCheckout( TS.book.addDaysToIsoDate(_sInDate,1) ); 807 TS.book.rebuildDays($('select#ts-checkout-month')[0]); 808 } 809 } 810 TS.book.rebuildDays($('select#ts-checkout-month')[0]); 811 } 812 else{ 813 TS.book.updateCheckout( _sOutDate ); 814 } 815 } 816 } 817 TS.book.storeDates(); 818 }, 819 /* 820 called by datepicker onClose 821 updates associated day and month/year select elements 822 */ 823 datepickerUpdateSelects: function(date, instance){ 824 // console.log('hello'); 825 _sDay = TS.book.dateToDayYearMonth(date)[0]; 826 _sYearMonth = TS.book.dateToDayYearMonth(date)[1]; 827 _sType = instance.id.split('-',2)[1]; 828 // console.log('hello'); 829 if (_sType == 'checkin'){ 830 TS.book.updateCheckin( TS.book.isoToDate(date) ); 831 if (TS.book.bAlwaysUpdateCheckout){ 832 if (!TS.book.checkoutUpdated) { 833 TS.book.updateCheckout( TS.book.addDaysToIsoDate(date,1) ); 834 } else if(TS.book.isoToDate(TS.book.eCheckinInput.val()).getTime() >= TS.book.isoToDate(TS.book.eCheckoutInput.val()).getTime() ) { 835 TS.book.updateCheckout( TS.book.addDaysToIsoDate(date,1) ); 836 } 837 } 838 if (!TS.book.checkoutUpdated) { 839 TS.book.updateCheckout( TS.book.addDaysToIsoDate(date,1) ); 840 } else if(TS.book.isoToDate(TS.book.eCheckinInput.val()).getTime() >= TS.book.isoToDate(TS.book.eCheckoutInput.val()).getTime()) { 841 TS.book.updateCheckout( TS.book.addDaysToIsoDate(date,1) ); 842 } 843 } else { 844 TS.book.checkoutUpdated = true; 845 TS.book.updateCheckout(TS.book.isoToDate(date)); 846 TS.book.updateCheckout(date); 847 } 848 TS.book.storeDates(); 849 TS.book.updateNightsStay(); 850 }, 851 /* 852 helper function - calculate difference between 2 date objects in days 853 */ 854 dayDiff: function(oInDate, oOutDate){ 855 return Math.round((oInDate-oOutDate)/(1000*60*60*24)); 856 }, 857 /* 858 helper function - test submitted form values 859 */ 860 fakeFormSubmit: function(){ 861 var _oInDate = $('#' + TS.book.sInDateInputId).datepicker('getDate'); 862 var _oOutDate = $('#' + TS.book.sOutDateInputId).datepicker('getDate');
863 var _sInDateHiddenInputs = TS.book.eCheckinInput.val(); 864 var _sOutDateHiddenInputs = TS.book.eCheckoutInput.val(); 865 var _sMsg = ''; 866 _sMsg += '# nights:\n\n'; 867 _sMsg += TS.book.dayDiff( _oOutDate, _oInDate ) + '\n\n'; 868 _sMsg += 'Datepicker checkin and checkout dates:\n\n'; 869 _sMsg += _oInDate + '\n'; 870 _sMsg += _oOutDate + '\n\n'; 871 _sMsg += 'Hidden inputs checkin and checkout dates:\n\n'; 872 _sMsg += _sInDateHiddenInputs + '\n'; 873 _sMsg += _sOutDateHiddenInputs + '\n\n'; 874 _sMsg += 'Number of guests:\n\n'; 875 _sMsg += $('#' + TS.book.sNumberGuestsId).val() + '\n\n'; 876 _sMsg += 'Additional data from hidden inputs:\n\n'; 877 $('.ts-extra-data').each(function(){ 878 _sMsg += $(this).attr('name') + ' = ' + $(this).val() + '\n'; 879 }); 880 alert('>>>> FORM SUBMITTED SUCCESSFULLY !!\n\n' + _sMsg); 881 }, 882 realFormSubmit: function(){ 883 var _sUrl = ''; 884 var _sCurrentUrl = window.location.toString(); 885 //var _sCurrentBaseUrl = _sCurrentUrl.substring(0, _sCurrentUrl.indexOf('?')); 886 var _sInMonth = parseInt(TS.book.eCheckinInput.val().split('-',3)[1], 10) - 1; 887 var _sOutMonth = parseInt(TS.book.eCheckoutInput.val().split('-',3)[1], 10) - 1; 888 var _oInDate = $('#' + TS.book.sInDateInputId).datepicker('getDate'); 889 var _oOutDate = $('#' + TS.book.sOutDateInputId).datepicker('getDate'); 890 var _FullOutDate = $.datepicker.formatDate('yy-m-dd', new Date(TS.book.eCheckoutInput.val())); 891 var _FullInDate = $.datepicker.formatDate('yy-m-dd', new Date(TS.book.eCheckinInput.val())); 892 var numGuests = TS.book.eNumberGuests.val(); 893 var roomDrop = $('#ts-room-type').val(); 894 var studentDiscount = $('#ts-student-discount').prop("checked") ? "Y" : "N"; 895 var roomType; 896 if (roomDrop != "none") { 897 if (roomDrop == "All") { 898 roomType = "GRT1,GRT2,GRT3,GRT4,GRT5,GRT6,GRT8,GRT9"; 899 } else { 900 roomType = roomDrop; 901 } 902 } else { 903 if (numGuests == "1") { 904 roomType = "GRT1,GRT2,GRT3,GRT6"; 905 } else if (numGuests == "2") { 906 roomType = "GRT2,GRT3,GRT6"; 907 } else if (numGuests == "3") { 908 roomType = "GRT3,GRT4,GRT5,GRT6"; 909 } else if (numGuests == "4") { 910 roomType = "GRT2,GRT3,GRT5,GRT6,GRT8"; 911 } else if (numGuests == "5") { 912 roomType = "GRT2,GRT3,GRT4,GRT5,GRT6,GRT8"; 913 } else if (numGuests == "6") { 914 roomType = "GRT2,GRT3,GRT4,GRT5,GRT6,GRT8"; 915 } else if (numGuests == "7") { 916 roomType = "GRT2,GRT3,GRT4,GRT5,GRT6,GRT8"; 917 } else if (numGuests == "8") { 918 roomType = "GRT2,GRT3,GRT4,GRT5,GRT6,GRT8"; 919 } else if (numGuests == "9") { 920 roomType = "GRT2,GRT3,GRT4,GRT5,GRT6,GRT8"; 921 } else if (numGuests >= "10") { 922 roomType = "GRT1,GRT2,GRT3,GRT4,GRT5,GRT6,GRT8,GRT9"; 923 } 924 } 925 if ($('#ts-location').val() != null) { 926 if ($('#ts-location').val() == "all") { 927 document.forms['styleForm'].selLocation.value = "%"; 928 } else { 929 document.forms['styleForm'].selLocation.value = $('#ts-location').val(); 930 } 931 document.forms['styleForm'].selLocationNm.value = escape($('#ts-location').find('option:selected').text()); 932 }; 933 if ($('#ts-hotel-name').val() != null) { 934 document.forms['styleForm'].hotelName.value = escape($('#ts-hotel-name').find('option:selected').text()); 935 if ($('#ts-hotel-name').val() == "all") { 936 document.forms['styleForm'].hotelCode.value = "%"; 937 } else { 938 document.forms['styleForm'].hotelCode.value = escape($('#ts-hotel-name').val()); 939 } 940 if ($('#ts-hotel-name').val() != "all" && roomDrop == "none") { 941 roomType = "GRT1,GRT2,GRT3,GRT4,GRT5,GRT6,GRT8,GRT9"; 942 } 943 }; 944 if ($('#ts-hotel-type').val() != null) { 945 document.forms['styleForm'].selCategoryName.value = $('#ts-hotel-type').find('option:selected').text(); 946 document.forms['styleForm'].selAmenity.value = $('#ts-hotel-type').val(); 947 if (($('#ts-hotel-type').val() == "HT45") || ($('#ts-hotel-type').val() == "HT4") || ($('#ts-hotel-type').val() == "HT5")) { 948 roomType = "GRT1,GRT2,GRT3,GRT4,GRT5,GRT6,GRT8,GRT9"; 949 } 950 }; 951 if ($('#ts-city').val() != null) { 952 document.forms['styleForm'].selCity.value = $('#ts-city').find('option:selected').text(); 953 document.forms['styleForm'].cityCd.value = $('#ts-city').val(); 954 }; 955 _sUrl += TS.book.sSubmissionUrl; 956 _sUrl += '?afCd=' + document.forms['styleForm'].afftCode.value; 957 _sUrl += '&afTp=' + document.forms['styleForm'].afftType.value; 958 _sUrl += '&NoAd=' + TS.book.eNumberGuests.val();
959 _sUrl += '&NoCh=' + document.forms['styleForm'].cmbNoChi.value; 960 _sUrl += '&NoNgt=' + TS.book.dayDiff( _oOutDate, _oInDate ); 961 _sUrl += '&stPr=0'; 962 _sUrl += '&edPr=999999'; 963 _sUrl += '&PrRg=All%20Prices'; 964 _sUrl += '&AcNm=' + document.forms['styleForm'].hotelName.value; 965 _sUrl += '&Grp=' + escape(document.forms['styleForm'].selGroup.value); 966 _sUrl += '&NoRm=' + document.forms['styleForm'].cmbNoOfRooms.value; 967 _sUrl += '&Ct=CY1'; 968 _sUrl += '&InDt=' + TS.book.eCheckinInput.val().split('-',3)[2]; 969 _sUrl += '&InMn=' + (parseInt(TS.book.eCheckinInput.val().split('-',3)[1]) -1); 970 _sUrl += '&InYr=' + TS.book.eCheckinInput.val().split('-',3)[0]; 971 _sUrl += '&OtDt=' + TS.book.eCheckoutInput.val().split('-',3)[2]; 972 _sUrl += '&prSc=' + escape(_sCurrentUrl); 973 _sUrl += '&OtMn=' + (parseInt(TS.book.eCheckoutInput.val().split('-',3)[1]) -1); 974 _sUrl += '&OtYr=' + TS.book.eCheckoutInput.val().split('-',3)[0]; 975 _sUrl += '&htCd=' + escape(document.forms['styleForm'].hotelCode.value); 976 _sUrl += '&amty=' + escape(document.forms['styleForm'].landingHotelType.value); 977 _sUrl += '&slCt=' + escape(document.forms['styleForm'].selCity.value); 978 _sUrl += '&CtgNm=' + escape(document.forms['styleForm'].selCategoryName.value); 979 _sUrl += '&slCat=' + escape(document.forms['styleForm'].selCategory.value); 980 _sUrl += '&Dcn1=' + studentDiscount; 981 _sUrl += '&Dcn2=N&mxP=' + document.forms['styleForm'].maxpPrevalue.value; 982 _sUrl += '&slLoc=' + escape(document.forms['styleForm'].slLoc.value); 983 _sUrl += '&sLNm=' + document.forms['styleForm'].sLNm.value; 984 _sUrl += '&flB=C&Sor=W'; 985 _sUrl += '&vInf=' + escape(document.forms['styleForm'].visitorInfo.value); 986 _sUrl += '&language=' + escape(document.forms['styleForm'].language.value); 987 _sUrl += '&country=' + escape(document.forms['styleForm'].country.value); 988 _sUrl += '&InDate=' + _FullInDate; 989 _sUrl += '&OutDate=' + _FullOutDate; 990 _sUrl += '&NoAdTs=' + (parseInt(TS.book.eNumberGuests.val()) -1); 991 _sUrl += '&cny=' + escape(document.forms['styleForm'].cny.value); 992 _sUrl += '&roomtype=&browser=IE' 993 _sUrl += '&Utp=' + escape(document.forms['styleForm'].Utp.value); 994 _sUrl += '&id=TS&sgamty=-&bcd='; 995 _sUrl += '&RmTyD=&RmTyp=' + escape(roomType); 996 if (document.getElementById("HID_SELECTEDHOTEL_val")) { 997 if (document.getElementById("HID_SELECTEDHOTEL_val").value != "") { 998 var tempattdetails = ATTRACTIONSDETAILS[document.getElementById("HID_SELECTEDHOTEL_val").value]; 999 attName = temp_ATTRACTION_NAME; 1000 latiVal = tempattdetails.geocodes.lat; 1001 longVal = tempattdetails.geocodes.lon; 1002 attid = document.getElementById("HID_SELECTEDHOTEL_val").value; 1003 attrdp = tempattdetails.distance[0]; 1004 attrds = tempattdetails.distance[1]; 1005 gsortval = tempattdetails.sortby; 1006 _sUrl += '&geolat=' + latiVal; 1007 _sUrl += '&geolon=' + longVal; 1008 _sUrl += '&geolocation=' + escape(attName); 1009 _sUrl += '&atCd=' + document.getElementById("HID_SELECTEDHOTEL_val").value; 1010 _sUrl += '&rdp=' + attrdp; 1011 _sUrl += '&rds=' + attrds; 1012 _sUrl += '&gsortval=distance'; 1013 disableButton('ts-book-submit'); 1014 // console.log(attName); 1015 window.location = _sUrl; 1016 } else { 1017 alert('Sorry we could not find this London attraction\nPlease select an attraction from the list and search again'); 1018 } 1019 } else { 1020 disableButton('ts-book-submit'); 1021 window.location = _sUrl; 1022 } 1023 } 1024 }; 1025 $('#ts-guest, #mobile-guests').change(function (e) { 1026 if ($(this).val() == 21) { 1027 window.location = "http://book.travelstay.com/en/group-enquiry.htm"; 1028 }; 1029 }); 1030//Mobile Date Picker 1031// $(function() { 1032function loadMobileCal() { 1033 $('#inline-ci-datepicker').datepicker({ 1034 autoClose: true, 1035 dateFormat:"D d M yy", 1036 minDate: 0, 1037 maxDate:"+2Y +1D", 1038 setDate:"0", 1039 onSelect: function (selectedDate) { 1040 var minDate = new Date(Date.parse(selectedDate)); 1041 var coDate = $("#inline-co-datepicker").datepicker('getDate'); 1042 minDate.setDate(minDate.getDate() + 1); 1043 $("#inline-co-datepicker").datepicker("option", "minDate", minDate); 1044 // if (!sDocCookie) { 1045 if (!TS.book.checkoutUpdated || coDate < minDate) { 1046 $("#inline-co-datepicker").datepicker('setDate', minDate); 1047 $('#mobile-checkout-date').attr('value',$('#
1047inline-co-datepicker').val()); 1048 } 1049 // } 1050 storeMobileCookie; 1051 $('#mobile-checkin-date').attr('value',$('#inline-ci-datepicker').val()); 1052 $('#in-date').html($('#inline-ci-datepicker').val()); 1053 $('#out-date').html($('#inline-co-datepicker').val()); 1054 $(this).hide(400); 1055 $('#ts-checkin-date').attr('value',TS.book.dateToIso(new Date(Date.parse(selectedDate)))); 1056 $('#ts-checkout-date').attr('value',TS.book.dateToIso(new Date(Date.parse($('#inline-co-datepicker').val())))); 1057 TS.book.updateMobileNightsStay(); 1058 } 1059 }); 1060 $('#inline-co-datepicker').datepicker({ 1061 autoClose: true, 1062 dateFormat:"D d M yy", 1063 defaultDate: +1, 1064 minDate: "+1D", 1065 maxDate:"+2Y +1D", 1066 setDate:"1", 1067 onSelect: function (selectedDate) { 1068 TS.book.checkoutUpdated = true; 1069 var maxDate = new Date(Date.parse(selectedDate)); 1070 $('#mobile-checkout-date').attr('value',$('#inline-co-datepicker').val()); 1071 $('#in-date').html($('#inline-ci-datepicker').val()); 1072 $('#out-date').html($('#inline-co-datepicker').val()); 1073 storeMobileCookie(); 1074 $(this).hide(400); 1075 $('#ts-checkout-date').attr('value',TS.book.dateToIso(new Date(Date.parse(selectedDate)))); 1076 TS.book.updateMobileNightsStay(); 1077 } 1078 }); 1079 $('#mobile-checkin-date').attr('value',$('#inline-ci-datepicker').val()); 1080 $('#mobile-checkout-date').attr('value',$('#inline-co-datepicker').val()); 1081 mobSCheckin = new Date($('#ts-checkin-date').val()); 1082 mobSCheckout = new Date($('#ts-checkout-date').val()); 1083 $("#inline-ci-datepicker").datepicker( "setDate", mobSCheckin); 1084 $("#inline-co-datepicker").datepicker( "setDate", mobSCheckout); 1085 $('#in-date').html($('#inline-ci-datepicker').val()); 1086 $('#out-date').html($('#inline-co-datepicker').val()); 1087 $('#mobile-checkin-date').attr('value',$('#inline-ci-datepicker').val()); 1088 $('#mobile-checkout-date').attr('value',$('#inline-co-datepicker').val()); 1089 TS.book.updateMobileNightsStay(); 1090} 1091 $('#mobile-checkin-date').click(function(event) { 1092 $('.ci-datepicker-container').show(400); 1093 $('#inline-ci-datepicker').show(400); 1094 $('.co-datepicker-container').hide(); 1095 if ($('.mobile-advanced-fields').is(':visible')) { 1096 $('.main-content-left-container').css('margin-top', '630px'); 1097 } else { 1098 $('.main-content-left-container').css('margin-top', '535px'); 1099 } 1100 }); 1101 $('#mobile-checkout-date').click(function(event) { 1102 $('.co-datepicker-container').show(400); 1103 $('#inline-co-datepicker').show(400); 1104 $('.ci-datepicker-container').hide(); 1105 if ($('.mobile-advanced-fields').is(':visible')) { 1106 $('.main-content-left-container').css('margin-top', '630px'); 1107 } else { 1108 $('.main-content-left-container').css('margin-top', '535px'); 1109 } 1110 }); 1111 $('#inline-ci-datepicker').change(function(){ 1112 $('#mobile-checkin-date').attr('value',$(this).val()); 1113 var checkInDate = $("#inline-ci-datepicker").datepicker('getDate'); 1114 var checkOutDate = $("#inline-co-datepicker").datepicker('getDate'); 1115 var dayDifference = dayDiff(checkInDate, checkOutDate); 1116 if(dayDifference < 1) { 1117 var newCheckout = new Date(Date.parse(checkInDate)); 1118 } 1119 TS.book.updateNightsStay(); 1120 }); 1121 $('#inline-co-datepicker').change(function(){ 1122 $('#mobile-checkout-date').attr('value',$(this).val()); 1123 TS.book.updateNightsStay(); 1124 }); 1125 var sDocCookie = TS.cookie.read(TS.book.sCookieName); 1126 if (sDocCookie){ 1127 mobSCheckin = new Date(sDocCookie.split(',',3)[0]); 1128 mobSCheckout = new Date(sDocCookie.split(',',3)[1]); 1129 $("#inline-ci-datepicker").datepicker( "setDate", mobSCheckin ); 1130 $("#inline-co-datepicker").datepicker( "setDate", mobSCheckout ); 1131 $('#mobile-checkin-date').attr('value',$('#inline-ci-datepicker').val());
1132 $('#mobile-checkout-date').attr('value',$('#inline-co-datepicker').val()); 1133 } 1134 function storeCookie() { 1135 TS.book.storeDates(); 1136 } 1137 function storeMobileCookie() { 1138 TS.book.checkoutUpdated = true; 1139 var _oInDate = $('#inline-ci-datepicker').datepicker('getDate'); 1140 var _oOutDate = $('#inline-co-datepicker').datepicker('getDate'); 1141 var formattedCookieIn = $.datepicker.formatDate('yy-mm-dd', _oInDate); 1142 var formattedCookieOut = $.datepicker.formatDate('yy-mm-dd', _oOutDate); 1143 var numGuests = $('#mobile-guests').val(); 1144 var studentDiscount = $('#ts-student-discount-mobile').prop("checked") ? "Y" : "N"; 1145 var exisitingCooking = TS.cookie.read(TS.book.sCookieName); 1146 1147 if (sDocCookie){ 1148 savedCity = sDocCookie.split(',',11)[7]; 1149 savedLocation = sDocCookie.split(',',11)[2]; 1150 savedHotel = sDocCookie.split(',',11)[6]; 1151 savedHotelType = sDocCookie.split(',',11)[8]; 1152 savedAttraction = sDocCookie.split(',',11)[9]; 1153 savedAttractionCode = sDocCookie.split(',',11)[10]; 1154 if ($('#ts-city-mobile').val() != null) { 1155 savedCity = $('#ts-city-mobile').val(); 1156 }; 1157 if ($('#ts-hotel-type-mobile').val() != null) { 1158 savedHotelType = $('#ts-hotel-type-mobile').val(); 1159 }; 1160 if ($('#ts-attraction-mobile').val() != null) { 1161 savedAttraction = $('#ts-attraction-mobile').val(); 1162 savedAttractionCode = $('#HID_SELECTEDHOTEL_val').val(); 1163 }; 1164 if ($('#ts-hotel-name').val() != null) { 1165 savedHotel = $('#ts-hotel-name').val(); 1166 }; 1167 if ($('#ts-location-mobile').val() != null) { 1168 savedLocation = $('#ts-location-mobile').val(); 1169 }; 1170 var cookieInfo = TS.book.eCheckinInput.val() + ',' + TS.book.eCheckoutInput.val() + ',' + savedLocation + ',' + $('#ts-room-type-mobile').val() + ',' + studentDiscount + ',' + TS.book.eNumberGuests.val() + ',' + savedHotel + ',' + savedCity + ',' + savedHotelType + ',' + savedAttraction + ',' + savedAttractionCode; 1171 } else { 1172 var cookieInfo = formattedCookieIn + ',' + formattedCookieOut + ',' + $('#ts-location-mobile').val() + ',' + $('#ts-room-type-mobile').val() + ',' + studentDiscount + ',' + numGuests + ',' + $('#ts-hotel-name-mobile').val() + ',' + $('#ts-city-mobile').val() + ',' + $('#ts-hotel-type-mobile').val() + ',' + $('#ts-attraction-mobile').val() + ',' + $('#HID_SELECTEDHOTEL_val').val(); 1173 } 1174 TS.cookie.create(TS.book.sCookieName, cookieInfo); 1175 } 1176 1177 function dayDiff(oInDate, oOutDate){ 1178 return (oOutDate-oInDate)/(1000*60*60*24); 1179 } 1180 1181 $('.auto-update').change(function (e) { 1182 storeCookie(); 1183 }); 1184 $('.mobile-auto-update').change(function (e) { 1185 storeMobileCookie(); 1186 }); 1187}); 1188// }); 1189function otherCity() { 1190 var bookingURL = "http://book.travelstay.com/Search_now.htm?"; 1191 var setLang = "set-lang=" + escape(document.forms['styleForm'].language.value); 1192 var setCur = "&set-currency=" + escape(document.forms['styleForm'].cny.value); 1193 bookingURL = bookingURL + setLang + setCur; 1194 window.location = bookingURL; 1195} 1196function disableButton(buttonID) { 1197 // console.log(buttonID); 1198 var languageName = document.styleForm.language.value; 1199 if (buttonID == "mobile-booking-submit") { 1200 $('#' + buttonID).hide(); 1201 $('#mobile-booking-pressed').css('display', 'block'); 1202 } else { 1203 if(languageName.toLowerCase() == "en") 1204 { 1205 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>Searching...'); 1206 } 1207 else if (languageName.toLowerCase() == "es") 1208 { 1209 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>Buscando...'); 1210 } 1211 else if (languageName.toLowerCase() == "de") 1212 { 1213 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>Suche...'); 1214 } 1215 else if (languageName.toLowerCase() == "fr") 1216 { 1217 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>Recherche en cours...'); 1218 } 1219 else if (languageName.toLowerCase() == "it") 1220 { 1221 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>Ricerca in corso...'); 1222 } 1223 else if (languageName.toLowerCase() == "pl") 1224 { 1225 $('#' + buttonID).html('<i class="fa fa-spinner fa-pulse searching-icon"></i>WyszukujÄ...'); 1226 } 1227 $('#' + buttonID).css('cursor', 'default'); 1228 $('#' + buttonID).prop('href', 'javascript:void(0)'); 1229 $('#' + buttonID).prop('id', ''); 1230 } 1231 $('#' + buttonID).click(function () {return false;}); 1232} 1233function gup( name ){ 1234 name = name.replace(/[\\[]/,'\\\\[').replace(/[\\]]/,'\\\\]'); 1235 var regexS = '[\\?&]'+name+'=([^&#]*)'; var regex = new RegExp( regexS ); 1236 var results = regex.exec( window.location.href ); 1237 if( results == null ) { 1238 return null; 1239 }else{ 1240 return results[1]; 1241 } 1242} 1243function loadCurrencyCode(){ 1244 var currencycode = getCookie('cur'); 1245 var curField = $("input[name='cny']"); 1246 if (currencycode != "") { 1247 curField.val(currencycode); 1248 }; 1249} 1250function getUrlParameter(sParam) 1251{ 1252 var sPageURL = window.location.search.substring(1); 1253 var sURLVariables = sPageURL.split('&'); 1254 for (var i = 0; i < sURLVariables.length; i++) 1255 { 1256 var sParameterName = sURLVariables[i].split('='); 1257 if (sParameterName[0] == sParam) 1258 { 1259 return sParameterName[1]; 1260 } 1261 } 1262} 1263jQuery(window).bind("pageshow", function(event) { 1264 if (event.originalEvent.persisted) { 1265 window.location.reload() 1266 } 1267}); 1268jQuery('#ts-city, #ts-city-mobile').on('change', function () { 1269 if ($(this).val() == "SAC") { 1270 window.location = "http://book.travelstay.com/Search_now.htm?set-lang="+escape(document.forms['styleForm'].language.value)+"&set-currency="+escape(document.forms['styleForm'].cny.value); 1271 } 1272});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.