function deObfuscate(s) { s = s.replace(/@d/g, '.'); s = s.replace(/@s/g, '/'); s = s.replace(/@@/g, '@'); s = s.replace(/[a-zA-Z]/g, function(c) { return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26); }); return s; } function clickOb(el) { var url = el.getAttribute('obs'); window.location = deObfuscate(url); return false; } SplendiaSoftReadyHandlers = [ ]; SplendiaInjectionHandlers = [ ]; function runSoftReadyHandlers() { for (var i = 0; i < SplendiaSoftReadyHandlers.length; i++) { SplendiaSoftReadyHandlers[i](); } } function runInjectionHandlers() { for (var i = 0; i < SplendiaInjectionHandlers.length; i++) { SplendiaInjectionHandlers[i](); } } if (!this.JSON) { JSON = {}; } (function () { function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; } if (typeof Date.prototype.toJSON !== 'function') { Date.prototype.toJSON = function (key) { return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z'; }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) { return this.valueOf(); }; } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }, rep; function str(key, holder) { // Produce a string from holder[key]. var i, // The loop counter. k, // The member key. v, // The member value. length, mind = gap, partial, value = holder[key]; // If the value has a toJSON method, call it to obtain a replacement value. if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } // If we were called with a replacer function, then call the replacer to // obtain a replacement value. if (typeof rep === 'function') { value = rep.call(holder, key, value); } // What happens next depends on the value's type. switch (typeof value) { case 'string': return quote(value); case 'number': // JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': // If the value is a boolean or null, convert it to a string. Note: // typeof null does not produce 'null'. The case is included here in // the remote chance that this gets fixed someday. return String(value); // If the type is 'object', we might be dealing with an object or an array or // null. case 'object': // Due to a specification blunder in ECMAScript, typeof null is 'object', // so watch out for that case. if (!value) { return 'null'; } // Make an array to hold the partial results of stringifying this object value. gap += indent; partial = []; // Is the value an array? if (Object.prototype.toString.apply(value) === '[object Array]') { // The value is an array. Stringify every element. Use null as a placeholder // for non-JSON values. length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } // Join all of the elements together, separated with commas, and wrap them in // brackets. v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v; } // If the replacer is an array, use it to select the members to be stringified. if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { k = rep[i]; if (typeof k === 'string') { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } else { // Otherwise, iterate through all of the keys in the object. for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } // Join all of the member texts together, separated with commas, // and wrap them in braces. v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v; } } // If the JSON object does not yet have a stringify method, give it one. if (typeof JSON.stringify !== 'function') { JSON.stringify = function (value, replacer, space) { // The stringify method takes a value and an optional replacer, and an optional // space parameter, and returns a JSON text. The replacer can be a function // that can replace values, or an array of strings that will select the keys. // A default replacer method can be provided. Use of the space parameter can // produce text that is more easily readable. var i; gap = ''; indent = ''; // If the space parameter is a number, make an indent string containing that // many spaces. if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } // If the space parameter is a string, it will be used as the indent string. } else if (typeof space === 'string') { indent = space; } // If there is a replacer, it must be a function or an array. // Otherwise, throw an error. rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } // Make a fake root object containing our value under the key of ''. // Return the result of stringifying the value. return str('', {'': value}); }; } // If the JSON object does not yet have a parse method, give it one. if (typeof JSON.parse !== 'function') { JSON.parse = function (text, reviver) { // The parse method takes a text and an optional reviver function, and returns // a JavaScript value if the text is a valid JSON text. var j; function walk(holder, key) { // The walk method is used to recursively walk the resulting structure so // that modifications can be made. var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); } // Parsing happens in four stages. In the first stage, we replace certain // Unicode characters with escape sequences. JavaScript handles many characters // incorrectly, either silently deleting them, or treating them as line endings. cx.lastIndex = 0; if (cx.test(text)) { text = text.replace(cx, function (a) { return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }); } // In the second stage, we run the text against regular expressions that look // for non-JSON patterns. We are especially concerned with '()' and 'new' // because they can cause invocation, and '=' because it can cause mutation. // But just to be safe, we want to reject all unexpected forms. // We split the second stage into 4 regexp operations in order to work around // crippling inefficiencies in IE's and Safari's regexp engines. First we // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we // replace all simple value tokens with ']' characters. Third, we delete all // open brackets that follow a colon or comma or that begin the text. Finally, // we look to see that the remaining characters are only whitespace or ']' or // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. if (/^[\],:{}\s]*$/. test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { // In the third stage we use the eval function to compile the text into a // JavaScript structure. The '{' operator is subject to a syntactic ambiguity // in JavaScript: it can begin a block or an object literal. We wrap the text // in parens to eliminate the ambiguity. j = eval('(' + text + ')'); // In the optional fourth stage, we recursively walk the new structure, passing // each name/value pair to a reviver function for possible transformation. return typeof reviver === 'function' ? walk({'': j}, '') : j; } // If the text is not JSON parseable, then a SyntaxError is thrown. throw new SyntaxError('JSON.parse'); }; } }()); function QMCreateCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function QMCreateCookieMin(name,value,minutes) { if (minutes) { var date = new Date(); date.setTime(date.getTime()+(minutes*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function QMReadCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function QMEraseCookie(name) { createCookie(name,"",-1); } /* var dtemp = new Date(); SplendiaInitialMilestone = { 'name' : '(pre-handlers)', 'hit' : dtemp.getTime() }; SplendiaMilestones = [ ]; function addMilestone(name) { var dtemp = new Date(); SplendiaMilestones.push({ 'name' : name, 'hit' : dtemp.getTime() }); } function logMilestones() { var last = SplendiaInitialMilestone; for (var i = 0; i < SplendiaMilestones.length; i++) { var current = SplendiaMilestones[i]; console.log('' + (current.hit - last.hit) + 'ms: ' + current.name); last = current; } } */ SplendiaSoftReadyHandlers.push(function() { ////////////////////////////////////////////////////////////////////////////// var Namespace = function() { this.places = { }; this.dialogs = { }; }; Namespace.prototype.levelOfDetailForZoom = function(level) { if (level < 0) level = 0; else if (level > 17) level = 17; return MapsProfile.zoomContent[level][this.zoomProfile]; } Namespace.prototype.displayInZoom = function(level) { return this.levelOfDetailForZoom(level) > 0; } Namespace.prototype.flush = function(map) { $.each(this.places, function(k, v) { if (v.marker != false) map.gmap.removeOverlay(v.marker); }); this.places = { }; } Namespace.prototype.flushDialogs = function(map) { $.each(this.dialogs, function(k, v) { if (v) map.gmap.removeOverlay(v); }); this.dialogs = { }; } Namespace.prototype.addContent = function(place) { this.places[parseInt(place.i)] = { point: new GLatLng(parseFloat(place.a), parseFloat(place.o)), name: place.n, marker: false, extra: place }; } Namespace.prototype.newContents = function(newPlaces, map) { if (typeof(newPlaces[this.zoomProfile]) == 'undefined') return; var np = newPlaces[this.zoomProfile]; if (np == null || np == false) return; //console.log(this.zoomProfile + '(' + MapsProfile.zoomContent[map.gmap.getZoom()][this.zoomProfile]+ ')' + ' ' + np.length); var diff = []; for (var i = 0; i < np.length; i++) { var place = np[i]; if (typeof(this.places[place.i]) != 'undefined') continue; this.addContent(place); diff.push(place.i); } if (diff.length <= 0) return; for (var i = 0; i < diff.length; i++) { this.realizeContent(diff[i], map); } } Namespace.prototype.realizeContent = function(id, map) { var place = this.places[id]; var theNS = this; place.marker = new GMarker(place.point, this.markerOptionsForID(id, place, map)); place.marker.isInfoWindowOpen = false; place.marker.tooltip = new GCustomTooltip(place.marker, function() { return theNS.tooltipContent(id, place, map); }, 5); GEvent.addListener(place.marker,'mouseover', function() { if (!window.maps2InfoWindowOpen && !(place.marker.isInfoWindowOpen) && !(place.marker.isHidden())) { place.marker.tooltip.show(); theNS.dialogs[id] = place.marker.tooltip; } }); GEvent.addListener(place.marker,'mouseout', function() { place.marker.tooltip.hide(); theNS.dialogs[id] = null; }); this.setClickHandler(id, place, map); map.gmap.addOverlay(place.marker); map.gmap.addOverlay(place.marker.tooltip); } Namespace.prototype.setClickHandler = function(id, place, map) { GEvent.addListener(place.marker,'click', function() { place.marker.tooltip.hide(); map.centerOnGeoID(id, 'destination'); }); } Namespace.prototype.markerOptionsForID = function(id, place, map) { return {'icon':this.icon}; } Namespace.prototype.focusOnID = function(id) { } Namespace.prototype.tooltipContent = function(id, place, map) { return $('
test
').get(0); } Namespace.prototype.legendIcons = function() { return '
   '+ this.iconName + '
'; } ///////////////////////////////////////////////////////////////////////////// var Countries = function() { this.zoomProfile = 'countries'; this.iconName = map2Trans.m_countries; this.icon = new GIcon(); this.icon.image = '/images/mapmarkers/2/pais.png'; this.icon.iconSize = new GSize(18,22); this.icon.iconAnchor = new GPoint(1,20); this.icon.infoWindowAnchor = new GPoint(0,0); this.icon.infoShadowAnchor = new GPoint(0,0); } Countries.prototype = new Namespace(); Countries.prototype.tooltipContent = function(id, place, map) { var html = '
'; html += '
'+place.extra.n+'
'; html += ''; var s = map2Trans.m_click.replace('{img}', ''); html += '
'+place.extra.nh+' '+map2Trans.m_hotels+'


'+s+'.
'; html += '
'; return $(html).get(0); } ////////////////////////////////////////////////////////////////////////////// var Cities = function() { this.zoomProfile = 'cities'; this.iconName = map2Trans.m_cities; this.icon = new GIcon(); this.icon.image = '/images/mapmarkers/2/ciudades.png'; this.icon.iconSize = new GSize(17,17); this.icon.iconAnchor = new GPoint(8,8); this.icon.infoWindowAnchor = new GPoint(0,0); this.icon.infoShadowAnchor = new GPoint(0,0); this.iconS = new GIcon(); this.iconS.image = '/images/mapmarkers/2/ciudades-s.png'; this.iconS.iconSize = new GSize(8,8); this.iconS.iconAnchor = new GPoint(4,4); this.iconS.infoWindowAnchor = new GPoint(0,0); this.iconS.infoShadowAnchor = new GPoint(0,0); } Cities.prototype = new Namespace(); Cities.prototype.tooltipContent = function(id, place, map) { var html = '
'; html += '
'+place.extra.n+'
'; html += ''; var s = map2Trans.m_click.replace('{img}', ''); html += '
'+place.extra.nh+' '+map2Trans.m_hotels+'


'+s+'.
'; html += '
'; return $(html).get(0); } Cities.prototype.iconForPlace = function(place) { var icon = this.icon; if (parseInt(place.extra.nh) < 4) { icon = this.iconS; } return icon; } Cities.prototype.markerOptionsForID = function(id, place, map) { return {'icon': this.iconForPlace(place) }; } ////////////////////////////////////////////////////////////////////////////// var BabyHotels = function() { this.zoomProfile = 'babyHotels'; this.iconName = map2Trans.m_hotelsB; this.icon = new GIcon(); this.icon.image = '/images/mapmarkers/2/cuadrado-azul2.png'; this.icon.iconSize = new GSize(9,11); this.icon.iconAnchor = new GPoint(4,10); this.icon.infoWindowAnchor = new GPoint(0,0); this.icon.infoShadowAnchor = new GPoint(0,0); } BabyHotels.prototype = new Namespace(); BabyHotels.prototype.markerOptionsForID = function(id, place, map) { return {icon:this.icon, clickable:false}; } BabyHotels.prototype.legendIcons = function() { return ''; } window.SplendiaMapsHilightHotel = function(id) { } ////////////////////////////////////////////////////////////////////////////// var Hotels = function() { var me = this; this.zoomProfile = 'hotels'; this.iconName = map2Trans.m_hotelsB; this.icon = new GIcon(); this.icon.image = '/images/mapmarkers/2/cuadrado-azul.png'; this.icon.iconSize = new GSize(17,21); this.icon.iconAnchor = new GPoint(9,20); this.icon.infoWindowAnchor = new GPoint(0,0); this.icon.infoShadowAnchor = new GPoint(0,0); this.iconVisited = new GIcon(); this.iconVisited.image = '/images/mapmarkers/2/azul-marca.png'; this.iconVisited.iconSize = new GSize(17,21); this.iconVisited.iconAnchor = new GPoint(9,20); this.iconVisited.infoWindowAnchor = new GPoint(0,0); this.iconVisited.infoShadowAnchor = new GPoint(0,0); this.iconSelected = new GIcon(); this.iconSelected.image = '/images/mapmarkers/2/icono-selecion.png'; this.iconSelected.iconSize = new GSize(34,40); this.iconSelected.iconAnchor = new GPoint(15,36); this.iconSelected.infoWindowAnchor = new GPoint(0,0); this.iconSelected.infoShadowAnchor = new GPoint(0,0); this.iconAvail = new GIcon(); this.iconAvail.image = '/images/mapmarkers/2/cuadrado-azul.png'; this.iconAvail.iconSize = new GSize(17,21); this.iconAvail.iconAnchor = new GPoint(9,20); this.iconAvail.infoWindowAnchor = new GPoint(0,0); this.iconAvail.infoShadowAnchor = new GPoint(0,0); this.iconNotAvail = new GIcon(); this.iconNotAvail.image = '/images/mapmarkers/2/cuadrado-gris.png'; this.iconNotAvail.iconSize = new GSize(17,21); this.iconNotAvail.iconAnchor = new GPoint(9,20); this.iconNotAvail.infoWindowAnchor = new GPoint(0,0); this.iconNotAvail.infoShadowAnchor = new GPoint(0,0); this.iconVisitedAvail = new GIcon(); this.iconVisitedAvail.image = '/images/mapmarkers/2/azul-marca.png'; this.iconVisitedAvail.iconSize = new GSize(17,21); this.iconVisitedAvail.iconAnchor = new GPoint(9,20); this.iconVisitedAvail.infoWindowAnchor = new GPoint(0,0); this.iconVisitedAvail.infoShadowAnchor = new GPoint(0,0); this.iconVisitedNotAvail = new GIcon(); this.iconVisitedNotAvail.image = '/images/mapmarkers/2/gris-marca.png'; this.iconVisitedNotAvail.iconSize = new GSize(17,21); this.iconVisitedNotAvail.iconAnchor = new GPoint(9,20); this.iconVisitedNotAvail.infoWindowAnchor = new GPoint(0,0); this.iconVisitedNotAvail.infoShadowAnchor = new GPoint(0,0); this.focusedHotel = 0; this.hiHotel = 0; this.focusedInThePast = {}; window.SplendiaMapsHilightHotel = function(id) { if (me.hiHotel > 0) { if (typeof(me.places[me.hiHotel]) != 'undefined') { var place = me.places[me.hiHotel]; place.marker.setImage(me.iconForPlace(place).image); } } me.hiHotel = id; if (me.hiHotel > 0 && me.focusedHotel != me.hiHotel) { if (typeof(me.places[me.hiHotel]) != 'undefined') { var place = me.places[me.hiHotel]; place.marker.setImage('/images/mapmarkers/2/cuadrado-verde-old.png'); } } } } Hotels.prototype = new Namespace(); Hotels.prototype.focusOnID = function(map, id, mode) { if (mode != 'hotel') return; this.focusedHotel = id; this.focusedInThePast[id] = true; } Hotels.prototype.iconForPlace = function(place) { var icon = this.icon; if (typeof(this.focusedInThePast[place.extra.i]) != 'undefined') { icon = this.iconVisited; if (place.extra.d == 'y') { icon = this.iconVisitedAvail; } else if (place.extra.d == 'n') { icon = this.iconVisitedNotAvail; } } else { if (place.extra.d == 'y') { icon = this.iconAvail; } else if (place.extra.d == 'n') { icon = this.iconNotAvail; } } if (place.extra.i == this.focusedHotel) { icon = this.iconSelected; } return icon; } Hotels.prototype.markerOptionsForID = function(id, place, map) { return {'icon': this.iconForPlace(place) }; } Hotels.prototype.tooltipContent = function(id, place, map) { var starsImg = ''; var th = place.extra.th; if (th == 'H3' || th == 'H4' || th == 'H4L' || th == 'H5' || th == '5L' || th == 'H5L' || th == 'H5GL') { starsImg = ''; } var icon = this.iconForPlace(place); var html = '
'; html += '
'+place.extra.n+' '+starsImg+'
'; html += ''; html += '
'+map2Trans.m_location+': '+place.extra.l+'
'+map2Trans.m_style+': '+place.extra.s+'
'+place.extra.r+' '+map2Trans.m_rooms+'
'; if (place.extra.pr) html += map2Trans.m_from + ' ' + place.extra.p + '
'; var s = map2Trans.m_click_info.replace('{img}', ''); html += s +'.
'; html += '
'; return $(html).get(0); } window.maps2InfoWindowOpen = false; Hotels.prototype.setClickHandler = function(id, place, map) { var theHotels = this; GEvent.addListener(place.marker, 'click', function() { place.marker.tooltip.hide(); // refocus if (parseInt(theHotels.focusedHotel) > 0 && (typeof theHotels.places[theHotels.focusedHotel]) != 'undefined') { var oldFocus = theHotels.focusedHotel; var oldFocusMarker = theHotels.places[theHotels.focusedHotel].marker; map.gmap.removeOverlay(oldFocusMarker); theHotels.focusedHotel = 0; theHotels.realizeContent(oldFocus, map); } theHotels.focusedHotel = id; theHotels.focusedInThePast[id] = true; // remove the current marker map.gmap.removeOverlay(place.marker); // create new marker theHotels.realizeContent(id, map); theController.queueOp(function() { window.map2LoadingRefCountIncr(); $.get( '/index.php?resource=ajax&component=AjaxMaps&op=hotelpopup&id=' + id, {}, function(data) { place.marker.openInfoWindowHtml(data); window.maps2InfoWindowOpen = true; GEvent.addListener(map.gmap, "infowindowclose", function() { window.maps2InfoWindowOpen = false; }); window.map2LoadingRefCountDecr(); }, 'html' ); }); //map.centerOnGeoID(id, 'hotel'); //map.gmap.setCenter(place.point, map.gmap.getZoom()); }); } Hotels.prototype.legendIcons = function() { if (map2WithDates) { return '
   '+map2Trans.m_avail_hotels+'
' + '
   '+map2Trans.m_not_avail_hotels+'
'; } else { return '
   '+ this.iconName + '
'; } } ////////////////////////////////////////////////////////////////////////////// var Pois = function() { this.zoomProfile = 'pois'; this.iconName = map2Trans.m_pois; this.icon = new GIcon(); this.icon.image = '/images/mapmarkers/2/info.png'; this.icon.iconSize = new GSize(18,23); this.icon.iconAnchor = new GPoint(9,22); this.icon.infoWindowAnchor = new GPoint(0,0); this.icon.infoShadowAnchor = new GPoint(0,0); this.iconTransport = new GIcon(); this.iconTransport.image = '/images/mapmarkers/2/transporte.png'; this.iconTransport.iconSize = new GSize(18,23); this.iconTransport.iconAnchor = new GPoint(9,22); this.iconTransport.infoWindowAnchor = new GPoint(0,0); this.iconTransport.infoShadowAnchor = new GPoint(0,0); this.iconAirport = new GIcon(); this.iconAirport.image = '/images/mapmarkers/2/avion.png'; this.iconAirport.iconSize = new GSize(18,23); this.iconAirport.iconAnchor = new GPoint(9,22); this.iconAirport.infoWindowAnchor = new GPoint(0,0); this.iconAirport.infoShadowAnchor = new GPoint(0,0); } Pois.prototype = new Namespace(); Pois.prototype.markerOptionsForID = function(id, place, map) { var icon = place.extra.t == 0 ? this.iconAirport : (place.extra.t == 1 ? this.iconTransport : this.icon); return {'icon':icon}; } Pois.prototype.tooltipContent = function(id, place, map) { var html = '
'; html += '
'+place.extra.n+'
'; html += '
'; return $(html).get(0); } Pois.prototype.legendIcons = function() { return '
   '+ this.iconName + '
' + '
   ' + map2Trans.m_transport + '
' + '
   ' + map2Trans.m_airport + '
' ; } ////////////////////////////////////////////////////////////////////////////// var MapsController = function() { this.loadedGoogleJS = false; this.loadingGoogleJS = false; this.pendingOps = [ ]; }; MapsController.prototype.loadGoogleJS = function() { this.loadingGoogleJS = true; var script = document.createElement('script'); script.type = 'text/javascript'; var url = 'http://maps.google.com/maps?file=api&v=2&async=2&callback=Maps2GoogleAPIReady'; url += '&key=' + map2Key; url += '&hl=' + map2Lang; script.src = url; document.body.appendChild(script); } MapsController.prototype.queueOp = function(op) { if (!this.loadedGoogleJS && !this.loadingGoogleJS) { this.loadGoogleJS(); } this.pendingOps.push(op); this.runQueue(); } MapsController.prototype.runQueue = function() { if (!this.loadedGoogleJS) return; if (this.pendingOps.length <= 0) return; var ops = this.pendingOps; this.pendingOps = [ ]; for (var i = 0; i < ops.length; i++) { ops[i](); } this.runQueue(); } var theController = new MapsController(); window.Maps2GoogleAPIReady = function() { theController.loadedGoogleJS = true; theController.loadingGoogleJS = false; extraDeclarations(); theController.runQueue(); } window.Map2SearchSelectionHook = null; ////////////////////////////////////////////////////////////////////////////// var Map = function(center, zoom, node, postRequest) { this.center = center; this.zoom = zoom; this.domNode = node; this.gmap = false; this.geocoder = false; this.namespaces = [ ]; this.legend = false; this.initial = { }; this.initial.center = center; this.initial.zoom = zoom; this.create(postRequest); } Map.prototype.create = function(postRequest) { var theMap = this; theController.queueOp(function() { for (var i = 0; i < MapsProfile.ordering.length; i++) { theMap.namespaces.push(new MapsProfile.ordering[i]()); } theMap.gmap = new GMap2(theMap.domNode); theMap.gmap.setCenter(new GLatLng(theMap.center.lat, theMap.center.lon), theMap.zoom); //theMap.gmap.enableScrollWheelZoom(); theMap.gmap.addControl(new GLargeMapControl3D()); theMap.gmap.addControl(new GMapTypeControl()); theMap.gmap.addControl(new GScaleControl()); theMap.gmap.addControl(new GOverviewMapControl()); theMap.legend = new GCustomLegend(); theMap.gmap.addControl(theMap.legend); GEvent.addListener(theMap.gmap, "moveend", function() { theMap.request(); }); theMap.request(); theMap.geocoder = new GClientGeocoder(); $('#map2_address_search_form').submit(function() { var q = $('#map2_address_search_input').val(); var country = $('#map2_address_search_country').val(); theMap.geocoder.setBaseCountryCode(country); theMap.geocoder.getLatLng(q, function(point) { if (point != null) { theMap.centerOnLatLng(point.lat(), point.lng(), 14); } }); return false; }); $('#map2_address_search_initial').click(function() { theMap.gmap.setCenter(new GLatLng(theMap.initial.center.lat, theMap.initial.center.lon), theMap.initial.zoom); return false; }); postRequest(theMap); }); } Map.prototype.request = function() { var theMap = this; window.map2LoadingRefCountIncr(); $.get( '/index.php?resource=ajax&component=AjaxMaps&op=map', theMap.requestOptions(), function(data) { if (data.status != 'ok') return; var legendContents = ''; for (var i = 0; i < theMap.namespaces.length; i++) { var ns = theMap.namespaces[i]; ns.flushDialogs(theMap); if (ns.displayInZoom(theMap.gmap.getZoom())) { ns.newContents(data, theMap); legendContents = ns.legendIcons() + legendContents; } else { ns.flush(theMap); } } theMap.legend.setInnerHTML(legendContents); window.map2LoadingRefCountDecr(); }, 'json' ); } Map.prototype.flush = function() { for (var i = 0; i < this.namespaces.length; i++) { this.namespaces[i].flushDialogs(this); this.namespaces[i].flush(this); } } Map.prototype.requestOptions = function() { var zoom = this.gmap.getZoom(); var bounds = this.gmap.getBounds(); var sw = bounds.getSouthWest(); var ne = bounds.getNorthEast(); var opts = { 'lat' : sw.lat(), 'lon' : sw.lng(), 'lat2' : ne.lat(), 'lon2' : ne.lng() }; for (var i = 0; i < this.namespaces.length; i++) { var ns = this.namespaces[i]; opts[ns.zoomProfile] = ns.levelOfDetailForZoom(zoom); } return opts; } Map.prototype.centerOnLatLng = function(lat, lon, zoom) { this.gmap.setCenter(new GLatLng(lat, lon), zoom); } Map.prototype.centerOnGeoID = function(id, mode) { var theMap = this; theController.queueOp(function() { window.map2LoadingRefCountIncr(); $.get( '/index.php?resource=ajax&component=AjaxMaps&op=geoinfo&id=' + id + '&mode=' + mode, {}, function(data) { if (data.status != 'ok') return; theMap.focusOnID(id, mode); theMap.flush(); theMap.gmap.setCenter(new GLatLng(parseFloat(data.lat), parseFloat(data.lon)), parseInt(data.zoom)); window.map2LoadingRefCountDecr(); }, 'json' ); }); } Map.prototype.centerOnGeoIDNoZoom = function(id, mode) { var theMap = this; theController.queueOp(function() { window.map2LoadingRefCountIncr(); $.get( '/index.php?resource=ajax&component=AjaxMaps&op=geoinfo&id=' + id + '&mode=' + mode, {}, function(data) { if (data.status != 'ok') return; theMap.focusOnID(id, mode); theMap.flush(); theMap.gmap.setCenter(new GLatLng(parseFloat(data.lat), parseFloat(data.lon)), theMap.gmap.getZoom()); window.map2LoadingRefCountDecr(); }, 'json' ); }); } Map.prototype.focusOnID = function(id, mode) { for (var i = 0; i < this.namespaces.length; i++) { var ns = this.namespaces[i]; ns.focusOnID(this, id, mode); } } ////////////////////////////////////////////////////////////////////////////// var AllMaps = function() { this.homeMap = false; this.hotelPageMap = false; this.hotelListMap = false; } AllMaps.prototype.prepareMap = function(elementID) { var map = false; if (map2DefaultLocationObj != false) { map = new Map( { lat: parseFloat(map2DefaultLocationObj.lat), lon: parseFloat(map2DefaultLocationObj.lon) }, parseInt(map2DefaultLocationObj.zoom), document.getElementById(elementID), function(theMap) { theMap.focusOnID(map2DefaultLocation, map2DefaultLocationMode); } ); } else if (map2DefaultLocation > 0) { map = new Map({lat: 20, lon: 15}, 2, document.getElementById(elementID), function(theMap) { }); map.centerOnGeoID(map2DefaultLocation, map2DefaultLocationMode); } else { map = new Map({lat: 20, lon: 15}, 2, document.getElementById(elementID), function(theMap) { }); } return map; } AllMaps.prototype.showHomeMap = function() { if (this.homeMap != false) return; this.homeMap = this.prepareMap('maps_home_map'); var theMap = this.homeMap; window.Map2SearchSelectionHook = function(id, mode) { theMap.centerOnGeoID(id, mode); } } AllMaps.prototype.showHotelPageMap = function() { if (this.hotelPageMap != false) return; this.hotelPageMap = this.prepareMap('maps_hotel_page_map'); } AllMaps.prototype.showHotelListMap = function() { if (this.hotelListMap != false) return; this.hotelListMap = this.prepareMap('maps_hotel_list_map'); } AllMaps.prototype.showHotelListMapForHotelID = function(id) { if (this.hotelListMap != false) { this.hotelListMap.centerOnGeoID(id, 'hotel'); return; } this.hotelListMap = this.prepareMap('maps_hotel_list_map'); this.hotelListMap.centerOnGeoID(id, 'hotel'); } AllMaps.prototype.showHotelListMapForHotelIDNoZoom = function(id) { if (this.hotelListMap != false) { this.hotelListMap.centerOnGeoIDNoZoom(id, 'hotel'); return; } this.hotelListMap = this.prepareMap('maps_hotel_list_map'); this.hotelListMap.centerOnGeoIDNoZoom(id, 'hotel'); } ////////////////////////////////////////////////////////////////////////////// window.SplendiaMaps = new AllMaps(); var MapsProfile = { ordering: [Pois, BabyHotels, Hotels, Cities, Countries], zoomContent: { 0: { countries: 1, cities: 0, babyHotels: 0, hotels: 0, pois: 0 }, 1: { countries: 1, cities: 0, babyHotels: 0, hotels: 0, pois: 0 }, 2: { countries: 1, cities: 0, babyHotels: 0, hotels: 0, pois: 0 }, 3: { countries: 1, cities: 0, babyHotels: 0, hotels: 0, pois: 0 }, 4: { countries: 1, cities: 0, babyHotels: 0, hotels: 0, pois: 0 }, 5: { countries: 0, cities: 2, babyHotels: 0, hotels: 0, pois: 0 }, 6: { countries: 0, cities: 2, babyHotels: 0, hotels: 0, pois: 0 }, 7: { countries: 0, cities: 2, babyHotels: 0, hotels: 0, pois: 0 }, 8: { countries: 0, cities: 2, babyHotels: 0, hotels: 0, pois: 0 }, 9: { countries: 0, cities: 2, babyHotels: 0, hotels: 0, pois: 0 }, 10: { countries: 0, cities: 2, babyHotels: 0, hotels: 1, pois: 0 }, 11: { countries: 0, cities: 2, babyHotels: 0, hotels: 2, pois: 1 }, 12: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 }, 13: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 }, 14: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 }, 15: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 }, 16: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 }, 17: { countries: 0, cities: 0, babyHotels: 0, hotels: 2, pois: 1 } } } window.map2LoadingRefCountIncr = function() { }; window.map2LoadingRefCountDecr = function() { }; var extraDeclarations = function() { /** * @author Marco Alionso Ramirez, marco@onemarco.com * @url http://onemarco.com * @version 1.0 * This code is public domain * * The Tooltip class is an addon designed for the Google Maps GMarker class. * @constructor * @param {GMarker} marker * @param {String} content * @param {Number} padding */ window.GCustomTooltip = function(marker, contentCB, padding){ this.marker = marker; this.contentCB = contentCB; this.padding = padding; this.div = null; this.map = null; } window.GCustomTooltip.prototype = new GOverlay(); window.GCustomTooltip.prototype.initialize = function(map){ this.map = map; } window.GCustomTooltip.prototype.customRealize = function() { var map = this.map; this.div = document.createElement("div"); var innerContainer = this.div.cloneNode(false); this.div.appendChild(innerContainer); this.div.style.position = 'absolute'; this.div.style.visibility = 'hidden'; this.shadowQuadrants = [{},{},{},{}] this.shadowQuadrants[0].div = document.createElement('div'); this.shadowQuadrants[0].div.style.position = 'absolute'; this.shadowQuadrants[0].div.style.overflow = 'hidden'; this.shadowQuadrants[0].img = createPngElement('/images/mapmarkers/2/tooltip_shadow.png'); this.shadowQuadrants[0].img.style.position = 'absolute'; this.shadowQuadrants[0].div.appendChild(this.shadowQuadrants[0].img); this.shadowQuadrants[1].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[1].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[1].div.appendChild(this.shadowQuadrants[1].img); this.shadowQuadrants[2].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[2].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[2].div.appendChild(this.shadowQuadrants[2].img); this.shadowQuadrants[3].div = this.shadowQuadrants[0].div.cloneNode(false); this.shadowQuadrants[3].img = this.shadowQuadrants[0].img.cloneNode(true); this.shadowQuadrants[3].div.appendChild(this.shadowQuadrants[3].img); this.shadowQuadrants[0].div.style.right = '0px'; this.shadowQuadrants[0].div.style.top = '0px'; this.shadowQuadrants[0].img.style.top = '0px'; this.shadowQuadrants[0].img.style.right = '0px'; this.shadowQuadrants[1].div.style.left = '0px'; this.shadowQuadrants[1].div.style.top = '0px'; this.shadowQuadrants[1].img.style.top = '0px'; this.shadowQuadrants[2].div.style.left = '0px'; this.shadowQuadrants[2].div.style.bottom = '0px'; this.shadowQuadrants[2].img.style.bottom = '0px'; this.shadowQuadrants[2].img.style.left = '0px'; this.shadowQuadrants[3].div.style.right = '0px'; this.shadowQuadrants[3].div.style.bottom = '0px'; this.shadowQuadrants[3].img.style.bottom = '0px'; this.shadow = this.div.cloneNode(false); this.shadow.appendChild(this.shadowQuadrants[0].div); this.shadow.appendChild(this.shadowQuadrants[1].div); this.shadow.appendChild(this.shadowQuadrants[2].div); this.shadow.appendChild(this.shadowQuadrants[3].div); innerContainer.className = 'tooltip'; var child = this.contentCB(); innerContainer.appendChild(child); map.getPane(G_MAP_FLOAT_PANE).appendChild(this.div); map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.shadow); //this.map = map; //draw tooltip var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint()); var iconAnchor = this.marker.getIcon().iconAnchor; var xPos = Math.round(markerPos.x - this.div.clientWidth / 2); var yPos = markerPos.y - iconAnchor.y - this.div.clientHeight - this.padding; this.div.style.top = yPos + 'px'; this.div.style.left = xPos + 'px'; //draw shadow //calculate shadow location shadowAnchor = new GPoint( markerPos.x + Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) , markerPos.y - Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) + 4); //calculate shadow dimenstions var shadowSize = new GSize(this.div.clientWidth + Math.round(this.div.clientHeight / 2) + 8, Math.round(this.div.clientHeight / 2) + 10); if(shadowSize.width % 2 == 1) shadowSize.width--; if(shadowSize.height % 2 == 1) shadowSize.height--; //apply shodaw location and dimensions this.shadow.style.left = (shadowAnchor.x - (shadowSize.width - shadowSize.height - 10 )/ 2) + 'px'; this.shadow.style.top = (shadowAnchor.y - shadowSize.height) + 'px'; this.shadow.style.width = (shadowSize.width) + 'px'; this.shadow.style.height = shadowSize.height + 'px'; //get quadrant dimensions var qHeight = shadowSize.height / 2; var qOddWidth = shadowSize.height > shadowSize.width ? shadowSize.height / 2: (shadowSize.width) / 2; var qEvenWidth = shadowSize.width - qOddWidth; //apply quadrant dimensions, calculate and apply Q2 and Q4 image offsets this.shadowQuadrants[0].div.style.width = qOddWidth + 'px'; this.shadowQuadrants[0].div.style.height = qHeight + 'px'; this.shadowQuadrants[1].div.style.width = qEvenWidth + 'px'; this.shadowQuadrants[1].div.style.height = qHeight + 'px'; this.shadowQuadrants[1].img.style.left = -(160 - shadowSize.height) + 'px'; this.shadowQuadrants[2].div.style.width = qOddWidth + 'px'; this.shadowQuadrants[2].div.style.height = qHeight + 'px'; this.shadowQuadrants[3].div.style.width = qEvenWidth + 'px'; this.shadowQuadrants[3].div.style.height = qHeight + 'px'; this.shadowQuadrants[3].img.style.right = -(160 - shadowSize.height) +'px'; } window.GCustomTooltip.prototype.remove = function(){ if (this.shadow) this.shadow.parentNode.removeChild(this.shadow); if (this.div) this.div.parentNode.removeChild(this.div); this.shadow = null; this.div = null; } window.GCustomTooltip.prototype.copy = function(){ var content = this.contentCB(); return new window.GCustomTooltip(this.marker,content,this.padding); } window.GCustomTooltip.prototype.redraw = function(force){ if (!force) return; //this.customRealize(); } window.GCustomTooltip.prototype.show = function(){ this.customRealize(); this.div.style.visibility = 'visible'; this.shadow.style.visibility = 'visible'; } window.GCustomTooltip.prototype.hide = function(){ /* if (this.div) { this.div.style.visibility = 'hidden'; } if (this.shadow) { this.shadow.style.visibility = 'hidden'; } */ this.remove(); } //utility function for png compatibility in IE6 var IS_IE = false; var IS_LT_IE7; //@cc_on IS_IE = true; //@cc_on IS_LT_IE7 = @_jscript_version < 5.7; function createPngElement(src) { var img = document.createElement('img'); img.setAttribute('src',src); if(IS_IE && IS_LT_IE7) { img.style.visibility = 'hidden'; var div = document.createElement('div'); div.appendChild(img); div.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\',sizingMethod=\'crop\')'; return div; } return img; } window.GCustomLegend = function () {} window.GCustomLegend.prototype = new GControl; window.GCustomLegend.prototype.initialize = function(map) { var me = this; this.loadingRefCount = 0; var html = '
'; html += ''; html += '
'; me.panel = $(html).get(0); map.getContainer().appendChild(me.panel); window.map2LoadingRefCountIncr = function() { me.loadingRefCount++; me.realizeLoading(); }; window.map2LoadingRefCountDecr = function() { me.loadingRefCount = me.loadingRefCount > 0 ? me.loadingRefCount - 1 : 0; me.realizeLoading(); }; return me.panel; } window.GCustomLegend.prototype.getDefaultPosition = function() { return new GControlPosition( G_ANCHOR_TOP_RIGHT, new GSize(10, 50) ); } window.GCustomLegend.prototype.realizeLoading = function() { if (this.loadingRefCount > 0) $('#map2LegendLoading').show(); else $('#map2LegendLoading').hide(); } window.GCustomLegend.prototype.setInnerHTML = function(html) { //this.panel.innerHTML = '
'+map2Trans.m_legend+'
' + html; $('#map2LegendInnerList').html('
'+map2Trans.m_legend+'
' + html); } }; }); SplendiaSoftReadyHandlers.push(function() { if ($('#maps_home_map').length > 0) { window.SplendiaMaps.showHomeMap(); } window.SplendiaMapsOpenHotelThumb = function(url) { window.map2LoadingRefCountIncr(); $('.map2_medium_hotel_popup .col_left img.big').load(function () { window.map2LoadingRefCountDecr(); }); $('.map2_medium_hotel_popup .col_left img.big').attr('src', url); } window.SplendiaMapsOpenHotelPage = function(url) { window.location = url; } }); function quoteString(str) { var c, i, l = str.length, o = ''; for (i = 0; i < l; i += 1) { c = str.charAt(i); if (c >= ' ') { if (c === '\\' || c === '"') { o += '\\'; } o += c; } else { switch (c) { case '\b': o += '\\b'; break; case '\f': o += '\\f'; break; case '\n': o += '\\n'; break; case '\r': o += '\\r'; break; case '\t': o += '\\t'; break; default: c = c.charCodeAt(); o += '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); } } } return o + ''; } // equal sized columns function equalHeights() { if ($('.home_layout').length > 0) { var containerH = $('.home_layout_wrapper').height() - 2; $('.home_layout_consumer').each(function() { if ($(this).hasClass('sub_column_right_with_borders')) { $(this).height(containerH - 20); } else { $(this).height(containerH); } }); } else { var containerH = $('.sizer_parent').height(); var headerAdjust = ($('.column_left_bot_box').length > 0) ? 209 : 0; $('.sizer_column_left').height(containerH - headerAdjust); $('.sizer_column_right').height(containerH); } } function cancelHeights() { if ($('.home_layout').length > 0) { $('.home_layout_consumer').css('height', 'auto'); } if ($('.column_left_bot_box').length > 0) { $('.column_left_bot_box').css('height', 'auto'); } $('.sizer_column_left, .sizer_column_right').css('height', 'auto'); } function balanceColumns() { setTimeout(function() { equalHeights(); }, 100); } function balanceColumnsSlow() { setTimeout(function() { cancelHeights(); equalHeights(); }, 500); } function cancelBalanceColumns() { cancelHeights(); } /** * Splendia State object * * This object holds a copy of all the javascript state that is required to build the * site correctly on each page load, also to do things like make sure certain data * parameters are available to javascript from the server side. * * There are certain actions taken in the php code that requires coordination with the * javascript functionality to enable or disable certain things, like popups, how they * react to button clicks, etc. * *** WARNING ****: this object will most likely disappear because now, there are better ways to do this which dont involve being retarded */ var Splendia = new Object(); Splendia.UI = new Object(); Splendia.UI.showMessage = function(message,text,status) { function stripHTML(input){ return input.replace(/<[^>]*>/g, ""); }; if(!message){ text.replace("
","\n"); text.replace("
","\n"); alert(stripHTML(text)); }else{ var type = (status == true) ? "success-message" : "error-message"; message.attr("class","message "+type); message.html(stripHTML(text)); message.show("slow"); } } Splendia.UI.hideMessage = function(message) { message.attr("class","message"); message.hide("slow"); message.html(""); } Splendia.Form = function(node,onSuccess,onMode) { var __node; var __onSuccess; var __onFailure; var __onComplete; var __onMode; var __onSend; this.constructor = function(node,onSuccess,onMode) { this.__node = $(node); this.__onSuccess = onSuccess || this.defaultSuccess; this.__onMode = onMode || this.defaultMode; this.__onSend = this.defaultSend; this.__onComplete = this.defaultComplete; this.__onFailure = this.defaultFailure; var submit = $("input.submit_button:not(.change-recaptcha)",this.__node); var change = $(".change-recaptcha",this.__node); var parentObject = this; this.reset(); submit.click(function(){ return parentObject.send($(this)); }); change.click(function(){ Recaptcha.reload(); return false; }); return this; } this.reset = function() { this.resetFormErrors(); Splendia.UI.hideMessage($(".message:not(.dont-erase)",this.__node)); } this.defaultSend = function(node) { }; this.setSendCallback = function(cb) { this.__onSend = cb; return this; }; this.defaultComplete = function(node) { }; this.setCompleteCallback = function(cb) { this.__onComplete = cb; return this; }; this.defaultSuccess = function(node) { }; this.setSuccessCallback = function(cb) { this.__onSuccess = cb; return this; }; this.defaultFailure = function(form,errors){} this.setFailureCallback = function(cb) { this.__onFailure = cb; return this; }; this.defaultMode = function(node) { return "ajax"; }; this.setModeCallback = function(cb) { this.__onMode = cb; return this; }; this.send = function(node) { this.__onSend(node); var mode = this.__onMode(node); switch(mode){ case "post": { return this.sendPOST(node); }break; case "ajax": { return this.sendAJAX(node); }break; }; return false; } this.sendPOST = function(node) { var form = node.parents().find("form").eq(0); this.reset(); form.submit(); return true; } this.sendAJAX = function(node) { var form = node.parents().find("form").eq(0); var sending = $(".sending",form); var action = $("input[name='action']",form).attr("value") || form.attr("action"); var message = $(".message",form); var parentObject = this; sending.css("visibility","visible"); this.reset(); $.post(action,form.serialize(),function(reply){ parentObject.__onComplete(node); sending.css("visibility","hidden"); Splendia.UI.showMessage(message,reply.message,reply.success); if(reply.success == false){ parentObject.processFormErrors(reply.errors,form); parentObject.__onFailure(form,reply.errors); }else{ parentObject.__onSuccess(node,reply.message); } },"json"); return false; } this.resetFormErrors = function() { var element = $("[name]",this.__node); element.removeClass("form-error-border"); if(element.attr("type") == "checkbox") element.parent().find("label").removeClass("form-error-background"); } this.processFormErrors = function(errors,form) { for(var a=0;a 12 ) ? currentHours - 12 : currentHours; // Convert an hours component of "0" to "12" currentHours = ( currentHours == 0 ) ? 12 : currentHours; // Compose the string for display var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay; // Update the time display $(".jsclock",popup).text(currentTimeString); }); } function initMisc() { // debug clicky clicky $('.version_string').click(function() { $('.debug_hide').toggle(); }); // default input text styling $('.default_input_text').bind('click.default_input_text focus.default_input_text', function () { $(this).removeClass('default_input_text'); }); // Open a form object to control the hotelier join form if($(".hotelier_join").length){ new Splendia.Form(".hotelier_join") .setSendCallback( function(node){ $(node).attr("disabled","disabled"); }) .setCompleteCallback( function(node){ $(node).attr("disabled",""); }) .setFailureCallback( function(form,errors){ var message = ""; for(a=0;a 1 && url.substring(0,1) == '/') window.location = url; }); $('.hotel_list_distance_select').change(function(ev) { var url = this.options[this.selectedIndex].value; if (url.length > 1) window.location = url; }); $('#hotel_header_view_all_cities').click(function() { $('.listing_header .mc').hide(); $('.listing_header .pc').show(); cancelBalanceColumns(); balanceColumns(); return false; }); var listTabClick = function (id) { $('#tab_' + id).show(); $('.details_tabs_container .hotel_list_tab_pane:not(#tab_' + id + ')').hide(); $('#' + id).addClass('selected'); $('.details_tabs_container .tab_chooser li:not(#' + id + ')').removeClass('selected'); if (id == 'c_list') { location.hash = '#list'; } if (id == 'c_map') { location.hash = '#map'; window.SplendiaMaps.showHotelListMap(); } cancelBalanceColumns(); balanceColumns(); } $('.details_tabs_container .tab_chooser li').click(function() { var id = $(this).attr('id'); listTabClick(id); }); $('.listing_hotel_map_link').click(function() { var hotelid = $(this).attr('hotelid'); listTabClick('c_map'); $.scrollTo('#hotel_list_page', 500); window.SplendiaMaps.showHotelListMapForHotelID(hotelid); return false; }); $('.hotel_list_map_tab_mini_list tr').click(function() { var hotelid = $(this).attr('hotelid'); window.SplendiaMaps.showHotelListMapForHotelIDNoZoom(hotelid); return false; }); $('.hotel_list_map_tab_mini_list tr').hover( function() { window.SplendiaMapsHilightHotel($(this).attr('hotelid')); }, function() { window.SplendiaMapsHilightHotel(0); } ); if (location.hash == '#list') { listTabClick('c_list'); } else if (location.hash == '#map') { listTabClick('c_map'); } $('.map_box img,.map_box .map_label').click(function() { $.scrollTo('#hotel_list_page', 500); listTabClick('c_map'); }); if ($('#listing_ad_area_id').length > 0) { var ad_interval = setInterval(function() { if ($("#listing_ad_area_id a[href*='empty.gif']").parents('div.listing_ad_area').hide().length > 0) { cancelBalanceColumns(); balanceColumns(); clearInterval(ad_interval); } }, 200); } } function initRetrievePasswordPage() { if ($('#ret_pass_box').length <= 0) { return; } var form = $('form'); var actionForgot = $("input[name='action_forgot']").val(); $("#submit").click(function() { $("#loading").css('display', 'inline-block'); $("#msg").hide(); $.post(actionForgot,form.serialize(),function(reply){ $("#loading").hide(); $("#msg").css('display', 'inline-block'); if (reply.success) { $("#msg").css('color', 'green'); } else { $("#msg").css('color', 'red'); } $("#msg").html(reply.message); },"json"); return false; }); } function initCurrencySelector() { // currency selector /* $('#currency_selector').click(function() { $('#currency_list').toggle(); return false; }); * */ $('#currency_list li a').click(function(ev) { $('#currency_selected').text($(ev.target).text()); //$('#currency_list').toggle(); }); } function initLanguageSelector() { // lang selector /*$('#lang_selector').click(function() { $('#lang_list').toggle(); return false; });*/ $('#lang_list li a').click(function(ev) { window.location = ev.target.href; }); } function initPageLoginForm() { var showForgot = function(){ var form = $(this).parents().find(".login_area form").eq(0); var actionForgot = $("input[name='action_forgot']",form); var message = $(".message",form); $(".password_area",form).hide(); $(".forgot_area",form).show(); Splendia.UI.hideMessage(message); form.attr("action",actionForgot.val()); return false; }; var hideForgot = function(){ var form = $(this).parents().find(".login_area form").eq(0); var actionLogin = $("input[name='action_login']",form); var message = $(".message",form); $(".password_area",form).show(); $(".forgot_area",form).hide(); Splendia.UI.hideMessage(message); form.attr("action",actionLogin.val()); return false; }; var success = function(button){ var form = $(button).parents().find(".login_area form").eq(0); var type = $("input[name='type']",form).val(); var actionLogin = $("input[name='action_login']",form); if((type == "club" || type == "booking") && form.attr("action") == actionLogin.val()) window.location.reload(); } var mode = function(button){ var form = $(button).parents().find(".login_area form").eq(0); var type = $("input[name='type']",form).val(); var actionLogin = $("input[name='action_login']",form); if(type == "hotel" && form.attr("action") == actionLogin.val()) return "post"; return "ajax"; } var form = $(".login_area form"); new Splendia.Form(form,success,mode); $(".remind_password",form).click(showForgot); $(".cancel_recovery",form).click(hideForgot); } function initClubHotels() { if ($('#club_hotels_page').length <= 0) return; var clubHotelSelected = false; var openCountry = function(event){ closeCountry(event); clubHotelSelected = $(this); clubHotelSelected.addClass("show_country"); cancelBalanceColumns(); balanceColumns(); return false; }; var closeCountry = function(event){ if(clubHotelSelected) clubHotelSelected.removeClass("show_country"); } $(".club_hotels .country").each(function(){ $(this).click(openCountry); }); $(".club_hotels .country .city a").each(function(){ $(this).click(function(){ window.location = $(this).attr("href"); }); }); } function initBooking() { if ($('#booking_page').length <= 0) { return; } $('#book_retrive_password_link').click(function() { var newwindow=window.open($('#book_retrive_password_link').attr('href'), 'name', 'height=180,width=400,address=no,location=no'); //,resizable=0,scrollbars=0,toolbar=0,menubar=0,location=0,status=0,directories=0'); if (window.focus) {newwindow.focus()} return false; }); $('#booking_open_promo').click(function() { $('.booking_promo_form').show(); $('.booking_promo_trig').hide(); return false; }); $('#booking_close_promo').click(function() { $('.booking_promo_form').hide(); $('.booking_promo_trig').show(); return false; }); $('.booking_content_inv input, .booking_content_inv select').bind('change focus', function() { $(this).parents().removeClass('fail'); $(this).parents().removeClass('fail2'); }); // affiliates form takes advantage of this too $('.affiliates_content input, .affiliates_content select').bind('change focus', function() { $(this).parents().removeClass('fail'); }); $('.book_optional_text').bind('change focus', function() { $(this).val(''); $(this).removeClass('book_optional_text'); $(this).unbind('change focus'); }); $('#book_club_wish_to_join,#book_club_wish_to_join_label').click(function() { if ($('#book_club_wish_to_join').is(':checked')) { $('#optional_club_creation_sub_form').addClass('creation_enabled'); $('#book_club_login_now').removeAttr('checked'); $('#optional_club_login_sub_form').hide(); $('#book_club_login_now').hide(); $('#book_club_login_now_label').hide(); } else { $('#optional_club_creation_sub_form').removeClass('creation_enabled'); $('#book_club_login_now').show(); $('#book_club_login_now_label').show(); } }); $('#book_club_login_now,#book_club_login_now_label').click(function() { if ($('#book_club_login_now').is(':checked')) { $('#optional_club_login_sub_form').show(); $('#book_club_wish_to_join').removeAttr('checked'); $('#optional_club_creation_sub_form').removeClass('creation_enabled'); $('#book_club_wish_to_join').hide(); $('#book_club_wish_to_join_label').hide(); } else { $('#optional_club_login_sub_form').hide(); $('#book_club_wish_to_join').show(); $('#book_club_wish_to_join_label').show(); } }); $('#book_submit_button').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('book'); $('#proposal_mode').val('no'); $('#book_submit_button,#book_submit_button_proposal').attr("disabled", "disabled"); $('.book_submit_indicator').css('visibility', 'visible'); document.bookform.submit(); }); $('#book_submit_button_proposal').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('book'); $('#proposal_mode').val('yes'); $('#book_submit_button,#book_submit_button_proposal').attr("disabled", "disabled"); $('.book_submit_indicator').css('visibility', 'visible'); document.bookform.submit(); }); $('#book_club_login_submit').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('login'); document.bookform.submit(); }); $('#book_promocode_submit').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('promocode'); document.bookform.submit(); }); $('#book_promocode_cancel_submit').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('promocodecancel'); document.bookform.submit(); }); $('#book_club_register_submit').click(function() { $('.book_optional_text').val(''); $('#submit_mode').val('register'); document.bookform.submit(); }); var bookingRemoveSameCurrency = function() { var selected = $('#payment_currency option:selected').val(); var def = $('#payment_currency').attr('defcur'); if (selected == def) { $('#payment_currency_equiv').hide(); } else { $('#payment_currency_equiv').show(); } $('.curr_selector_alt_price').hide(); $('.curr_selector_price_for_' + selected).show(); }; bookingRemoveSameCurrency(); $('#payment_currency').change(bookingRemoveSameCurrency); $('#booking_cancel_policy_link').click(function() { $('#booking_extra_info').toggle(); }); $('#book_options_toggler').click(function() { $('.options_block').toggle(); $('#book_options_toggler .disabled').toggle(); $('#book_options_toggler .enabled').toggle(); return false; }); } function initHotelDetails() { if ($('#hotel_page').length <= 0) { return; } $('.collapser').click(function() { var id = 'landmarks_' + $(this).attr('id'); $('#' + id + ' li.hide').toggle(); $('#' + id + ' a span.h').toggle(); $('#' + id + ' a span.s').toggle(); cancelBalanceColumns(); balanceColumns(); return false; }); // url details var detailTabClick = function (id) { $('.hotel_details #tab_' + id).show(); $('.hotel_details .details_tabs_container .tab:not(#tab_' + id + ')').hide(); $('.hotel_details #' + id).addClass('selected'); $('.hotel_details .details_tabs_container .tab_chooser li:not(#' + id + ')').removeClass('selected'); if (id == 'c_info') { location.hash = '#info'; } if (id == 'c_desc') { location.hash = '#desc'; } if (id == 'c_review') { location.hash = '#review'; } if (id == 'c_price') { location.hash = '#price'; } if (id == 'c_video') { location.hash = '#video'; } if (id == 'c_book') { location.hash = '#booking'; } cancelBalanceColumns(); balanceColumns(); } $('.hotel_details .details_tabs_container .tab_chooser li').click(function() { var id = $(this).attr('id'); detailTabClick(id); }); $(".hotel_page_map_link").click(function() { $.scrollTo('#hotelPageHotelSubInfo', 500); detailTabClick('c_map'); return false; }); $('.hotel_details li.rec').click(function() { detailTabClick('c_review'); }); if (location.hash == '#rooms') { detailTabClick('c_rooms'); } else if (location.hash == '#desc') { detailTabClick('c_desc'); } else if (location.hash == '#review') { detailTabClick('c_review'); } else if (location.hash == '#map' || location.hash == '#mapta') { if (location.hash == '#mapta') { $.scrollTo('#hotelPageHotelSubInfo', 500); } detailTabClick('c_map'); } $('.map_box .img,.map_box .map_label,.map_box .map_hotel_marker').click(function() { $.scrollTo('#hotelPageHotelSubInfo', 500); detailTabClick('c_map'); }); // in-column button $('.submitBooking').click(function() { if (BookingHotelPageNeedsRooms()) { detailTabClick('c_rooms'); BookingFlashRoomSelection(); } else { $('.submitBooking,.submitBookingTop').attr("disabled", "disabled"); BookingSubmitStart(); } }); // in-column button - pegasus $('.submitBookingPegasus').click(function() { var $el = $(this); var prod = $el.attr('prod'); var rooms = $el.attr('rooms'); var adults = $el.attr('adults'); BookingSubmitStartPegasus(prod, rooms, adults); }); // out of column button, always available $('.submitBookingTop').click(function() { var needsDates = BookingHotelPageNeedsDates(); var needsRooms = BookingHotelPageNeedsRooms(); if (needsDates) { detailTabClick('c_rooms'); BookingFlashDateSelection(); } else { if (!needsDates && roomPageOkToSendDates) { hotelPageSearchButtonAction(); } else { if (needsRooms) { detailTabClick('c_rooms'); BookingFlashRoomSelection(); } if (!needsDates && !needsRooms) { $('.submitBooking,.submitBookingTop').attr("disabled", "disabled"); BookingSubmitStart(); } } } }); // desc link $('#hp_view_full_desc').click(function() { detailTabClick('c_desc'); $.scrollTo('#hotelPageHotelSubInfo', 500); return false; }); // lower room link $('.hp_lower_room_link,.hp_lower_room_link_desc').click(function() { detailTabClick('c_rooms'); BookingFlashDateSelection(); return false; }); // avail calendars $.each(bookingRoomNoRoomsCalendar, function(k, v) { // calendar 2.0 var callbacksBase = function() { }; callbacksBase.prototype = { getMonthName: function(month) { return datepickerRegional.monthNames[month]; }, getDayName: function(day) { if (day == 6) return datepickerRegional.dayNamesMin[0]; return datepickerRegional.dayNamesMin[day+1]; }, getClose: function() { return searchBoxTranslations['s_close']; }, getToday: function() { return searchBoxTodayDate; } }; var initialSearchBoxStartDate = searchBoxStartDate; var callbacksS = new callbacksBase(); callbacksS.getSelected = function() { return initialSearchBoxStartDate; } callbacksS.getLabel = function() { return ''; } callbacksS.selectionMade = function(selected) { } var cal = new SplendiaCalendar('#' + k + ' .sc_container', '', [], callbacksS); cal.setSingleMonth(true); cal.setNoHide(true); cal.setNoSelection(true); cal.setDispMap(v); cal.renderInline($('#' + k + ' .sc_container')); }); $('.hotel_rooms_dates_bar_change').click(function() { $('#rooms_header_with_dates,.rooms_header_no_rooms,.msg_no_rooms').hide(); $('#rooms_header').show(); cancelBalanceColumns(); balanceColumns(); return false; }); $('.hotel_rooms_dates_bar_change2').click(function() { $('#rooms_header_with_dates,.rooms_header_no_rooms,.msg_no_rooms').hide(); $('#rooms_header').show(); //detailTabClick('c_rooms'); BookingFlashDateSelection(); cancelBalanceColumns(); balanceColumns(); return false; }); $('.comments_filter li').click(function() { var r = $(this).attr('restrict'); $('.comments_filter li').removeClass('toggled'); $(this).addClass('toggled'); $('.customer_comments li').each(function() { if ($(this).attr('belongsto').indexOf(r) >= 0) $(this).show(); else $(this).hide(); }); }); $('#rating_sort_select').change(function() { var at = $(this).val(); var orig = $.makeArray($('.customer_comments li')); var comp = function(a, b) { if ($(a).attr(at) < $(b).attr(at)) return -1; else if ($(a).attr(at) > $(b).attr(at)) return 1; else return 0; }; var compI = function(a, b) { if ($(a).attr(at) > $(b).attr(at)) return -1; else if ($(a).attr(at) < $(b).attr(at)) return 1; else return 0; }; orig.sort(at == 'default' ? comp : compI); $('.customer_comments').html(''); $.each(orig, function() { $('.customer_comments').append(this); }); }); var prodTableSelectChange = function() { var id = $(this).attr('id'); var rate = $(this).attr('restrictrate'); var totalExistingRates = { 'nonrefun' : 0, 'normal' : 0 }; var totalRates = { 'nonrefun' : 0, 'normal' : 0 }; var totalRateNonrefun = 0; var totalRateNormal = 0; var totalSelection = 0; // count first $('table.prod_table select').each(function() { var thisRate = $(this).attr('restrictrate'); totalRates[thisRate] += this.selectedIndex; totalExistingRates[thisRate]++; totalSelection += this.selectedIndex; }); // restrict second $('table.prod_table select').each(function() { var thisRate = $(this).attr('restrictrate'); if (thisRate != rate && totalRates[rate] > 0) { this.selectedIndex = 0; $(this).attr('disabled', 'disabled'); } else { $(this).removeAttr('disabled'); } }); // message if needed if (totalSelection > 0 && totalExistingRates['nonrefun'] > 0 && totalExistingRates['normal'] > 0) { $('.warn_mixed_rates').show(); } else { $('.warn_mixed_rates').hide(); } var parentID = $(this).parents('.room_block').attr('id'); BookingRecalcProductAvailSelection(parentID); var r = BookingBuildProductSelection(); bookingRoomSelection = r.sel; var i = r.total; var s = r.query; $('.totalRooms').html(''+i); $('.totalPrice').html('...'); var e = BookingBuildProductSelectionExtras(); $.getJSON( '/index.php?resource=ajax&component=AjaxChangeProducts', { 'product_selection' : s, 'product_hotel_id' : searchFixedHotel, 'product_datestart' : initialDatestart, 'product_dateend' : initialDateend, 'detailed_extras' : e.query }, function(data) { bookingRoomSubtotals = data.prices; bookingRoomTotal = data.total; BookingUpdatePrices(); if (data.enableextras) { $('.sideRoomHasExtra').show(); $('.sideRoomHasExtra').html(data.totalextras); } else { $('.sideRoomHasExtra').hide(); } // in-tab part: change link label $.each(data.briefs, function(k, v) { if (v == '') $('#prod_block_id_' + k + ' .extra_bed_popup_trigger').html($('#prod_block_id_' + k + ' .extra_bed_popup_trigger').attr('orig')); else $('#prod_block_id_' + k + ' .extra_bed_popup_trigger').html(v); }); } ); } $('.prod_table_select').change(prodTableSelectChange); $('.product_info_popup_trigger2').click(function() { var id = $(this).attr('id'); $('#popup_' + id).toggle(); $('.occ_info_popup:not(#popup_' + id + ')').hide(); return false; }); $('.occ_info_popup .close').click(function() { $(this).parents('.occ_info_popup').hide(); }); $('.room_desc_popup_trigger').click(function() { var id = $(this).attr('id').substring(6); $('.desc_room_image_selector').removeClass('desc_room_image_selector_current'); $('.desc_room_image').hide(); $('#' + id + ' .desc_room_image:first').show(); $('#' + id + ' .desc_room_image_selector:first').addClass('desc_room_image_selector_current'); $('body').append($('#' + id).get(0)); var breath = ($(window).height() - $(this).height()); $('#' + id).css('left', ($(window).width() - 500)/2 + 'px'); $('#' + id).css('top', (100 + $(window).scrollTop()) + 'px'); $('#' + id).toggle(); $('.desc_popup:not(#' + id + ')').hide(); return false; }); $('.desc_popup .close').click(function() { $(this).parents('.desc_popup').hide(); }); $('.hotel_rooms_no_rooms_city_link').click(function() { window.location = $(this).attr('link'); return false; }); $('.desc_room_image_selector').click(function() { var id = $(this).attr('id'); $('.desc_room_image:not(#full_' + id + ')').hide(); $('#full_' + id).show(); $('.desc_room_image_selector').removeClass('desc_room_image_selector_current'); $(this).addClass('desc_room_image_selector_current'); return false; }); $('.pegasus_popup_trigger').click(function() { var id = $(this).attr('id').substring(6); var ajax = $(this).attr('ajax'); $.get(ajax, function(data) { $('#' + id + ' .remote').html(data); }); $('body').append($('#' + id).get(0)); var breath = ($(window).height() - $(this).height()); $('#' + id).css('left', ($(window).width() - 500)/2 + 'px'); $('#' + id).css('top', (100 + $(window).scrollTop()) + 'px'); $('.pegasus_popup:not(#' + id + ')').hide(); $('#' + id).show(); return false; }); $('.pegasus_popup .close').click(function() { $(this).parents('.pegasus_popup').hide(); $('.room_desc_popup_extra_filler').hide(); cancelBalanceColumns(); balanceColumns(); }); var BuildExtraBedModel = function(subnode) { var pop = $(subnode).parents('.extra_bed_popup').get(0); var model = { }; model.extraArrayInstances = function() { var r = []; for (var i = 1; i <= this.maxRooms; i++) { if (i > this.currentRooms) continue; var inst = this.instances[i]; r.push({"adults": (inst.adults - this.capacityAdults) , "children" : inst.children, "babies" : inst.babies }); } return r; } // static limits model['prodID'] = $('table', pop).attr('prod'); model['maxRooms'] = parseInt($('.ep_rooms', pop).attr('max')); model['maxGuests'] = parseInt($('.ep_rooms', pop).attr('maxguests')); model['maxAdults'] = parseInt($('.ep_adults', pop).attr('nativemax')); model['capacityAdults'] = parseInt($('.ep_adults', pop).attr('capacity')); model['maxChildren'] = parseInt($('.ep_children', pop).attr('nativemax')); model['maxBabies'] = parseInt($('.ep_babies', pop).attr('nativemax')); model['instances'] = { }; // current values model['currentRooms'] = parseInt($('.ep_rooms select', pop).val()); for (var i = 1; i <= model.maxRooms; i++) { var row = $('tbody tr[instance='+i+']', pop); model.instances[i] = { 'adults' : parseInt($('.ip_adults select', row).val()), 'children' : model.maxChildren > 0 ? (parseInt($('.ip_children select', row).val())) : 0, 'babies' : model.maxBabies > 0 ? (parseInt($('.ip_babies select', row).val())) : 0 } } return model; } var FixExtraBedModel = function(model) { for (var i = 1; i <= model.maxRooms; i++) { var inst = model.instances[i]; var extrasOccupiedByAdults = inst.adults - model.capacityAdults; extrasOccupiedByAdults = extrasOccupiedByAdults > 0 ? extrasOccupiedByAdults : 0; var extrasOccupiedByChildren = inst.children; var extrasOccupiedByBabies = inst.babies; var extrasOccupied = extrasOccupiedByAdults + extrasOccupiedByChildren + extrasOccupiedByBabies; inst['maxAdults'] = model.maxAdults - extrasOccupied; inst['maxChildren'] = model.maxChildren - extrasOccupied; inst['maxBabies'] = model.maxBabies - extrasOccupied; if (inst.adults > inst.maxAdults) inst.maxAdults = inst.adults; if (inst.children > inst.maxChildren) inst.maxChildren = inst.children; if (inst.babies > inst.maxBabies) inst.maxBabies = inst.babies; } var tA = 0; var eA = 0; var eC = 0; var eB = 0; for (var i = 1; i <= model.maxRooms; i++) { if (i > model.currentRooms) continue; var inst = model.instances[i]; tA += inst.adults; eA += inst.adults - model.capacityAdults; eC += inst.children; eB += inst.babies; } model.summary = { 'totalAdults' : tA, 'extraAdults' : eA, 'extraChildren' : eC, 'extraBabies' : eB } // in-tab part: add extras extrasByProductID[model.prodID] = model.extraArrayInstances(); } var ApplyExtraBedModel = function(subnode, model) { var pop = $(subnode).parents('.extra_bed_popup').get(0); var fillOption = function(j, n, sel) { var r = ''; for (; j <= n; j++) { r += (sel == j ? ''; } return r; }; for (var i = 1; i <= model.maxRooms; i++) { var row = $('tbody tr[instance='+i+']', pop); var inst = model.instances[i]; // show/hide if (i <= model.currentRooms) { row.show(); } else { row.hide(); } // replace selects $('.ip_adults select', row).html(fillOption(model.capacityAdults, inst.maxAdults, inst.adults)); $('.ip_children select', row).html(fillOption(0, inst.maxChildren, inst.children)); $('.ip_babies select', row).html(fillOption(0, inst.maxBabies, inst.babies)); } } var RecalcExtraBedTotals = function(subnode, model) { var pop = $(subnode).parents('.extra_bed_popup').get(0); $('tfoot .tp_adults', pop).html('' + model.summary.totalAdults); $('tfoot .tp_children', pop).html('' + model.summary.extraChildren); $('tfoot .tp_babies', pop).html('' + model.summary.extraBabies); var extras = '['; var comma = ''; for (var i = 1; i <= model.maxRooms; i++) { if (i > model.currentRooms) continue; var inst = model.instances[i]; extras += comma + '{"adults":' + (inst.adults - model.capacityAdults) + ',"children":' + inst.children + ',"babies":' + inst.babies+'}'; comma = ','; } extras += ']'; var url = $('table', pop).attr('info'); $.get(url, { 'extras' : extras }, function(data) { for (var i = 1, j = 0; i <= model.maxRooms; i++, j++) { if (i > model.currentRooms) continue; var row = $('tbody tr[instance='+i+']', pop); $('.ip_total', row).html(data.prods[j].cost); } $('.tp_total', pop).html(data.total); }, 'json'); } $('.extra_bed_popup_trigger').click(function() { var url = $(this).attr('url'); var popupID = $(this).attr('popupid'); var prodID = $(this).attr('prodid'); var needsLoad = false; if ($('#' + popupID).length <= 0) { var frag = $('
'); $('body').append(frag); var breath = ($(window).height() - $('#' + popupID).height()); $('#' + popupID).css('left', ($(window).width() - 500)/2 + 'px'); $('#' + popupID).css('top', (100 + $(window).scrollTop()) + 'px'); needsLoad = true; } else { $('#' + popupID).show(); } var postLoad = function() { // always repeat recentering of the popup var breath = ($(window).height() - $('#' + popupID).height()); $('#' + popupID).css('left', ($(window).width() - 500)/2 + 'px'); $('#' + popupID).css('top', (100 + $(window).scrollTop()) + 'px'); var node = $('#' + popupID + ' table'); var model = BuildExtraBedModel(node); FixExtraBedModel(model); ApplyExtraBedModel(node, model); RecalcExtraBedTotals(node, model); } if (needsLoad) { $.get(url, function(data) { $('#' + popupID).html(data); $('#' + popupID +' table select').change(function() { var model = BuildExtraBedModel(this); FixExtraBedModel(model); ApplyExtraBedModel(this, model); RecalcExtraBedTotals(this, model) }); $('#' + popupID + ' .controlrow input').click(function() { $(this).parents('.extra_bed_popup').hide(); cancelBalanceColumns(); balanceColumns(); // in-tab part: change room selection var model = BuildExtraBedModel(this); FixExtraBedModel(model); $('#prod' + prodID).val(''+model.currentRooms); prodTableSelectChange(); }); $('#' + popupID + ' .close').click(function() { $(this).parents('.extra_bed_popup').hide(); cancelBalanceColumns(); balanceColumns(); }); $('#' + popupID + ' .controlrow a').click(function() { $(this).parents('.extra_bed_popup').hide(); cancelBalanceColumns(); balanceColumns(); return false; }); postLoad(); }, 'html'); } else { postLoad(); } return false; }); } // FIXME: This should be removed, it's not used anymore. function initHotelAccess() { var popup = $("#hotelier_remind_password .popup"); var form = $("#hotelier_remind_password .popup form"); $("#hotelier_remind_password a").click(function(){ if(form.length == 0) return false; popup.show(); return false; }); $("#hotelier_remind_password .popup .close_button").click(function(){ popup.hide(); return false; }); $("#hotelier_remind_password .popup .submit").click(function(){ var data = form.serialize(); $.post(form.attr("action"),data,function(data){ alert("success = "+data.success); },"json"); return false; }); } function BookingSubmitStart() { var r = BookingBuildProductSelection(); var e = BookingBuildProductSelectionExtras(); window.location = '/index.php?resource=redirector&component=RedirectStartBooking&mode=splendia' + '&datestart=' + encodeURIComponent(searchBoxStartDate) + '&dateend=' + encodeURIComponent(searchBoxEndDate) + '&extras=' + encodeURIComponent(e.query) + '&product_selection=' + encodeURIComponent(r.query) ; } function BookingSubmitStartPegasus(prod, rooms, adults) { window.location = '/index.php?resource=redirector&component=RedirectStartBooking&mode=pegasus' + '&datestart=' + encodeURIComponent(searchBoxStartDate) + '&dateend=' + encodeURIComponent(searchBoxEndDate) + '&prod=' + encodeURIComponent(prod) + '&rooms=' + encodeURIComponent(rooms) + '&adults=' + encodeURIComponent(adults) ; } function BookingRecalcProductAvailSelection(id) { var fillOption = function(n) { var r = ''; for (var j = 0; j <= n; j++) { r += ''; } return r; }; var max = bookingRoomMaxAvail[id]; var selected = 0; $('#' + id + ' select').each(function() { selected += this.selectedIndex; }); var available = max - selected; $('#' + id + ' select').each(function() { var i = this.selectedIndex; var localAvail = available + this.selectedIndex; //if (i < localAvail) { $(this).html(fillOption(localAvail)); this.selectedIndex = i; //} }); } function BookingBuildProductSelection() { var selection = { }; var s = '{'; var first = true; var i = 0; $('table.prod_table select').each(function() { if (!first) s = s + ','; var id = this.getAttribute('id').substring(4); var val = this.selectedIndex; selection[id] = val; i = i + parseInt(val); s = s + '"' + id + '" : "' + val + '"'; first = false; }); s = s + '}'; return { 'total': i, 'sel': selection, 'query': s }; } function BookingBuildProductSelectionExtras() { var s = '{'; var first = true; $.each(extrasByProductID, function (k, v) { var val = ''; var first2 = true; $.each(v, function (i, w) { if (!first2) val = val + ','; val = val + '{"adults":' + w.adults + ', "children":' + w.children + ', "babies":' + w.babies + '}'; first2 = false; }); if (!first) s = s + ','; s = s + '"' + k + '" : [' + val + ']'; first = false; }); s = s + '}'; return { 'query': s }; } function BookingHotelPageNeedsDates() { return searchBoxStartDate == false || searchBoxEndDate == false; } function BookingHotelPageNeedsRooms() { var total = 0; $('table.prod_table select').each(function() { total += this.selectedIndex; }); return total <= 0; } function BookingFlashDateSelection() { $.scrollTo('#hotelPageHotelSubInfo', 500); if ($('.rooms_header_no_rooms:visible').length <= 0) { $('.submitBookingTopErr').show().animate({color: '#888888'}, 360) .animate({color: '#888888'}, 5720) .animate({color: 'white'}, 360); } /* $('#rooms_header').animate({ backgroundColor: 'white' }, 360) .animate( { backgroundColor: '#F1F0EE' }, 360) .animate( { backgroundColor: 'white' }, 360) .animate( { backgroundColor: '#F1F0EE' }, 360); */ $('.date_picker_input_tab').animate({ backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150); } function BookingFlashRoomSelection() { $.scrollTo('#hotelPageHotelSubInfo', 500); $('.sideNoRoomsMsg').show().animate({color: '#888888'}, 360) .animate({color: '#888888'}, 5720) .animate({color: 'white'}, 360); $('table.prod_table select').animate({ backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150) .animate( { backgroundColor: 'rgb(254,239,131)' }, 150) .animate( { backgroundColor: 'white' }, 150); } function BookingUpdatePrices() { $.each(bookingRoomSubtotals, function(k, v) { $('#sub' + k).html(''+v); }); $('.totalPrice').html(''+bookingRoomTotal); } function FacilitiesSendAjax() { var q = []; $.each(FacilitiesMarked, function(k, v) { if (v) { q.push(k); } }); var q2 = q.join(','); $.get( '/index.php', { 'resource' : 'ajax', 'component' : 'AjaxSaveAdvanced', 'q' : q2 } ); } function FacilitiesRebuildListing() { var htmlA = []; var htmlB = []; var htmlC = []; var total = 0; var totalMarked = 0; $.each(FacilitiesAvailable, function(k, v) { var marked = FacilitiesMarked[k]; var name = FacilitiesTrans[k]; var html = '
  • ' + v + '
    ' + name + '
  • '; totalMarked += marked ? 1 : 0; if (FacilitiesCat[k] == 'a') { htmlA.push({ 'name' : name, 'html' : html }); } else if (FacilitiesCat[k] == 'b') { htmlB.push({ 'name' : name, 'html' : html }); } else { if (parseInt(k) < 10000) { htmlC.push({ 'name' : name, 'html' : html }); } else { $('.hotel_listing .virtual_facility_offers input').get(0).checked = marked; if (v <= 0) $('.hotel_listing .virtual_facility_offers input').attr('disabled', 'disabled'); else $('.hotel_listing .virtual_facility_offers input').removeAttr('disabled'); } } total++; }); var comp = function(a, b) { if (a.name < b.name) return -1; else if (a.name > b.name) return 1; else return 0; }; htmlA.sort(comp); htmlB.sort(comp); htmlC.sort(comp); var phtmlA = ''; $.each(htmlA, function() { phtmlA += this.html; }); var phtmlB = ''; $.each(htmlB, function() { phtmlB += this.html; }); var phtmlC = ''; $.each(htmlC, function() { phtmlC += this.html; }); $('#facilitiesA').html(phtmlA); $('#facilitiesB').html(phtmlB); $('#facilitiesC').html(phtmlC); if (total <= 0) { $('.hide_when_no_hotels').hide(); return; } $('.facilityC:not(.zeroF)').click(function() { FacilitiesToggle($(this).attr('faid')); FacilitiesResolve(); FacilitiesRebuildListing(); FacilitiesSendAjax(); }); var iListing = 0; var iNearby = 0; $.each(FacilitiesHotel, function(k, hotel) { if (FacilitiesHotelIsPresent(hotel.facilities)) { $('#hotel' + hotel.id).show(); if ($('#hotel' + hotel.id).attr('nearby') == 'yes') { iNearby = iNearby + 1; } else { iListing = iListing + 1; } } else { $('#hotel' + hotel.id).hide(); } }); $('#listing_found_count').html('' + iListing); $('#listing_found_nearby_count').html('' + iNearby); if (iNearby <= 0) $('.listing_separator_title').hide(); else $('.listing_separator_title').show(); if (totalMarked > 0) { $('.listing_found_count_total').show(); $('.view_all_hotels_remove_filters').show(); } else { $('.listing_found_count_total').hide(); $('.view_all_hotels_remove_filters').hide(); } cancelBalanceColumns(); balanceColumns(); } function FacilitiesToggle(f) { FacilitiesMarked[f] = !FacilitiesMarked[f]; } function FacilitiesInitialMarks() { // all the possible facilities, unfiltered $.each(FacilitiesHotel, function(k, hotel) { $.each(hotel.facilities, function(k2, v) { FacilitiesMarked[k2] = false; }); }); } function FacilitiesHotelIsPresent(facilities) { // test 2: it has all marked facilities var test2 = true; $.each(FacilitiesMarked, function(k2, v2) { if (v2) { test2 = test2 && facilities[k2]; } }); return test2; } function FacilitiesAreValid(facilities, current) { // the hotel "passes the exam" when it complies with BOTH: // it has the current facility // it has all marked facilities // test 1: it has the current facility var test1 = false; $.each(facilities, function(k2, v2) { test1 = test1 || (k2 == current); }); // test 2: it has all marked facilities var test2 = true; $.each(FacilitiesMarked, function(k2, v2) { if (v2) { test2 = test2 && facilities[k2]; } }); return test1 && test2; } function FacilitiesResolve() { FacilitiesAvailable = { }; // all the possible facilities, unfiltered $.each(FacilitiesHotel, function(k, hotel) { $.each(hotel.facilities, function(k2, v) { FacilitiesAvailable[k2] = 0; }); }); // now fix the counts $.each(FacilitiesAvailable, function(k, v) { $.each(FacilitiesHotel, function(kh, hotel) { if (FacilitiesAreValid(hotel.facilities, k)) { FacilitiesAvailable[k]++; } }); }); } SplendiaSoftReadyHandlers.push(function() { initMisc(); initCurrencySelector(); initLanguageSelector(); Jobs.setup(); // Job satellite setup FAQS.setup(); // FAQS satellite setup Popup.instance = new Popup(); SendToFriend.instance = new SendToFriend(); initHotelList(); initHotelDetails(); initBooking(); initPageLoginForm(); initClubHotels(); initRetrievePasswordPage(); }); /* * jQuery Color Animations * Copyright 2007 John Resig * Released under the MIT and GPL licenses. */ (function(jQuery){ // We override the animation for all of these color styles jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ jQuery.fx.step[attr] = function(fx){ if ( fx.state == 0 ) { fx.start = getColor( fx.elem, attr ); fx.end = getRGB( fx.end ); } fx.elem.style[attr] = "rgb(" + [ Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0) ].join(",") + ")"; } }); // Color Conversion functions from highlightFade // By Blair Mitchelmore // http://jquery.offput.ca/highlightFade/ // Parse strings looking for color tuples [255,255,255] function getRGB(color) { var result; // Check if we're already dealing with an array of colors if ( color && color.constructor == Array && color.length == 3 ) return color; // Look for rgb(num,num,num) if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; // Look for rgb(num%,num%,num%) if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; // Look for #a0b1c2 if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; // Look for #fff if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; // Otherwise, we're most likely dealing with a named color return colors[jQuery.trim(color).toLowerCase()]; } function getColor(elem, attr) { var color; do { color = jQuery.curCSS(elem, attr); // Keep going until we find an element that has color, or we hit the body if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") ) break; attr = "backgroundColor"; } while ( elem = elem.parentNode ); return getRGB(color); }; // Some named colors to work with // From Interface by Stefan Petre // http://interface.eyecon.ro/ var colors = { aqua:[0,255,255], azure:[240,255,255], beige:[245,245,220], black:[0,0,0], blue:[0,0,255], brown:[165,42,42], cyan:[0,255,255], darkblue:[0,0,139], darkcyan:[0,139,139], darkgrey:[169,169,169], darkgreen:[0,100,0], darkkhaki:[189,183,107], darkmagenta:[139,0,139], darkolivegreen:[85,107,47], darkorange:[255,140,0], darkorchid:[153,50,204], darkred:[139,0,0], darksalmon:[233,150,122], darkviolet:[148,0,211], fuchsia:[255,0,255], gold:[255,215,0], green:[0,128,0], indigo:[75,0,130], khaki:[240,230,140], lightblue:[173,216,230], lightcyan:[224,255,255], lightgreen:[144,238,144], lightgrey:[211,211,211], lightpink:[255,182,193], lightyellow:[255,255,224], lime:[0,255,0], magenta:[255,0,255], maroon:[128,0,0], navy:[0,0,128], olive:[128,128,0], orange:[255,165,0], pink:[255,192,203], purple:[128,0,128], violet:[128,0,128], red:[255,0,0], silver:[192,192,192], white:[255,255,255], yellow:[255,255,0] }; })(jQuery); // Some mousewheel plugin I wanted for jquery /** * * credits for this plugin go to brandonaaron.net * * unfortunately his site is down * * @param {Object} up * @param {Object} down * @param {Object} preventDefault */ jQuery.fn.extend({ mousewheel: function(up, down, preventDefault) { return this.hover( function() { jQuery.event.mousewheel.giveFocus(this, up, down, preventDefault); }, function() { jQuery.event.mousewheel.removeFocus(this); } ); }, mousewheeldown: function(fn, preventDefault) { return this.mousewheel(function(){}, fn, preventDefault); }, mousewheelup: function(fn, preventDefault) { return this.mousewheel(fn, function(){}, preventDefault); }, unmousewheel: function() { return this.each(function() { jQuery(this).unmouseover().unmouseout(); jQuery.event.mousewheel.removeFocus(this); }); }, unmousewheeldown: jQuery.fn.unmousewheel, unmousewheelup: jQuery.fn.unmousewheel }); jQuery.event.mousewheel = { giveFocus: function(el, up, down, preventDefault) { if (el._handleMousewheel) jQuery(el).unmousewheel(); if (preventDefault == window.undefined && down && down.constructor != Function) { preventDefault = down; down = null; } el._handleMousewheel = function(event) { if (!event) event = window.event; if (preventDefault) if (event.preventDefault) event.preventDefault(); else event.returnValue = false; var delta = 0; if (event.wheelDelta) { delta = event.wheelDelta/120; if (window.opera) delta = -delta; } else if (event.detail) { delta = -event.detail/3; } if (up && (delta > 0 || !down)) up.apply(el, [event, delta]); else if (down && delta < 0) down.apply(el, [event, delta]); }; if (window.addEventListener) window.addEventListener('DOMMouseScroll', el._handleMousewheel, false); window.onmousewheel = document.onmousewheel = el._handleMousewheel; }, removeFocus: function(el) { if (!el._handleMousewheel) return; if (window.removeEventListener) window.removeEventListener('DOMMouseScroll', el._handleMousewheel, false); window.onmousewheel = document.onmousewheel = null; el._handleMousewheel = null; } }; /** * jQuery.ScrollTo - Easy element scrolling using jQuery. * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com * Dual licensed under MIT and GPL. * Date: 9/11/2008 * @author Ariel Flesler * @version 1.4 * * http://flesler.blogspot.com/2007/10/jqueryscrollto.html */ ;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery); ////////////////////////////////////////////////////////////// // HI. i'm isolated in my own ready handler for a reason. // yes, in the bottom of this file. don't move me inside // another ready handler or to anywhere else in this file. // have a nice day :) ////////////////////////////////////////////////////////////// $(document).ready(function() { $('.autoclosing_popup').click(function() { return false; }); document.onclick = function(ev){ /* Eventually this will change because now there is a popup manager allowing only one popup to be open at once, therefore the autoclosing_popup classes which were needed before, are not needed now, just call the Popup.instance.hide() method and the currently open popup will close. */ $('.autoclosing_popup').hide(); // no guts no glory if(typeof(Popup) !== "undefined") Popup.instance.hide(); if ($('.autoclosing_popup_completion').length > 0 && typeof(hackCompletionExternalCloseHandler) !== "undefined") { if (hackCompletionExternalCloseHandler != null) { hackCompletionExternalCloseHandler(); } } }; // yes, this, here, let it be, for the sake of webkit&co balanceColumnsSlow(); }); ////////////////////////////////////////////////////////////// /** * Specific javascript for controlling the hotel detail thumbnail area that is shared amongst multiple pages */ SplendiaSoftReadyHandlers.push(function() { var details = $(".details_image_block"); var tarea = $(".thumb_area",details); $('.pager a',tarea).click(function() { var id = $(this).attr('id'); $('#th_' + id,tarea).show(); $('.thumb_page:not(#th_' + id + ')',tarea).hide(); return false; }); $('.thumb_page img',tarea).click(function(){ var rel = $(this).attr('rel'); $('.loading_image',details).show(); $('.main_image',details).load(function () { $('.loading_image',details).hide(); }); $('.main_image',details).attr('src', rel); }); }); SplendiaSoftReadyHandlers.push(function() { if($(".rating").length <= 0) return false; var monitor = false; var marker = false; var indicator = false; var buttons = false; var save = false; // Stop selection while dragging document.body.ondrag = function () { return false; }; document.body.onselectstart = function () { return false; }; var updatePosition = function(e){ initMarker($(this).parent()); var index = parseInt(e.originalTarget.alt.split(" ").pop()); var t = Math.ceil(index+1); var b = Math.floor(index); setMarker(t,b); } var stopMouse = function(){ $(document).unbind("mousemove"); $(document).unbind("mouseup"); monitor = false; }; var startMouse = function(){ if(monitor == false){ $(document).mouseup(stopMouse); monitor = true; initMarker($(this).parent()); var left = indicator.offset().left; var mw = marker.width(); var min = mw/2; var iw = indicator.width()-min; $(document).mousemove(function(e){ var nx = -(left - e.pageX); var c = (nx/iw)*10; var t = Math.ceil(c); var b = Math.floor(c); setMarker(t,b); }); } }; var initMarker = function(parent){ indicator = $(parent); marker = $(".marker",indicator); buttons = $(".button",indicator); save = indicator.parent().find("input[type='hidden']").eq(0); } var setMarker = function(high,low,override) { if(high < 1) high = 1; if(high > 10) high = 10; if(low < 0) low = 0; if(low > 9) low = 9; buttons.each(function(i){ if(i < high) $(this).attr("src",this.src.replace("-off","-on")); else $(this).attr("src",this.src.replace("-on","-off")); }); if(override!=undefined) high = override; marker.html(high); save.val(high); var pos = (low*marker.width())+low; marker.css("left",pos+"px"); } var resetMarker = function(node,state) { var i = $(".indicator",node); if(state){ $(".hbox-right",node).hide("slow"); }else{ $(".hbox-right",node).show("slow"); } initMarker(i); setMarker(4.5,4.5,""); } $(".rating .poll .indicator .marker").mousedown(startMouse); $(".rating .poll .indicator").click(updatePosition); // Enable the breakfast toggle $("input[name='breakfast_not_apply']").click(function(){ var p = $("div.poll-hotel-food"); resetMarker(p,this.checked); }); // Enable the customer service toggle $("input[name='cservice-not-contacted']").click(function(){ var p = $("div.poll-cservice-level"); resetMarker(p,this.checked); }); }); SplendiaSoftReadyHandlers.push(function() { var benefits = $(".benefits input[type='checkbox'][name!='benefit-none']"); var none = $(".benefits input[name='benefit-none']"); benefits.each(function(){ $(this).click(function(){ none.attr("checked",""); }); }); none.click(function(){ if(this.checked){ benefits.each(function(){ this.checked = false; }); } }); }); SplendiaSoftReadyHandlers.push(function() { $(".recommend .send_to_friend").click(function(){ SendToFriend.instance.setName($("input[name='name']",$(this)).val()); SendToFriend.instance.setEmail($("input[name='email']",$(this)).val()); SendToFriend.instance.setSubject($("input[name='subject']",$(this)).val()); SendToFriend.instance.setComments($("input[name='comment']",$(this)).val()); var hotelid = $("input[name='hotelid']",$(this)).val(); if(hotelid){ SendToFriend.instance.setResource("HotelDetail"); SendToFriend.instance.setHotel(hotelid); }else{ SendToFriend.instance.setResource("Splendia"); SendToFriend.instance.setURL($("input[name='url']",$(this)).val()); } SendToFriend.instance.show(); return false; }); }); hackCompletionExternalCloseHandler = null; jQuery.autocomplete = function(input, options) { // Create a link to self var me = this; var directEnter = false; // Create jQuery object for input element var $input = $(input).attr("autocomplete", "off"); // Apply inputClass if necessary if (options.inputClass) $input.addClass(options.inputClass); // Create results var results = document.createElement("div"); // Create jQuery object for results var $results = $(results); $results.hide().addClass(options.resultsClass).css("position", "absolute"); $results.addClass('autoclosing_popup'); $results.addClass('autoclosing_popup_completion'); if ( options.width > 0 ) $results.css("width", options.width); // Add to body element $('body').append(results); input.autocompleter = me; var timeout = null; var prev = ""; var active = -1; var cache = {}; var keyb = false; var lastKeyPressCode = null; // flush cache function flushCache(){ cache = {}; cache.data = {}; cache.length = 0; }; // flush cache flushCache(); // if there is a data array supplied if( options.data != null ){ var sFirstChar = "", stMatchSets = {}, row = []; // no url was specified, we need to adjust the cache length to make sure it fits the local data store if( typeof options.url != "string" ) options.cacheLength = 1; // loop through the array and create a lookup structure for( var i=0; i < options.data.length; i++ ){ // if row is a string, make an array otherwise just reference the array row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]); // if the length is zero, don't add to list if( row[0].length > 0 ){ // get the first character sFirstChar = row[0].substring(0, 1).toLowerCase(); // if no lookup array for this character exists, look it up now if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = []; // if the match is a string stMatchSets[sFirstChar].push(row); } } // add the data items to the cache for( var k in stMatchSets ){ // increase the cache size options.cacheLength++; // add to the cache addToCache(k, stMatchSets[k]); } } /* $input .keyup(function(e) { active = -1; if (timeout) clearTimeout(timeout); timeout = setTimeout(function(){onChange();}, options.delay); }) */ $input .keydown(function(e) { // track last key pressed lastKeyPressCode = e.keyCode; switch(e.keyCode) { case 38: // up e.preventDefault(); moveSelect(-1); break; case 40: // down e.preventDefault(); moveSelect(1); break; case 9: // tab e.preventDefault(); break; case 13: // return if (typeof(searchBoxStartDate) != 'undefined' && typeof(searchBoxEndDate) != 'undefined' ) { if (searchBoxStartDate != false && searchBoxEndDate != false) directEnter = true; } if (selectCurrent()) { // make sure to blur off the current field $input.get(0).blur(); e.preventDefault(); } break; default: active = -1; if (timeout) clearTimeout(timeout); timeout = setTimeout(function(){onChange();}, options.delay); break; } }) .focus(function() { if ($input.val() == $input.attr('title') || $input.val() == $input.attr('titled') || $input.val() == $input.attr('titleh')) $input.val(''); //$('#popup_locations_trigger').hide(); $('#popup_locations_trigger').attr('src', '/images/header/icon_destinations_list_blank.gif'); $('#popup_locations').hide(); active = -1; if (timeout) clearTimeout(timeout); timeout = setTimeout(function(){onChange();}, options.delay); }) .blur(function() { //hideResults(); //if ($input.val() == '') // $input.val($input.attr('title')); //if ($input.attr('mode') != 'hotel') //$('#popup_locations_trigger').show(); $('#popup_locations_trigger').attr('src', '/images/header/icon_destinations_list.gif'); }) .click(function() { return false; }); hideResultsNow(); function onChange() { // ignore if the following keys are pressed: [del] [shift] [capslock] /*if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return hideResultsNow();*/ //return $results.hide(); var v = $input.val(); //if (v == prev) return; prev = v; if (v.length >= options.minChars) { $input.addClass(options.loadingClass); requestData(v); } else { if (typeof(extraTopCities) != 'undefined' && $input.attr('mode') != 'hotel') { $input.addClass(options.loadingClass); requestData(v); } else { $input.removeClass(options.loadingClass); currentSearchPopupNames = []; currentSearchPopupIDs = []; hideResultsNow(); //$results.hide(); } } } function moveSelect(step) { var lis = $("li", results); if (!lis) return; active += step; if (active < 0) { active = 0; } else if (active >= lis.size()) { active = lis.size() - 1; } lis.removeClass("ac_over"); $(lis[active]).addClass("ac_over"); // Weird behaviour in IE // if (lis[active] && lis[active].scrollIntoView) { // lis[active].scrollIntoView(false); // } }; function selectCurrent() { var li = $("li.ac_over", results)[0]; if (!li) { var $li = $("li", results); if (options.selectOnly) { if ($li.length == 1) li = $li[0]; } else if (options.selectFirst) { li = $li[0]; } } if (li) { selectItem(li); return true; } else { return false; } }; function selectItem(li) { var i = 0; if (!li) { li = document.createElement("li"); li.extra = []; li.selectValue = ""; } // spl ////////// //i = active; // spl ////////// i = $(li).attr('customIndex'); var v = $.trim(li.selectValue ? li.selectValue : li.innerHTML); input.lastSelected = v; prev = v; $results.html(""); $input.val(currentSearchPopupNames[i]); $input.attr('directenter', directEnter ? 'true' : 'false'); setSearchLocationID(currentSearchPopupIDs[i]); currentSearchPopupNames = []; currentSearchPopupIDs = []; hideResultsNow(); if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1); }; // selects a portion of the input string function createSelection(start, end){ // get a reference to the input element var field = $input.get(0); if( field.createTextRange ){ var selRange = field.createTextRange(); selRange.collapse(true); selRange.moveStart("character", start); selRange.moveEnd("character", end); selRange.select(); } else if( field.setSelectionRange ){ field.setSelectionRange(start, end); } else { if( field.selectionStart ){ field.selectionStart = start; field.selectionEnd = end; } } field.focus(); }; // fills in the input box w/the first match (assumed to be the best match) function autoFill(sValue){ // if the last user key pressed was backspace, don't autofill if( lastKeyPressCode != 8 ){ // fill in the value (keep the case the user has typed) $input.val($input.val() + sValue.substring(prev.length)); // select the portion of the value not typed by the user (so the next character will erase) createSelection(prev.length, sValue.length); } }; function showResults() { // get the position of the input field right now (in case the DOM is shifted) var pos = findPos(input); // either use the specified width, or autocalculate based on form element var iWidth = (options.width > 0) ? options.width : $input.width(); // reposition $results.css({ width: parseInt(iWidth) + "px", top: (pos.y + input.offsetHeight) + "px", left: pos.x + "px" }).show(); }; function hideResults() { // special case: down to 1 result //if (currentSearchPopupIDs.length == 1) { //selectItem($results.find('li')); //} // special case: "select first" if (currentSearchPopupIDs.length > 0) { selectItem($results.find('li:first')); } if (timeout) clearTimeout(timeout); timeout = setTimeout(hideResultsNow, 200); }; function hideResultsNow() { // special case: down to 1 result //if (currentSearchPopupIDs.length == 1) { //selectItem($results.find('li')); //} // special case: "select first" if (currentSearchPopupIDs.length > 0) { selectItem($results.find('li:first')); } if (timeout) clearTimeout(timeout); $input.removeClass(options.loadingClass); if ($results.is(":visible")) { $results.hide(); } /* if (options.mustMatch) { var v = $input.val(); if (v != input.lastSelected) { selectItem(null); } } */ }; hackCompletionExternalCloseHandler = hideResultsNow; function latestSearchesHTML() { if (extraLatestSearches.length <= 0) return false; var html = '
    '; html += '
    '+searchBoxTranslations['s_recent_searches']+'
    '; $.each(extraLatestSearches, function() { var id = this[0]; var name = this[1]; var countryCode = this[2]; var start = this[3]; var end = this[4]; var url = this[5]; var country = CountryNames[countryCode]; html += '
    ' + name + ', ' + country; if (start != 0) { html += '
    ' + start + ' / ' + end; } html += '
    ' }); html += '
    '; return $(html).get(0); }; function receiveData(q, data, isTopCities) { if (data) { $input.removeClass(options.loadingClass); results.innerHTML = ""; if ($.browser.msie) { $results.append(document.createElement('iframe')); } var hData = dataToDom(data); if (isTopCities) { var div = document.createElement("div"); div.innerHTML = '
    ' + searchBoxTranslations['s_top_cities'] + '
    '; hData.insertBefore(div,hData.firstChild); } results.appendChild(hData); if (typeof(extraLatestSearches) != 'undefined') { var n = latestSearchesHTML(); if (n != false) { results.appendChild(n); $('.ac_latest_block div.l').click(function() { var url = $(this).attr('url'); window.location = url; }); } } // autofill in the complete box w/the first match as long as the user hasn't entered in more data if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]); showResults(); } else { hideResultsNow(); } }; function parseData(data) { if (!data) return null; var parsed = []; var rows = data.split(options.lineSeparator); for (var i=0; i < rows.length; i++) { var row = $.trim(rows[i]); if (row) { parsed[parsed.length] = row.split(options.cellSeparator); } } return parsed; }; function dataToDom(data) { var ul = document.createElement("ul"); var num = data.length; // limited results to a max number if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow; if (num <= 0) { var div = document.createElement("div"); div.innerHTML = '
    0 ' + searchBoxTranslations['s_no_results'] + ' ' + $input.val() + '
    '; $(div).addClass("ac_error"); ul.appendChild(div); $('#popup_locations_trigger').attr('src', '/images/header/icon_destinations_list.gif'); } else { $('#popup_locations_trigger').attr('src', '/images/header/icon_destinations_list_blank.gif'); for (var i=0; i < num; i++) { var row = data[i]; if (!row) continue; var li = document.createElement("li"); if (options.formatItem) { li.innerHTML = options.formatItem(row, i, num); li.selectValue = row[0]; } else { li.innerHTML = row[0]; li.selectValue = row[0]; } var extra = null; if (row.length > 1) { extra = []; for (var j=1; j < row.length; j++) { extra[extra.length] = row[j]; } } li.extra = extra; $(li).attr('customIndex', i); ul.appendChild(li); $(li).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this); }).hover( function(e) { $(this).addClass("ac_over"); }, function(e) { $(this).removeClass("ac_over"); } ); } } return ul; }; function requestData(q) { searchDataDelegate(); var data = null; var isTopCities = false; if (q.length == 0 && extraTopCities != 'undefined' && $input.attr('mode') != 'hotel') { isTopCities = true; data = loadFromExtra(); } else { if (!options.matchCase) q = q.toLowerCase(); data = options.cacheLength ? loadFromCache(q) : null; } // recieve the cached data if (data) { receiveData(q, data, isTopCities); } /* else if( (typeof options.url == "string") && (options.url.length > 0) ){ $.get(makeUrl(q), function(data) { data = parseData(data); addToCache(q, data); receiveData(q, data); }); // if there's been no data found, remove the loading class } */ else { $input.removeClass(options.loadingClass); } }; function makeUrl(q) { var url = options.url + "?q=" + encodeURI(q); for (var i in options.extraParams) { url += "&" + i + "=" + encodeURI(options.extraParams[i]); } return url; }; function loadFromExtra() { var r = []; currentSearchPopupNames = []; currentSearchPopupIDs = []; for (var i = 0; i < 10; i++) { currentSearchPopupIDs[i] = extraTopCities[i]; var place = extraTopCities[i]; var h = placeIDByOrdinal[place]; r[i] = [ LocationNames[h] ]; currentSearchPopupNames[i] = LocationNamesNoHTML[h]; } return r; }; function loadFromCache(q) { if (!q) return null; q = transformNA(q); var x = 0; var y = 0; var z = 0; var bsub = []; var csub = []; var dsub = []; var i = 0; currentSearchPopupIDs = []; currentSearchPopupNames = []; var pIDsA = []; var pIDsB = []; var pIDsC = []; var pNamesA = []; var pNamesB = []; var pNamesC = []; var doSym = typeof(extraSynonyms) != 'undefined'; for (var j = 0; j < currentSearchNames.length; j++) { var index = currentSearchNames[j].indexOf(q); var symIndex = -1; var id = currentSearchDisplays[j*currentSearchSkip+1]; if (doSym) { if (typeof(extraSynonyms[id]) != 'undefined') { symIndex = transformNA(extraSynonyms[id]).indexOf(q); } } if (index >= 0 || symIndex >= 0) { var endIndex = index + q.length; var origIndex = index; var bolded = ''; if (symIndex >= 0 && index < 0) { bolded = currentSearchDisplays[j*currentSearchSkip]; } else { bolded = currentSearchDisplays[j*currentSearchSkip].substring(0, index); bolded += ""; bolded += currentSearchDisplays[j*currentSearchSkip].substring(index, endIndex); bolded += ""; bolded += currentSearchDisplays[j*currentSearchSkip].substring(endIndex); } if (origIndex == 0) { bsub[x] = [ bolded ]; pIDsA[x] = id; pNamesA[x] = currentSearchNameOnly[j*currentSearchSkip]; x++; } else if (symIndex == 0) { dsub[z] = [ bolded ]; pIDsC[z] = id; pNamesC[z] = currentSearchNameOnly[j*currentSearchSkip]; z++; } else { csub[y] = [ bolded ]; pIDsB[y] = id; pNamesB[y] = currentSearchNameOnly[j*currentSearchSkip]; y++; } } if (x > options.maxItemsToShow) break; } currentSearchPopupIDs = pIDsA.concat(pIDsB.concat(pIDsC)); currentSearchPopupNames = pNamesA.concat(pNamesB.concat(pNamesC)); return bsub.concat(csub.concat(dsub)); }; function matchSubset(s, sub) { if (!options.matchCase) s = s.toLowerCase(); var i = s.indexOf(sub); if (i == -1) return false; return i == 0 || options.matchContains; }; this.flushCache = function() { flushCache(); }; this.setExtraParams = function(p) { options.extraParams = p; }; this.findValue = function(){ var q = $input.val(); if (!options.matchCase) q = q.toLowerCase(); var data = options.cacheLength ? loadFromCache(q) : null; if (data) { findValueCallback(q, data); } else if( (typeof options.url == "string") && (options.url.length > 0) ){ $.get(makeUrl(q), function(data) { data = parseData(data) addToCache(q, data); findValueCallback(q, data); }); } else { // no matches findValueCallback(q, null); } } function findValueCallback(q, data){ if (data) $input.removeClass(options.loadingClass); var num = (data) ? data.length : 0; var li = null; for (var i=0; i < num; i++) { var row = data[i]; if( row[0].toLowerCase() == q.toLowerCase() ){ li = document.createElement("li"); if (options.formatItem) { li.innerHTML = options.formatItem(row, i, num); li.selectValue = row[0]; } else { li.innerHTML = row[0]; li.selectValue = row[0]; } var extra = null; if( row.length > 1 ){ extra = []; for (var j=1; j < row.length; j++) { extra[extra.length] = row[j]; } } li.extra = extra; } } if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1); } function addToCache(q, data) { if (!data || !q || !options.cacheLength) return; if (!cache.length || cache.length > options.cacheLength) { flushCache(); cache.length++; } else if (!cache[q]) { cache.length++; } cache.data[q] = data; }; function findPos(obj) { var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } return {x:curleft,y:curtop}; } } jQuery.fn.autocomplete = function(url, options, data) { // Make sure options exists options = options || {}; // Set url as option options.url = url; // set some bulk local data options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null; // Set default values for required options options.inputClass = options.inputClass || "ac_input"; options.resultsClass = options.resultsClass || "ac_results"; options.lineSeparator = options.lineSeparator || "\n"; options.cellSeparator = options.cellSeparator || "|"; options.minChars = options.minChars || 0; options.delay = options.delay || 400; options.matchCase = options.matchCase || 0; options.matchSubset = options.matchSubset || 0; options.matchContains = options.matchContains || 1; options.cacheLength = options.cacheLength || 1; options.mustMatch = options.mustMatch || 0; options.extraParams = options.extraParams || {}; options.loadingClass = options.loadingClass || "ac_loading"; options.selectFirst = options.selectFirst || false; options.selectOnly = options.selectOnly || false; options.maxItemsToShow = options.maxItemsToShow || -1; options.autoFill = options.autoFill || false; options.width = parseInt(options.width, 10) || 0; this.each(function() { var input = this; new jQuery.autocomplete(input, options); }); // Don't break the chain return this; } jQuery.fn.autocompleteArray = function(data, options) { return this.autocomplete(null, options, data); } jQuery.fn.indexOf = function(e){ for( var i=0; i'; for(var i = 0; i < LocationNames.length; i+=4) { if (LocationNames[i+3] == 3) { html += '' + LocationNamesNoHTML[i] + '
    '; } } */ html += '
    '+searchBoxTranslations['s_top_countries']+'
    '; for(var i = 0; i < extraTopCountries.length; i++) { var code = extraTopCountries[i]; html += '' + CountryNames[code] + '
    '; } html += '
    '; // top cities html += '
    '+searchBoxTranslations['s_top_cities']+'
    '; for(var i = 0; i < extraTopCities.length; i++) { var place = extraTopCities[i]; if (typeof(placeIDByOrdinal[place]) != "undefined") { var h = placeIDByOrdinal[place]; html += '' + LocationNamesNoHTML[h] + '
    '; } } html += '
    '; var i = 0; var c = 0; var genCol = function() { while (i < LocationNames.length && c < 26) { if (LocationNames[i+3] == 0 || LocationNames[i+3] == 3) { html += '' + LocationNamesNoHTML[i] + '
    '; c++; } i+=4; } c = 0; cols++; }; html += '
    '+searchBoxTranslations['s_all_countries']+'
    '; genCol(); html += '
    '; if (i < LocationNames.length) { html += '
     
    '; genCol(); html += '
    '; } if (i < LocationNames.length) { html += '
     
    '; genCol(); html += '
    '; } if (i < LocationNames.length) { html += '
     
    '; genCol(); html += '
    '; } sizeForLocColumns(cols); $('#popup_locations').html(html); if ($.browser.msie && $.browser.version == '6.0') { // we put a styled iframe behind the calendar so HTML SELECT elements don't show through $('#popup_locations').prepend(document.createElement('iframe')); } setupCloseButton(); } function locationsBuildCitySelection(code, start) { var cols = 2; var html = ''; html += addCloseButton(html); html += '
    '+searchBoxTranslations['s_country']+'
    '; html += '' + CountryNames[code] + '


    '; html += '
    '+searchBoxTranslations['s_main_cities']+'
    '; for(var i = 0; i < LocationNames.length; i+=4) { if (LocationNames[i+3] == 4 && LocationNames[i+2] == code) { html += '' + LocationNamesNoHTML[i] + '
    '; } } html += '



    '+searchBoxTranslations['s_back_countries']+'
    '; html += '
    '; html += '
    '+searchBoxTranslations['s_all_regions']+'
    '; for(var i = 0; i < LocationNames.length; i+=4) { if (LocationNames[i+3] == 1 && LocationNames[i+2] == code) { html += '' + LocationNamesNoHTML[i] + '
    '; } } html += '
    '; var i = 0; if (start !== false) { i = start; } var c = 0; var genCol = function() { while (i < LocationNames.length && c < 24) { if ((LocationNames[i+3] == 2 || LocationNames[i+3] == 4) && LocationNames[i+2] == code) { html += '' + LocationNamesNoHTML[i] + '
    '; c++; } i+=4; } c = 0; cols++; }; html += '
    '+searchBoxTranslations['s_all_cities']+'
    '; genCol(); if (start !== false && start != 0) { // doesn't fit, add a page link html += '
    '+searchBoxTranslations['s_prev']+'
    '; } html += '
    '; if (i < LocationNames.length) { html += '
     
    '; genCol(); html += '
    '; } if (i < LocationNames.length) { html += '
     
    '; genCol(); html += '
    '; } if (i < LocationNames.length) { html += '
     
    '; genCol(); if (i < LocationNames.length) { // doesn't fit, add a page link html += '
    '+searchBoxTranslations['s_next']+''; } html += '
    '; } sizeForLocColumns(cols); $('#popup_locations').html(html); if ($.browser.msie && $.browser.version == '6.0') { // we put a styled iframe behind the calendar so HTML SELECT elements don't show through $('#popup_locations').prepend(document.createElement('iframe')); } setupCloseButton(); } function locationsSelectedLoc(locID, name) { //$('#locationID').val(locID); setSearchLocationID(locID); $('#searchInput').val(name); $('#popup_locations').hide(); } ////////////////////////////////////////////////////////////////////////// function setSearchLocationID(id) { var directEnter = $('#searchInput').attr('directenter') == 'true'; searchLocationID = id; if (id !== false) { $('#searchButton,#searchButton_r').removeClass('submit_disabled'); } else { $('#searchButton,#searchButton_r').addClass('submit_disabled'); } if (directEnter) { genericSearchButtonAction(); } if (id !== false && typeof(window.Map2SearchSelectionHook) != 'undefined' && window.Map2SearchSelectionHook != null) window.Map2SearchSelectionHook(id, searchMode); } function searchFindPos(obj) { var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) { curleft += obj.offsetLeft; curtop += obj.offsetTop; } return {x:curleft,y:curtop}; } /******************************************************/ /* calendar 2.0 */ /******************************************************/ window.SplendiaCalendar = function(displayElement, extraCSS, triggers, callbacks) { var thisCalendar = this; this.displayElement = displayElement; this.extraCSS = extraCSS; this.callbacks = callbacks; this.singleMonth = false; this.noHide = false; this.noSelection = false; this.dispMap = false; $.each(triggers, function(i, val) { $(val).click(function() { thisCalendar.toggle(); return false; }); }); this.$node = false; } window.SplendiaCalendar.prototype = { setSingleMonth: function(v) { this.singleMonth = v; }, setDispMap: function(v) { this.dispMap = v; }, setNoHide: function(v) { this.noHide = v; }, setNoSelection: function(v) { this.noSelection = v; }, toggle: function() { this.prebuild(); if (this.$node.css('display') == 'none') { $('.sc_container_abs').hide(); this.show(); } else { this.hide(); } }, prebuild: function() { if (this.$node === false) { this.$node = $('
    '); $('body').append(this.$node); this.$node.click(function() { return false; }); } this.reposition(); }, findPos: function(obj) { obj = $(obj).get(0); var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } return {x:curleft,y:curtop}; }, reposition: function() { // get the position of the input field right now (in case the DOM is shifted) var pos = this.findPos(this.displayElement); // reposition this.$node.css({ //width: parseInt(iWidth) + "px", top: (pos.y + $(this.displayElement).get(0).offsetHeight) + "px", left: pos.x + "px" }); }, hide: function() { this.$node.hide(); }, show: function() { this.render(); this.$node.show(); }, parseDate: function(d) { var c = d.split('/'); var d = parseInt(c[0], 10) - 1; var m = parseInt(c[1], 10) - 1; var y = parseInt(c[2], 10) + 2000; return { 'day' : d, 'month' : m, 'year' : y }; }, nextMonth: function(year, month) { month++; if (month > 11) { year++; month = 0; } return { 'year' : year, 'month' : month }; }, prevMonth: function(year, month) { month--; if (month < 0) { year--; month = 11; } return { 'year' : year, 'month' : month }; }, renderInline: function(preNode) { this.$node = preNode; this.render(); }, render: function() { var base = this.parseDate(this.callbacks.getToday()); var selected = this.callbacks.getSelected(); if (selected != false) { base = this.parseDate(selected); } this.renderMonth(base); }, renderMonth: function(base) { //var pager = page > 0 ? '
    ' : ''; var today = this.parseDate(this.callbacks.getToday()); var prev = this.prevMonth(base.year, base.month); if (!this.singleMonth) { prev = this.prevMonth(prev.year, prev.month); } var next = this.nextMonth(base.year, base.month); if (!this.singleMonth) { next = this.nextMonth(next.year, next.month); } if (!this.singleMonth) { var zeroBased = today.month + today.year*12; var leftParity = ((base.month + base.year*12) - zeroBased) % 2; if (leftParity == 1) { base = this.prevMonth(base.year, base.month); } } var nextYear = this.parseDate(this.callbacks.getToday()); nextYear.year++; var pager = today.year == base.year && today.month == base.month ? '' : '
    '; if (this.singleMonth) { var base2 = this.nextMonth(base.year, base.month); var nextYear2 = this.nextMonth(nextYear.year, nextYear.month); pager += (base2.year >= nextYear2.year && base2.month > nextYear2.month) ? '' : '
    '; } var html = '
    ' + pager + this.callbacks.getMonthName(base.month) + ' ' + base.year + '
    '; html += this.generateMonth(base.year, base.month); html += '
    '; base = this.nextMonth(base.year, base.month); var pager = base.year >= nextYear.year && base.month >= nextYear.month ? '' : '
    '; if (!this.singleMonth) { html += '
    ' + pager + this.callbacks.getMonthName(base.month) + ' ' + base.year + '
    '; html += this.generateMonth(base.year, base.month); html += '
    '; } if (!this.noHide) { html += ''; } this.$node.html(html); var thisCalendar = this; if (this.singleMonth) { $('.month_left .pagerL', this.$node).click(function() { thisCalendar.renderMonth(prev); }); $('.month_left .pagerR', this.$node).click(function() { thisCalendar.renderMonth(next); }); } else { $('.month_left .pager', this.$node).click(function() { thisCalendar.renderMonth(prev); }); $('.month_right .pager', this.$node).click(function() { thisCalendar.renderMonth(next); }); } if (!this.noSelection) { $('.cl', this.$node).click(function() { thisCalendar.callbacks.selectionMade($(this).attr('spdate')); thisCalendar.hide(); }); } if (!this.noHide) { $('.sc_footer .close', this.$node).click(function() { thisCalendar.hide(); }); } }, day1Offset: function(year, month) { var d = new Date(year, month, 1); var d = d.getDay() - 1; return d >= 0 ? d : 6; }, daysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, dayOfYear: function (d) { var yn = d.getFullYear(); var mn = d.getMonth(); var dn = d.getDate(); var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1 var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date var ddiff = Math.round((d2-d1)/864e5); return ddiff; }, buildSPDate: function(year, month, day) { var d = '' + (day + 1); var m = '' + (month + 1); if (d.length == 1) d = '0' + d; if (m.length == 1) m = '0' + m; return '' + d + '/' + m + '/' + ('' + year).substring(2, 4); }, generateMonth: function(year, month) { var selected = this.callbacks.getSelected(); if (selected == false) selected = -9999; else { selected = this.parseDate(selected); if (selected.month == month && selected.year == year) selected = selected.day; else selected = -9999; } var today = this.parseDate(this.callbacks.getToday()); var cutoffDay = -9999; if (today.month == month && today.year == year) { cutoffDay = today.day; } var i = -this.day1Offset(year, month); var n = this.daysInMonth(year, month); var absI = -today.day; if (year == today.year && month == today.month) { absI = 0; } var curr = { 'year' : today.year, 'month' : today.month }; while (!(year == curr.year && month == curr.month)) { absI += this.daysInMonth(curr.year, curr.month); curr = this.nextMonth(curr.year, curr.month); } var html = ''; html += ''; var j = 0; while (j < 7) { html += ''; j++; } html += ''; var h = 0; while (h < 6) { html += ''; for (var j = 0; j < 7; j++, i++) { if (i < n && i >= 0) { var klass = 'noday'; if (i >= cutoffDay) { klass = 'cl'; if (i == selected && this.dispMap == false) klass += " sel"; else klass += " day"; if (this.dispMap != false && absI >= 0) { if (absI <= 365) klass += this.dispMap[absI] == 1 ? " av" : " noav"; else klass += " noav"; //klass += (absI % 5 == 0) ? " av" : " noav"; } absI++; } var spdate = this.buildSPDate(year, month, i); html += ''; } else html += ''; } html += ''; h++; } html += '
    '+this.callbacks.getDayName(j)+'
    ' + (i + 1) + ' 
    '; return html; } }; //$(document).ready(function() SplendiaSoftReadyHandlers.push(function() { // do not run the search setup if there is no search box if (typeof(window['searchMode']) == "undefined" ) { return; } var popup = document.createElement('div'); popup.setAttribute('id', 'popup_locations'); var input = document.getElementById('searchInput'); // BUGFIX: Stop looking at input, when it doesnt exist if(input){ var pos = searchFindPos(input); $(popup).hide().css({ top: (pos.y + input.offsetHeight + 4) + "px", left: pos.x + "px" }); } $('body').append(popup); window.initialDatestart = searchBoxStartDate; window.initialDateend = searchBoxEndDate; $('#searchInput').attr('mode', 'dest'); function setSearchMode(mode) { if (mode == searchMode) return; setSearchLocationID(false); if (mode == "destination") { if (searchDefaultLocationID !== false) { setSearchLocationID(searchDefaultLocationID); $('#searchInput').val(searchDefaultLocationName); } else { $('#searchInput').val($('#searchInput').attr('titled')); } $('#radio_destination').attr('class', 'radio_selected'); $('#radio_hotel').attr('class', 'radio_unselected'); //$('#searchInput').val($('#searchInput').attr('titled')); $('#searchInput').attr('mode', 'dest'); $('#searchInput').animate({ width : '169px' }, 'normal', function() { $('#popup_locations_trigger').show('normal'); } ); $('.search_box .submit').val(searchBoxTranslations['s_search']); searchMode = "destination"; currentSearchNames = LocationNamesNA; currentSearchDisplays = LocationNames; currentSearchNameOnly = LocationNamesNoHTML; currentSearchSkip = 4; } else { $('#radio_destination').attr('class', 'radio_unselected'); $('#radio_hotel').attr('class', 'radio_selected'); $('#searchInput').val($('#searchInput').attr('titleh')); $('#searchInput').attr('mode', 'hotel'); $('#popup_locations_trigger').hide('normal', function() { $('#searchInput').animate({ width : '182px' }, 'normal'); }); $('#popup_locations').hide(); $('.search_box .submit').val(searchBoxTranslations['s_book']); searchMode = "hotel"; currentSearchNames = HotelNamesNA; currentSearchDisplays = HotelNames; currentSearchNameOnly = HotelNamesNoHTML; currentSearchSkip = 4; } //$("#searchInput")[0].autocompleter.flushCache(); } currentSearchNames = LocationNamesNA; currentSearchDisplays = LocationNames; currentSearchNameOnly = LocationNamesNoHTML; currentSearchSkip = 4; $('#searchInput').autocompleteArray( [ 'filler' ], { delay:10, minChars:1, matchSubset:1, onItemSelect:selectItem, onFindValue:findValue, autoFill:false, maxItemsToShow:20, selectOnly:1, selectFirst:1, width: extraLatestSearches.length > 0 ? '450px' : '255px' } ); // location popup //////////////////////////////////////////////////////// $('#popup_locations_trigger,#top_dest_more').click(function () { searchDataDelegate(); if (searchHasPreselCountry != false) { locationsBuildCitySelection(searchHasPreselCountry, false); } else { locationsBuildCountrySelection(); } $('#popup_locations').toggle(); }); // room selector //////////////////////////////////////////////////////// $('#rooms_selector').click(function() { $('#rooms_list').slideToggle('fast'); }); $('#rooms_selector_r').click(function() { $('#rooms_list_r').slideToggle('fast'); }); //$('#rooms_selector li a,#rooms_selector_r li a').click(function(ev) { $('.room_selector_room_e').click(function(ev) { var t = $(ev.target).text(); $('#rooms_selected,#rooms_selected_r').text(t); searchBoxRooms = t.substring(0, 1); $('#rooms_list,#rooms_list_r').hide(); return false; }); // adults selector //////////////////////////////////////////////////////// $('#adults_selector').click(function() { $('#adults_list').slideToggle('fast'); }); $('#adults_selector_r').click(function() { $('#adults_list_r').slideToggle('fast'); }); //$('#adults_selector li a,#adults_selector_r li a').click(function(ev) { $('.adults_selector_room_e').click(function(ev) { var t = $(ev.target).text(); $('#adults_selected,#adults_selected_r').text(t); searchBoxAdults = t.substring(0, 1); $('#adults_list,#adults_list_r').hide(); return false; }); $('#radio_destination').click(function(ev) { $('.autoclosing_popup').hide(); setSearchMode("destination"); return false; }); $('#radio_hotel').click(function(ev) { $('.autoclosing_popup').hide(); setSearchMode("hotel"); return false; }); genericSearchButtonAction = function(ev) { if (searchLocationID !== false) { var dA = ''; var dE = ''; var dR = '&rooms=' + searchBoxRooms; var dAd = '&adults=' + searchBoxAdults; if (searchBoxStartDate !== false && searchBoxEndDate !== false) { dA = '&datestart=' + searchBoxStartDate; dE = '&dateend=' + searchBoxEndDate; } window.location = '/index.php?resource=redirector&component=RedirectStaticSearch&mode=' + searchMode + '&searchlist_id=' + searchLocationID + dA + dE + dR + dAd; } else { $('#searchInput').animate({ backgroundColor: 'rgb(254,239,131)' }, 120) .animate( { backgroundColor: 'white' }, 120) .animate( { backgroundColor: 'rgb(254,239,131)' }, 120) .animate( { backgroundColor: 'white' }, 120) .animate( { backgroundColor: 'rgb(254,239,131)' }, 120) .animate( { backgroundColor: 'white' }, 120); } } $('#searchButton').click(genericSearchButtonAction); // the hotel page always submits an hotel search, not a location search hotelPageSearchButtonActionProto = function(scrollToRooms) { if (searchFixedHotel !== false) { var dA = ''; var dE = ''; var dR = '&rooms=' + searchBoxRooms; var dAd = '&adults=' + searchBoxAdults; if (searchBoxStartDate !== false && searchBoxEndDate !== false) { dA = '&datestart=' + searchBoxStartDate; dE = '&dateend=' + searchBoxEndDate; } var dS = scrollToRooms ? '&roomscroll=1' : ''; window.location = '/index.php?resource=redirector&component=RedirectStaticSearch&mode=hotel' + '&searchlist_id=' + searchFixedHotel + dA + dE + dR + dAd + dS; } }; hotelPageSearchButtonAction = function() { hotelPageSearchButtonActionProto(false); }; $('#searchButton_r').click(function() { hotelPageSearchButtonActionProto(true); } ); // setup is done, now use initial params to set saved state ///////////// if (searchBoxStartDate !== false || searchBoxEndDate !== false) { newDateInterval(); } // avoid changes to nights display in the booking tab searchFirstIntervalCalc = false; if (searchMode != 'destination') { $('#radio_destination').attr('class', 'radio_unselected'); $('#radio_hotel').attr('class', 'radio_selected'); $('#popup_locations_trigger').hide(); $('#searchInput').css('width', '182px'); $('.search_box .submit').val(searchBoxTranslations['s_book']); searchMode = "hotel"; currentSearchNames = HotelNamesNA; currentSearchDisplays = HotelNames; currentSearchNameOnly = HotelNamesNoHTML; currentSearchSkip = 4; } // init location setSearchLocationID(searchLocationID); // calendar 2.0 var callbacksBase = function() { }; callbacksBase.prototype = { getMonthName: function(month) { return datepickerRegional.monthNames[month]; }, getDayName: function(day) { if (day == 6) return datepickerRegional.dayNamesMin[0]; return datepickerRegional.dayNamesMin[day+1]; }, getClose: function() { return searchBoxTranslations['s_close']; }, getToday: function() { return searchBoxTodayDate; } }; var callbacksS = new callbacksBase(); callbacksS.getSelected = function() { return searchBoxStartDate; } callbacksS.getLabel = function() { return searchBoxTranslations['s_date_arr']; } callbacksS.selectionMade = function(selected) { resetStartDate(selected); newDateIntervalProto(true); } var callbacksE = new callbacksBase(); callbacksE.getSelected = function() { return searchBoxEndDate; } callbacksE.getLabel = function() { return searchBoxTranslations['s_date_dep']; } callbacksE.selectionMade = function(selected) { resetEndDate(selected); newDateIntervalProto(false); } var cal1 = new SplendiaCalendar('#datestart', '', ['#datestart', '#fake-trigger-start'], callbacksS); var cal2 = new SplendiaCalendar('#dateend', '', ['#dateend', '#fake-trigger-end' ], callbacksE); var cal3 = new SplendiaCalendar('#datestart_r', '', ['#datestart_r', '#fake-trigger-start_r'], callbacksS); var cal4 = new SplendiaCalendar('#dateend_r', '', ['#dateend_r', '#fake-trigger-end_r' ], callbacksE); var damnIE6 = function () { if ($.browser.msie && $.browser.version == '6.0') { $('select').toggle(); } }; /* var startPickerOnScreen = false; var endPickerOnScreen = false; var startPickerOnScreen2 = false; var endPickerOnScreen2 = false; $('#fake-trigger-start').click(function() { if (startPickerOnScreen) { $('#datestart').datepicker('hide'); } else { $('#datestart').datepicker('show'); } }); $('#fake-trigger-end').click(function() { if (endPickerOnScreen) { $('#dateend').datepicker('hide'); } else { $('#dateend').datepicker('show'); } }); $('#fake-trigger-start_r').click(function() { if (startPickerOnScreen2) { $('#datestart_r').datepicker('hide'); } else { $('#datestart_r').datepicker('show'); } }); $('#fake-trigger-end_r').click(function() { if (endPickerOnScreen2) { $('#dateend_r').datepicker('hide'); } else { $('#dateend_r').datepicker('show'); } }); $("#datestart").datepicker({ duration: '', dateFormat: 'dd/mm/y', firstDay: 1, numberOfMonths: 2, changeMonth: false, changeYear: false, mandatory: true, showOn: "focus", minDate: new Date(), maxDate: '+1y', beforeShow: function () { damnIE6(); startPickerOnScreen = true; }, onClose: function() { damnIE6(); startPickerOnScreen = false; }, onSelect: function(date) { resetStartDate(date); newDateIntervalProto(true) } }); $("#datestart_r").datepicker({ duration: '', dateFormat: 'dd/mm/y', firstDay: 1, numberOfMonths: 2, changeMonth: false, changeYear: false, mandatory: true, showOn: "focus", minDate: new Date(), maxDate: '+1y', beforeShow: function () { damnIE6(); startPickerOnScreen2 = true; }, onClose: function() { damnIE6(); startPickerOnScreen2 = false; }, onSelect: function(date) { resetStartDate(date); newDateIntervalProto(true) } }); $("#dateend").datepicker({ duration: '', dateFormat: 'dd/mm/y', firstDay: 1, numberOfMonths: 2, changeMonth: false, changeYear: false, mandatory: true, showOn: "focus", minDate: new Date(), maxDate: '+1y', beforeShow: function () { damnIE6(); endPickerOnScreen = true; }, onClose: function() { damnIE6(); endPickerOnScreen = false; }, onSelect: function(date) { resetEndDate(date); newDateIntervalProto(false) } }); $("#dateend_r").datepicker({ duration: '', dateFormat: 'dd/mm/y', firstDay: 1, numberOfMonths: 2, changeMonth: false, changeYear: false, mandatory: true, showOn: "focus", minDate: new Date(), maxDate: '+1y', beforeShow: function () { damnIE6(); endPickerOnScreen2 = true; }, onClose: function() { damnIE6(); endPickerOnScreen2 = false; }, onSelect: function(date) { resetEndDate(date); newDateIntervalProto(false) } }); */ });