var Common_Scripts_TravelDates_VldCheckIn = 'Please select a valid Check-in Date.' var Common_Scripts_TravelDates_CheckInPast = 'The Check-in Date you have selected is in the past.' var Common_Scripts_TravelDates_VldCheckOut = 'Please select a valid Check-out Date.' var Common_Scripts_TravelDates_StayTooLong = 'Your period of stay should be not longer than 25 nights.\n\nIf you wish to book for more than 25 nights, please send us an e-mail with your request.' var Common_Scripts_TravelDates_OutAfterIn = 'Please ensure that the Check-out Date is after the Check-in Date.' var Common_Scripts_TravelDates_SelectDates = 'Please select your Travel Dates.' /* requires initialisation of the following variables: curDay, curMonth (0-11), curYear short month name array arrMonth requires setting dates cookie as below BEFORE instantializing the TravDates object: SetDatesCookie(30, 12, 1899, 30, 12, 1899) */ if (typeof(dateMask) == "undefined") dateMask = "d|m|y|-" if (typeof(wkdArray) == "undefined") var wkdArray = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") // TRAVEL DATES OBJECT START //travel dates object constructor function TravDates(inYCtl, inMCtl, inDCtl, inDayCtl, outYCtl, outMCtl, outDCtl, outDayCtl, lenStayID, startBlank, numYears) { if (numYears == null) numYears = 3 //default number of years for the calendar //properties this.inYCtl = inYCtl this.inMCtl = inMCtl this.inDCtl = inDCtl this.inDayCtl = inDayCtl this.outYCtl = outYCtl this.outMCtl = outMCtl this.outDCtl = outDCtl this.outDayCtl = outDayCtl this.lenStayID = lenStayID //methods this.SetDef = SetDefDates this.Validate = ValidateDates this.GetDate = GetSelDate this.SetDate = SetSelDate this.SetLenStay = SetLenStay this.SetDaysOfWeek = SetDay this.resetDate = ResetDate //populate select boxes if (startBlank) { var presOpt = 0 } else { var presOpt = -1 } populateDay(inDCtl, presOpt) populateMonth(inMCtl, presOpt) populateYear(inYCtl, presOpt, numYears) populateDay(outDCtl, presOpt) populateMonth(outMCtl, presOpt) populateYear(outYCtl, presOpt, numYears) //set default values this.SetDef(startBlank) //instatialise calendar object if (!document.layers) { cal = new Calendar(numYears, SetCalDate) window.onfocus = new Function("if (cal.win) cal.win.close()") } //populate day select box function populateDay(ctl, presOpt) { clearSelect(ctl, presOpt) var newOpt for (var i = 1 + presOpt; i < 32 + presOpt; i++) { newOpt = i - presOpt ctl[i] = new Option(newOpt, newOpt) } } //populate month select box function populateMonth(ctl, presOpt) { clearSelect(ctl, presOpt) for (var i = 1 + presOpt; i < 13 + presOpt; i++) ctl[i] = new Option(arrMonth[i-1-presOpt], i-presOpt) } //populate year select box function populateYear(ctl, presOpt, numYears) { clearSelect(ctl, presOpt) var newOpt for (var i = 1 + presOpt; i <= numYears + presOpt; i++) { newOpt = i + curYear - 1 - presOpt ctl[i] = new Option(newOpt, newOpt) } } //clear options of select control function clearSelect(ctl, presOpt) { for (var i = ctl.options.length - 1; i > presOpt; i--) ctl.options[i] = null } } //set default dates function SetDefDates(startBlank) { var defInD, defInM, defInY, defOutD, defOutM, defOutY if ( GetQSVal("inDay") != "" && GetQSVal("inMonth") != "" && GetQSVal("inYear") != "" && GetQSVal("outDay") != "" && GetQSVal("outMonth") != "" && GetQSVal("outYear") != "" ) { //if all dates were passed in querystring defInD = GetQSVal("inDay") defInM = GetQSVal("inMonth") defInY = GetQSVal("inYear") defOutD = GetQSVal("outDay") defOutM = GetQSVal("outMonth") defOutY = GetQSVal("outYear") } else if (GetQSVal("Checkin") != "" && GetQSVal("Checkout") != "") { //if all dates were passed in querystring var dateParts = GetQSVal("Checkin").split("-") defInD = dateParts[2] defInM = dateParts[1] defInY = dateParts[0] dateParts = GetQSVal("Checkout").split("-") defOutD = dateParts[2] defOutM = dateParts[1] defOutY = dateParts[0] } else { //extract dates from cookie var oSECookie = GetDatesCookie() if (oSECookie.inDate == "") { //there are no dates in cookie if (!startBlank) { //set default dates as follows: var defInDate = new Date(curYear, curMonth, curDay + 18) var defOutDate = new Date(curYear, curMonth, curDay + 20) defInD = defInDate.getDate() defInM = defInDate.getMonth() + 1 defInY = defInDate.getFullYear() defOutD = defOutDate.getDate() defOutM = defOutDate.getMonth() + 1 defOutY = defOutDate.getFullYear() } } else { //get defaults from cookie var inDArray = oSECookie.inDate.split("-") var outDArray = oSECookie.outDate.split("-") defInY = inDArray[0] defInM = inDArray[1] defInD = inDArray[2] defOutY = outDArray[0] defOutM = outDArray[1] defOutD = outDArray[2] } } //set dates if (!isNaN(defInD)) { this.SetDate(defInY, defInM, defInD, "in") this.SetDate(defOutY, defOutM, defOutD, "out") } } //validate dates and save them to cookie function ValidateDates() { //check that both dates are selected if (SelEmpty(this.inDCtl) || SelEmpty(this.inMCtl) || SelEmpty(this.inYCtl) || SelEmpty(this.outDCtl) || SelEmpty(this.outMCtl) || SelEmpty(this.outYCtl)) { return false } var checkinDate = this.GetDate("in") var checkoutDate = this.GetDate("out") //validate checkin date if (!validDate(checkinDate, this.inDCtl)) { if (typeof (Common_Scripts_TravelDates_VldCheckIn) == "undefined") Common_Scripts_TravelDates_VldCheckIn = "Please select a valid Check-in Date." alert(Common_Scripts_TravelDates_VldCheckIn) this.inDCtl.focus() return false } var curDate = new Date(curYear, curMonth, curDay) if (checkinDate - curDate < 0) { if (typeof (Common_Scripts_TravelDates_CheckInPast) == "undefined") Common_Scripts_TravelDates_CheckInPast = "The Check-in Date you have selected is in the past." alert(Common_Scripts_TravelDates_CheckInPast) this.inDCtl.focus() return false } //validate checkout date if (!validDate(checkoutDate, this.outDCtl)) { if (typeof (Common_Scripts_TravelDates_VldCheckOut) == "undefined") Common_Scripts_TravelDates_VldCheckOut = "Please select a valid Check-out Date." alert(Common_Scripts_TravelDates_VldCheckOut) this.outDCtl.focus() return false } //validate checkin - checkout difference if (checkoutDate - checkinDate > 2160000000) { //25 days in milliseconds if (typeof (Common_Scripts_TravelDates_StayTooLong) == "undefined") Common_Scripts_TravelDates_StayTooLong = "Your period of stay should be not longer than 25 nights.\n\nIf you wish to book for more than 25 nights, please send us an e-mail with your request." alert(Common_Scripts_TravelDates_StayTooLong) this.outDCtl.focus() return false } if (checkoutDate - checkinDate <= 0) { if (typeof (Common_Scripts_TravelDates_OutAfterIn) == "undefined") Common_Scripts_TravelDates_OutAfterIn = "Please ensure that the Check-out Date is after the Check-in Date." alert(Common_Scripts_TravelDates_OutAfterIn) this.outDCtl.focus() return false } //save dates to cookie SetDatesCookie(GetSelVal(this.inDCtl), GetSelVal(this.inMCtl), GetSelVal(this.inYCtl), GetSelVal(this.outDCtl), GetSelVal(this.outMCtl), GetSelVal(this.outYCtl)) return true //check that date select box has a not empty selection function SelEmpty(ctl) { if (GetSelVal(ctl) == "") { if (typeof (Common_Scripts_TravelDates_SelectDates) == "undefined") Common_Scripts_TravelDates_SelectDates = "Please select your Travel Dates." alert(Common_Scripts_TravelDates_SelectDates) ctl.focus() return true } return false } } //get date selected in dropdown boxes function GetSelDate(inOut) { var y = GetSelVal(eval("this." + inOut + "YCtl")) var m = GetSelVal(eval("this." + inOut + "MCtl")) var d = GetSelVal(eval("this." + inOut + "DCtl")) if (y == "" || m == "" || d == "") { return new Date() } else { return new Date(y, m - 1, d) } } //set date into dropdown boxes (month 1 to 12) function SetSelDate(year, month, day, inOut, bDoReset) { if (bDoReset == null) bDoReset = true SetSelVal(eval("this." + inOut + "YCtl"), Number(year)) SetSelVal(eval("this." + inOut + "MCtl"), Number(month)) SetSelVal(eval("this." + inOut + "DCtl"), Number(day)) if (bDoReset) { //reset the other date if (inOut == "in") this.resetDate("out") else this.resetDate("in") } } //set days of the week function SetDay() { if (this.inDayCtl != null) this.inDayCtl.value = "[" + wkdArray[this.GetDate("in").getDay()] + "]" if (this.outDayCtl != null) this.outDayCtl.value = "[" + wkdArray[this.GetDate("out").getDay()] + "]" } //set length of stay function SetLenStay() { if (this.lenStayID != null) { if (document.all) var stay = document.all[this.lenStayID] else if (document.getElementById) var stay = document.getElementById(this.lenStayID) if (stay) // Ask Eugene, for backwards affiliate capabilities stay.innerHTML = Math.round((this.GetDate("out") - this.GetDate("in")) / 86400000) + " " } //set days of the week this.SetDaysOfWeek() } //reset out date to (in date + 2) if out date <= in date AND reset in date to (out date - 1) if in date >= out date function ResetDate(InOut) { var checkinDate = this.GetDate("in") var checkoutDate = this.GetDate("out") var checkDate, incremet if (InOut == "in") { checkDate = checkoutDate incremet = -1 } else { checkDate = checkinDate incremet = 2 } if (checkinDate >= checkoutDate) { var newDate = new Date(checkDate.getFullYear(), checkDate.getMonth(), checkDate.getDate() + incremet) this.SetDate(newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate(), InOut, false) } //set length of stay this.SetLenStay() } // TRAVEL DATES OBJECT END //save dates to cookie function SetDatesCookie(inD, inM, inY, outD, outM, outY) { var oSECookie = GetDatesCookie() if (isNaN(inD) || isNaN(inM) || isNaN(inY) || isNaN(outD) || isNaN(outM) || isNaN(outY)) { oSECookie.inDate = "" oSECookie.outDate = "" } else { oSECookie.inDate = inY + "-" + inM + "-" + inD oSECookie.outDate = outY + "-" + outM + "-" + outD } document.cookie = escape("|SearchEng|") + "=" + escape("|" + oSECookie.country + "|" + oSECookie.city + "|" + oSECookie.suburb + "|" + oSECookie.inDate + "|" + oSECookie.outDate + "|") + ";path=/" } //returns object containing search engine cookie elements function GetDatesCookie() { var oSECookie = new Object() oSECookie.country = "" oSECookie.city = "" oSECookie.suburb = "" oSECookie.inDate = "" oSECookie.outDate = "" var cookieArray = URLDecode(document.cookie).split("|") for (var i=0; i") else document.write("") } //load container with remote data function getData(func, args) { var d = new Date() var params = "f=" + escape(func) + "&o=" + escape(this.objName) + "&u=" + d.getTime() for (var i=0; i "9" || number.charAt(i) < "0") return true } return false } //adds digit grouping to the number function formatNumber(number) { if (number.toString() == "") { if (typeof (Common_Scripts_FuncLib_OnRequest) == "undefined") Common_Scripts_FuncLib_OnRequest = "On Request" return Common_Scripts_FuncLib_OnRequest } if (number < 0) { var sign = "-" number = -number } else{ var sign = "" } number = number.toString() var tmpNumber = "" var dot = false for (var j=0; j=i; j--) { if (stringToTrim.charAt(j) != " ") break } return stringToTrim.substring(i, j + 1) } //validate email address function notEmail(field, fieldName, msg) { var email = trim(field.value) if (email == "") return false var at = false var dot = false for (var i=0; i 5)) { if (msg == null) msg = "The " + fieldName + " you entered is not a valid e-mail address." alert(msg) field.focus() field.select() return true } //check for invalid characters if (invalidChars(field, "E-mail", '%,;|" <>\\/')) return true return false } //validate ASCII Character Set function charCheck(field, message, toASCIIfield) { if (toASCIIfield == null) var txt = field.value else var txt = ToASCII(field) for (var i=0; i= 128) { alert(message) field.focus() return true } } return false } //checks whether selected option has invalid value and selects option with gotoIndex function checkInvalVal(sel, invalVal, gotoIndex) { if (GetSelVal(sel) == invalVal) sel.selectedIndex = gotoIndex } //date validation function validDate(date, ctlDay) { return date.getDate() == GetSelVal(ctlDay) } //set select box value function SetSelVal(ctl, newVal) { for (var i=0; i maxLen) { if (msg == null) msg = "Please limit " + ctlName + " to " + maxLen + " characters. You have used " + ctlLen + " characters." msg = msg.replace(/\[MaxCharactersAllowed\]/, maxLen) msg = msg.replace(/\[NumOfCharacters\]/, ctlLen) alert(msg) ctl.focus() return true } return false } //open new window function openWnd(url, name, height, width, directories, location, menubar, resizable, scrollbars, status, toolbar) { wnd = window.open(url, name, "alwaysRaised=1,height=" + height + ",width=" + width + ",directories=" + directories + ",locaton=" + location + ",menubar=" + menubar + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",status=" + status + ",toolbar=" + toolbar) wnd.focus() } //unencode url-encoded string function URLDecode(urlStr) { return unescape(urlStr.replace(/\+/g, " ")) } //remove all name/value pairs with the passed name from url-encoded querystring function remQStringName(qString, name) { var i var qStringNew = "" if (qString != "") { var curName var arrNameVal = qString.split("&") for (i in arrNameVal) { curName = URLDecode(arrNameVal[i].split("=")[0]) if (curName.toLowerCase() != name.toLowerCase()) qStringNew += "&" + arrNameVal[i] } } return qStringNew.substr(1) } //replace or add name/value pairs in url-encoded querystring function setQStringName(qString, name, arrVal) { var qStringNew = remQStringName(qString, name) var start = qStringNew == "" ? 1 : 0 for (var i in arrVal) qStringNew += "&" + escape(name) + "=" + escape(arrVal[i]) return qStringNew.substr(start) } //extract (first!) value from querystring for the passed name function GetQSVal(qsName) { var qsPair var qString = location.search.substr(1) var arrNameVal = qString.split("&") for (var i in arrNameVal) { qsPair = arrNameVal[i].split("=") if (URLDecode(qsPair[0]).toLowerCase() == qsName.toLowerCase()) return URLDecode(qsPair[1]) } return "" } //convert character to ASCII function ToASCII(field){ var txt = field.value for (var i = 0; i" break } if (sSheets[i].href != "") docStyles += "" } return docStyles } } //set selected date in the return controls function ReturnDate(year, month, day) { this.returnFunc(year, month + 1, day, this.returnParam) //call the calendar return function window.focus() //hide calendar by moving focus to the main window } //show calendar function ShowCal(posCtl, title, startYear, selDate, returnParam) { //do not show calendar in ie4 if (navigator.appVersion.indexOf("MSIE 4") != -1) return this.title = title //calendar titlebar text this.startYear = startYear //first year in the dropdown box this.selDate = selDate //date selected on the calender this.year = selDate.getFullYear() //current calendar year this.month = selDate.getMonth() //current calendar month this.returnParam = returnParam //extra parameter to pass to the return function //open calendar window var calPos = CalcCalCoord() this.win = window.open("", "", "channelmode=0, directories=0, fullscreen=0, hotkeys=0, left=" + calPos.x + ", location=0, menubar=0, resizable=0, status=0, titlebar=1, toolbar=0, top=" + calPos.y + ", width=141, height=133") //draw calendar this.draw() //calculate screen coordinates of the calendar window function CalcCalCoord() { var coord = new Object() if (typeof(window.screenLeft) == "undefined") { coord.x = screen.width / 2 coord.y = screen.height / 2 } else { var docBody = document.body var posTmp = posCtl coord.x = screenLeft + docBody.clientLeft - docBody.scrollLeft - 1 coord.y = screenTop + docBody.clientTop - docBody.scrollTop + posCtl.offsetHeight + 1 while (posTmp != docBody) { coord.x += posTmp.offsetLeft coord.y += posTmp.offsetTop posTmp = posTmp.offsetParent } if (typeof(blnDisplayFlg) != "undefined") { if ((posCtl == getPageObject("inDay")) || (posCtl == getPageObject("outDay"))) { coord.x += 6 coord.y += 8 } } } return coord } } //reload calendar html function DrawCal(monthShift) { //shift calendar's month and year if monthShift passed if (typeof(monthShift) != "undefined") { //year this.year += Math.floor((this.month + monthShift) / 12) //month this.month = (this.month + monthShift) % 12 if (this.month < 0) this.month += 12 } //get day of the week of the 1st day of the month (0 - sun, 1 - mon, etc) var firstMonthDay = new Date(this.year, this.month, 1).getDay() //get first monday before the 1st day of the month var day = 1 - (firstMonthDay + 6) % 7 //get "previous" and "next" link html var prevLnk = (this.year == this.startYear && this.month == 0) ? "     " : " <<" var nextLnk = (this.year == this.startYear + this.years - 1 && this.month == 11) ? "     " : ">> " //get calender html var calHTML = "" + "" + "" + this.title + "" + this.docStyles + "" + "" + '' + "" + "" + "" + "" + "" + "" + "" + "
" + "" + "" + "" + "" + "" + "" + "
" + prevLnk + "" + GetDropdownHTML(this.startYear, this.years, this.year, this.month) + "" + nextLnk + "
" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" var calYear, calMonth, calDay, tdClass, aClass var calDate = new Date(this.year, this.month, day) do { calHTML += "" do { calYear = calDate.getFullYear() calMonth = calDate.getMonth() calDay = calDate.getDate() //get cell and link class names if (calDate.getDay() == 0 || calDate.getDay() == 6) { //weekend aClass = "cal-wend" } else { aClass = "cal-wday" } if (calYear == this.selDate.getFullYear() && calMonth == this.selDate.getMonth() && calDay == this.selDate.getDate() && day > 0) { tdClass = "cal-this" aClass = "cal-lthis" } else if (calMonth == this.month && day > 0) { tdClass = "cal-month" } else { tdClass = "cal-date" } calHTML += "" day++ calDate = new Date(this.year, this.month, day) } while (calDate.getDay() != 1) //1 - monday calHTML += "" } while (calDate.getMonth() == this.month) calHTML += "
" + arrShortDay[1] + "" + arrShortDay[2] + "" + arrShortDay[3] + "" + arrShortDay[4] + "" + arrShortDay[5] + "" + arrShortDay[6] + "" + arrShortDay[0] + "
" + calDay + "
" + "
" + "" + "" //write calender html into the window with (this.win.document) { open() write(calHTML) close() } //set reference inside calendar window to the calendar object in the parent window this.win.oCal = this //get html of the calendar's dropdown function GetDropdownHTML(startYear, years, year, month) { var sMask = GetDropdownDateMask() var loopMonth, loopYear var sName, sValue, sSelected var dropdownHTML = "" return dropdownHTML } //returns date mask for month-year drop-down function GetDropdownDateMask() { var arrMask = dateMask.split("|") var sSeparator = arrMask[3] var sTmpMask = "" for (var i=0; i < arrMask.length-1; i++) { if (arrMask[i].indexOf("d") == -1 ) //do not include day in the mask sTmpMask += arrMask[i] + sSeparator } if (sSeparator != "") sTmpMask = sTmpMask.substring(0, sTmpMask.length - 1) return sTmpMask } } //initialise travel dates var curDay = 21 var curMonth = 7 var curYear = 2008 var bookPeriod = 20