// hotel marker HotelMarker.prototype = new Hotel(); function HotelMarker(chainCode, propertyId, iCityCode, name, description, address, zip, rating, price, imgUrl, iataCode, bookable, point, hotelsMap) { this.base = Hotel; this.base(chainCode, propertyId, iCityCode, name, description, address, zip, rating, price, imgUrl, iataCode); this.bookable = bookable; this.map = hotelsMap.map; this.hotelsMap = hotelsMap; this.duplicates = new Array(); this.amenities = new Array(); this.undeployMarker = null; this.complete = false; this.xmlhttp = null; //this.hotelDescription = iHotelDescription; this.logoIcon = "images//metal/small_wallaby.gif"; this.defaultHotelIcon = new GIcon(); if (this.bookable == true) { this.defaultHotelIcon.image = "images/metal/marker_ok.png"; } else { this.defaultHotelIcon.image = "images/metal/marker_ko.png"; } this.defaultHotelIcon.shadow = "images/metal/marker_shadow.png"; this.defaultHotelIcon.iconSize = new GSize(45, 40); this.defaultHotelIcon.shadowSize = new GSize(45, 40); this.defaultHotelIcon.iconAnchor = new GPoint(33, 38); this.defaultHotelIcon.infoWindowAnchor = new GPoint(33, 38); var opts = {}; opts.icon = this.defaultHotelIcon; opts.title = name; this.marker = new GMarker(point, opts); this.isClickedOn = false; GEvent.bind(this.marker, 'click', this, this.openInfoWindow); GEvent.bind(this.marker, 'infowindowclose', this, this.closeInfoWindow); } HotelMarker.prototype.setImage = function(url) { this.marker.setImage(url); } function doNothing() { } // to open the info windows on the hotel marker HotelMarker.prototype.openInfoWindowNoLoad = function() { this.hotelsMap.loadHotelsList = false; this.openInfoWindow(); } // to open the info windows on the hotel marker HotelMarker.prototype.openInfoWindow = function() { this.hotelsMap.loadHotelsList = false; this.map.panTo(this.marker.getLatLng()); this.openInfoWindowOnly(); } HotelMarker.prototype.openInfoWindowOnly = function() { // great f'in idea, id="div" nice. // nice use of css too. cowboy coding. var theIconUrl = "images/book/metal/small_book_this.png"; var DAY_MILLIS = 1000 * 60 * 60 * 24; var PLUS_MINUS_DAYS = 2; var theCheckInDate = document.getElementById('checkInDate').value; var theCheckOutDate = document.getElementById('checkOutDate').value; //alert("Co: '" + theCheckOutDate + "' Ci: '" + theCheckInDate + "'"); var theDateObjCheckin = Date.parse(theCheckInDate); var theDateObjCheckout = Date.parse(theCheckOutDate); var theStartEarliest = new Date(); var theStartLatest = new Date(); var theEndLatest = new Date(); var theEndEarliest = new Date(); var theIncrement = (PLUS_MINUS_DAYS * DAY_MILLIS); //alert("Date obj checkout " + theDateObjCheckout + " using increment of " + theIncrement); theStartEarliest.setTime(theDateObjCheckin - (PLUS_MINUS_DAYS * DAY_MILLIS)); theStartLatest.setTime(theDateObjCheckin + (PLUS_MINUS_DAYS * DAY_MILLIS)); theEndLatest.setTime(theDateObjCheckout + (PLUS_MINUS_DAYS * DAY_MILLIS)); theEndEarliest.setTime(theDateObjCheckout - (PLUS_MINUS_DAYS * DAY_MILLIS)); //var theDateStr = format(theStartEarliest, "dd NNN yyyy"); //alert("Date here: " + theDateObjCheckin); //alert("Date end: " + formatDate(theEndLatest, "dd NNN yyyy")); //alert("Date here in date obj: " + theStartEarliest.getYear()); var html = "
"; //html += ""; //html += ""; //html += "
"; html += "
"; html += "
"; html += "
" + this.name + "
"; //html += "
" + this.hotelDescription + "
"; html += "
" + this.address + "
"; html += "
" + this.zip + "
"; // end of topInfo html += "
"; html += "
"; //html += ""; /*html += "";*/ theUrl = ""; theUrl += "/walbrowser/CalendarView?checkInDate=" + theCheckInDate + "&checkOutDate="+theCheckOutDate + "&startDateEarliest="+formatDate(theStartEarliest, "dd NNN yyyy")+ "&startDateLatest="+formatDate(theStartLatest, "dd NNN yyyy")+ "&endDateEarliest="+formatDate(theEndEarliest, "dd NNN yyyy")+ "&endDateLatest="+formatDate(theEndLatest, "dd NNN yyyy")+ "&chainCode="+this.chainCode+"&hotelCode="+this.propertyId+"&hotelCityCode="+this.cityCode; //html += ""; html += "
Price : " + this.price + " € *
"; html += ""; html += "
* per room/per night
"; html += ""; //html += "
"; //html += "
"; // end of BottomInfo html += "
"; html += ""; //alert("DEBUG sending html to marker window : " + html); this.marker.openInfoWindowHtml(html, {suppressMapPan:true}); //this.retrieveDetails(); this.isClickedOn = true; //alert("Before detailed constructor"); //var theDetailedHotelInfo = new HotelDetailedInfo(""); //alert("After detailed constructor"); } HotelMarker.prototype.deploy = function() { if(walDebug) GLog.write(">>> deploy " + this.name); if (this.marker.deployed == false && this.duplicates.length > 0) { var pos = this.map.fromLatLngToDivPixel(this.marker.getPoint()); this.undeployMarker = new UndeployControl(this, this.marker.getPoint()); this.map.addOverlay(this.undeployMarker); var degree = Math.floor(360 / (this.duplicates.length)); var R = Math.floor(windowHeight / 5.5); var cur = 90 + degree; for (var i = 0; i < this.duplicates.length; i++) { var x = Math.floor(Math.cos(cur * 0.017453292519943295769236907684886) * R); var y = Math.floor(Math.sin(cur * 0.017453292519943295769236907684886) * R * (-1)); this.duplicates[i].marker.move(x, y); this.duplicates[i].marker.deployed = true; cur += degree; } if(walDebug) GLog.write(">>> undeploy " + this.name); return true; } if(walDebug) GLog.write("<<< deploy " + this.name); return false; } HotelMarker.prototype.undeploy = function() { if(walDebug) GLog.write(">>> undeploy " + this.name); if (this.marker.deployed == true && this.duplicates.length > 0) { for (var i = 0; i < this.duplicates.length; i++) { if (this.duplicates[i].isClickedOn == true) { this.duplicates[i].closeInfoWindow(); } this.duplicates[i].marker.move(0, 0); this.duplicates[i].marker.deployed = false; } } if(walDebug) GLog.write("<<< undeploy " + this.name); } HotelMarker.prototype.closeInfoWindow = function() { this.marker.closeInfoWindow(); this.isClickedOn = false; } HotelMarker.prototype.display = function(map) { if(walDebug) GLog.write(">>> display " + this.name); map.addOverlay(this.marker); if(walDebug) GLog.write("<<< display " + this.name); } // come on, seriously.....UNdisplay ?? HotelMarker.prototype.unDisplay = function(map) { if(walDebug) GLog.write(">>> unDisplay " + this.name); if (this.undeployMarker != null) { //this.undeployMarker.remove(); if(walDebug) GLog.write("Removed undeployMarker overlay: " + this.name); map.removeOverlay(this.undeployMarker); } // this.marker.remove(); map.removeOverlay(this.marker); if(walDebug) GLog.write("Removed marker overlay: " + this.name); if(walDebug) GLog.write("<<< unDisplay " + this.name); } HotelMarker.prototype.retrieveDetails = function() { if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc. xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { marker = this; xmlhttp.onreadystatechange = xmlLoad; xmlhttp.open("GET", "Details?propertyId=" + this.propertyId, true); xmlhttp.send(null); } } function removeImage() { if (document.getElementById('parent') != null && document.getElementById('image') != null) { document.getElementById('parent').removeChild(document.getElementById('image')); } } HotelMarker.prototype.createHtml = function() { var sDescr = ""; var idx = marker.description.indexOf(" ", 80); if (idx != -1) { sDescr = marker.description.substring(0, idx) + "..."; } else { sDescr = marker.description; } var r = marker.rating ? Math.round(marker.rating) : marker.rating; var html = "
"; html += ""; html += ""; html += ""; html += "
" + marker.name + "
"; if(r > 0) { html += ""; html += ""; html += ""; html += "
"; html += ""; html += "" + marker.rating; html += "
"; } else { html += "Hotel not yet rated"; } html += ""; html += ""; if (marker.imgUrl[0] != null && marker.imgUrl[0].length > 0) { html += ""; } else { html += "" } html += ""; html += ""; html += ""; html += "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
" + sDescr + "
"; if(marker.amenities.length > 0) { html += "
"; for(i=0;i"; } } html += "
"; } html += ""; html += "
"; html += ""; html += ""; if (this.bookable == true) { html += ""; } html += "
"; html += "
"; html += "Room from
" + marker.price + " EUR
(1 night for 1 person)"; html += "
"; html += "
"; html += 'Book this!'; html += "
"; html += "
"; return html; } function decodeAmenityCode(code) { switch(parseInt(code)) { case 1: return "MC_GASTRONOMY"; case 2: return "MC_WATERFRONT"; case 3: return "MC_SPAPOOL"; case 4: return "MC_PETSALLOWED"; case 5: return "MC_FAMILY"; case 6: return "MC_PARKING"; case 7: return "MC_AIRCONDITIONING"; case 8: return "MC_DISABLEDACCESS"; case 9: return "MC_SPORTACTIVITIES"; default: return null; } } HotelMarker.prototype.createErrorHtml = function() { var html = "
"; html += ""; html += ""; html += ""; html += "
" + this.name + "
"; html += "Could not load Hotel details"; html += "
"; return html; } HotelMarker.prototype.returnNotEmpty = function(node) { if (node != null && node.firstChild != null) { return node.firstChild.nodeValue; } return ''; } HotelMarker.prototype.loadHotels = function(xml) { if (xml == null) { return; } var xmlHotels = xml.documentElement.getElementsByTagName('Property'); if (xmlHotels != null) { // parse xml... for (var i = xmlHotels.length - 1; i >= 0; i--) { this.iataCode = xmlHotels[i].getAttribute("HotelCityCode"); this.chainCode = xmlHotels[i].getAttribute("ChainCode"); this.description = this.returnNotEmpty(xmlHotels[i].getElementsByTagName('Description')[0]); this.imgUrl = []; var images = xmlHotels[i].getElementsByTagName('ImageURL'); if (images.length == 0) { this.imgUrl.push(''); } for (var j = 0; j < images.length; j++) { this.imgUrl.push(this.returnNotEmpty(images[j])); } this.address = ''; var xmlAddress = xmlHotels[i].getElementsByTagName('Address'); if (xmlAddress && xmlAddress.length > 0) { xmlAddressLine = xmlAddress[0].getElementsByTagName('AddressLine'); for (var j = 0; j < xmlAddressLine.length; j++) { if (j > 0) { this.address += "
"; } this.address += this.returnNotEmpty(xmlAddressLine[j]); } var zipCode = this.returnNotEmpty(xmlAddress[0].getElementsByTagName('PostalCode')[0]); var city = this.returnNotEmpty(xmlAddress[0].getElementsByTagName('CityName')[0]); var stateProv = this.returnNotEmpty(xmlAddress[0].getElementsByTagName('StateProv')[0]); var xmlCountry = xmlAddress[0].getElementsByTagName('CountryName')[0]; var country = ""; if (xmlCountry != null) { country = xmlCountry.getAttribute("Code"); } if (zipCode.length > 0 || city.length > 0 || stateProv.length > 0) { this.address += "
"; } if (zipCode.length > 0) { this.address += zipCode; } if (city.length > 0) { this.address += " " + city; } if (stateProv.length > 0) { this.address += " " + stateProv; } if (country.length > 0) { this.address += "
" + country; } var phone = this.returnNotEmpty(xmlHotels[i].getElementsByTagName('ContactNumber')[0]); if (phone.length > 0) { this.address += "
Tel. " + phone; } } // end of address var xmlAmenities = xmlHotels[i].getElementsByTagName('Amenity'); this.amenities.length = 0; for (var j = 0; j < xmlAmenities.length; j++) { this.amenities.push(xmlAmenities[j].getAttribute("PropertyAmenityType")); } } } } var xmlhttp = null; var marker = null; function xmlLoad() { var xmlDoc = null; if (xmlhttp.readyState == 4) {// 4 = "loaded" if (xmlhttp.status==200) { try {//Internet Explorer xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(xmlhttp.responseText); } catch(e) { try { //Firefox, Mozilla, Opera, etc. parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlhttp.responseText, "text/xml"); } catch (ee) { return; } } } } else { return; } if (xmlDoc != null) { marker.loadHotels(xmlDoc); marker.complete = true; marker.marker.openInfoWindowHtml(marker.createHtml(), {suppressMapPan:true}); } else { marker.marker.openInfoWindowHtml(marker.createErrorHtml(), {suppressMapPan:true}); } }