// =============================================================================================== // class: EG_BookingEngine() // --------------------------- // // Main class for the booking engine. Recommended to use strict mode on the HTML page that // contains the calendar script // =============================================================================================== function EG_BookingEngine(){ // ---------------------------------------------------------------------------------------------------- // function: render() // ---------------------------------------------------------------------------------------------------- this.render = function(){ var output = '' + '' + ' ' + '' + '' + '' + '
' + '' + '' + '' + '' + '' + '' + '' + '
' + '
' + 'Save on the hotel. Spend on the fun. ' + '
' + '
Accommodation from budgetplaces
' + '
' + '
' + '' + '' + '
' + '
' + '' + '' + '
' + '' + '
' + '' + '' + '' + '
' + '' + '
' + '' + '' + '
' + '' + '' + '' + '' + '
' + '' ; document.writeln(output); } } // -------------------------------------------------------------------------------------------------- // function: setFocus() // -------------------------------------------------------------------------------------------------- function setFocus(dateField){ document.getElementById(dateField).focus(); } function affiliateCalendar(dateField, arrivalDate, departureDate, siteRoot, dateFormat,thisField){ displayCalendarV2(document.getElementById(dateField), arrivalDate, departureDate, siteRoot, dateFormat, thisField); } var be = new EG_BookingEngine(); be.render(); // -------------------------------------------------------------------------------------------------- // function: validateForm() // // -------------------------------------------------------------------------------------------------- function validateForm(myForm) { var booking_err1 = ''; var booking_err2 = ''; var booking_err3 = ''; var booking_err4 = ''; var booking_err5 = ''; // PREPARE ARRIVAL el = myForm.elements['egarrival_day']; if( el != null ){ myForm.elements['ARRIVAL'].value = el.options[el.selectedIndex].value; el = myForm.egarrival_yearmonth; myForm.elements['ARRIVAL'].value += "/" + el.options[el.selectedIndex].value; } // PREPARE DEPARTURE el = myForm.elements['egdeparture_day']; if( el != null ){ myForm.elements['DEPARTURE'].value = el.options[el.selectedIndex].value; el = myForm.egdeparture_yearmonth; myForm.elements['DEPARTURE'].value += "/" + el.options[el.selectedIndex].value; } // START VALIDATION var re = /^(\d+)\/(\d+)\/(\d+)$/; var dt_arr, dt_dep; var dt_today = new Date(); var dt_nextyr = new Date(dt_today - 0 + (1000*60*60*24*365)); if (!myForm.ARRIVAL.value.match(/^\d+\/\d+\/\d+$/)) { alert(booking_err1); return false; } if (!myForm.DEPARTURE.value.match(/^\d+\/\d+\/\d+$/)) { alert(booking_err2); return false; } match = re.exec(myForm.ARRIVAL.value); dt_arr = new Date(match[3],match[2]-1,match[1]); match = re.exec(myForm.DEPARTURE.value); dt_dep = new Date(match[3],match[2]-1,match[1]); num_nights = (dt_dep-dt_arr)/1000/60/60/24; if (dt_arr <= dt_today) { alert(booking_err3); return false; } if (dt_arr > dt_nextyr) { alert(booking_err4); return false; } if (dt_dep <= dt_arr) { alert(booking_err5); return false; } return true; } // -------------------------------------------------------------------------------------------------- // function: submitForm() // // -------------------------------------------------------------------------------------------------- function submitForm() { var ret = false; if (validateForm(frm)) { displayWindow = window.open('', "bookingWin", "scrollbars=1,menubar=0,toolbar=0,location=0,status=0,width=700,height=500"); if( displayWindow ){ ret = true; } else{ alert("WARNING! Your browser blocks popups."); } } return ret; } function open_eg_booking(obj){ var engine_div = null; while( obj.parentNode != null ){ if( obj.id.toLowerCase().indexOf("eap_be") > -1 ) { engine_div = obj; break; }; obj = obj.parentNode; } if( engine_div == null ){ alert("open_eg_booking() fails"); return; } var qstring = "?"; var affiliate = "207"; // get input controls var inp_list = engine_div.getElementsByTagName("input"); for( i = 0; i < inp_list.length; i++){ if( inp_list[i].type.toLowerCase() != 'button' ){ qstring += inp_list[i].name + '=' + inp_list[i].value.toLowerCase() + "&"; } } // get