booking.map=function(){var debug=false,_google_api_is_loaded=false,_b_map_bounding_box,_b_map_center,_b_clear_markers=false,_b_map_focus,_b_current_level,_b_clusters_type,_b_force_no_clusters,_b_cluster_mapping={country:"region",region:"city",city:"district",district:"hotel",anon:"hotel"},_b_show_label=false,_b_first_load_display_clicked_hotel=false,_b_target_coords,_b_map,_b_icon_types,_b_icon_zoom_levels,_b_icon_z_indices,max_hotels_via_json=booking.env.b_max_hotels_via_json,max_hotels_via_json_zoomed_out=200,_max_length_of_hotel_description=250,_b_initial_zoom_level,_b_initial_bounding_box,_b_selected_hotel="",_icon_mouse_down_flag=false,_map_dragged_flag=false,_b_previous_selected_hotel="",_open_info_window=null,_b_marker_ids=[],_b_markers={},MarkerLight,_b_circle,_b_circle_type,_zoomed=0,_initial_width,_map_wrapper,_map_is_embedded;function bOverlay(obj){this.obj=obj}function _buildCustomOverlay(){bOverlay.prototype=new google.maps.Overlay();bOverlay.prototype.initialize=function(){if(_open_info_window){$(_open_info_window).remove();_open_info_window=null}var popup_html='<div id="b_overlay" class="'+this.obj.icon_type+'"><h3>';if(this.obj.b_type!="cluster"){if(this.obj.b_class){popup_html+='<img src="//q.bstatic.com/icons/stars/'+this.obj.b_class;if(this.obj.b_class_half){popup_html+=this.obj.b_class_half}popup_html+='sterren-small.png" alt="'+this.obj.b_class+" "+(this.obj.b_class==1?booking.env.star:booking.env.stars)+'" />'}popup_html+=this.obj.title;if(this.obj.b_type!=="hotel"){popup_html+="<span>"+this.obj.subhead+"</span>"}popup_html+="</h3>";popup_html+="<p>";if(this.obj.b_image_url){popup_html+='<img src="'+this.obj.b_image_url+'" alt="" />'}}else{if(this.obj.url!=""){if(this.obj.b_class){popup_html+='<img src="//q.bstatic.com/icons/stars/'+this.obj.b_class;if(this.obj.b_class_half){popup_html+=this.obj.b_class_half}popup_html+='sterren-small.png" alt="'+this.obj.b_class+" "+(this.obj.b_class==1?booking.env.star:booking.env.stars)+'" />'}popup_html+=this.obj.title;popup_html+="</h3>";popup_html+="<p>";if(this.obj.b_image_url){popup_html+='<img src="'+this.obj.b_image_url+'" alt="" />'}}else{if(this.obj.b_cluster_name.match(/^anon/)){popup_html+=this.obj.b_nr_hotels+" "+(this.obj.b_nr_hotels==1?booking.env.map_hotel:booking.env.map_hotels)}else{popup_html+=this.obj.b_cluster_name+": "+this.obj.b_nr_hotels+" "+(this.obj.b_nr_hotels==1?booking.env.map_hotel:booking.env.map_hotels)}popup_html+="</h3>";popup_html+="<p>"}}if(this.obj.b_type==="hotel"||this.obj.url!=""){if(this.obj.b_description&&this.obj.b_description.length){popup_html+=(this.obj.b_description.length<=_max_length_of_hotel_description)?this.obj.b_description:booking.map.trunc(this.obj.b_description)}}else{if(this.obj.b_nr_hotels>1){popup_html+=booking.env.zoom_in}}popup_html+="</p>";if(this.obj.b_type=="hotel"){if(typeof(booking.env.map_vars)=="undefined"){booking.env.map_vars={}}if(typeof(booking.env.map_vars.translation_from)=="undefined"){booking.env.map_vars.translation_from="From"}if(typeof(booking.env.map_vars.translation_occupancies)=="undefined"){booking.env.map_vars.translation_occupancies=[]}popup_html+='<table id="b_overlay_table_prices"><tbody>';if(this.obj.av){var prices=this.obj.av;var room_types=booking.env.map_vars.translation_occupancies;if(prices.cheapest_double_selected_currency){popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+room_types[1]+'</td> <td class="b_overlay_td_room_price">'+prices.cheapest_double_selected_currency+"</td></tr>"}if(prices.cheapest_single_selected_currency){popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+room_types[0]+'</td> <td class="b_overlay_td_room_price">'+prices.cheapest_single_selected_currency+"</td></tr>"}}else{if(this.obj.prices){var prices=this.obj.prices;var room_types=booking.env.map_vars.translation_occupancies;for(var i in prices){if(prices[i]&&prices[i].room_persons&&prices[i].room_price){var total_persons=prices[i].room_persons-1;if(total_persons>3){total_persons=3}var print_room_price=(typeof(room_types[total_persons])!="undefined")?room_types[total_persons]:"";popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+print_room_price+'</td> <td class="b_overlay_td_room_price">'+prices[i].room_price+"</td></tr>"}else{if(prices[i]&&prices[i].room_from){popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+booking.env.map_vars.translation_from+'</td> <td class="b_overlay_td_room_price">'+prices[i].room_from+"</td></tr>"}}}}else{if(this.obj.b_min_rate){if(booking.env.map_vars.selected_currency_symbol){var currency=booking.env.map_vars.selected_currency_symbol}else{var currency=this.obj.b_currencycode}popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+booking.env.map_vars.translation_from+'</td> <td class="b_overlay_td_room_price">'+currency+" "+parseFloat(this.obj.b_min_rate).toFixed(2)+"</td></tr>"}else{if(this.obj.b_price||this.obj.b_price_selected_currency){if(this.obj.b_price_selected_currency){var currency=this.obj.b_price_selected_currency}else{var currency=this.obj.b_price}popup_html+='<tr class="b_overlay_tr"> <td class="b_overlay_td_room_occupancy" >'+booking.env.map_vars.translation_from+'</td> <td class="b_overlay_td_room_price">'+currency+"</td></tr>"}}}}popup_html+="</tbody></table>"}popup_html+="</p>";var popup=$(popup_html);var position=_b_map.fromLatLngToDivPixel(this.obj.latLng);var bounds=_b_map.getBounds();var top_right=_b_map.fromLatLngToDivPixel(bounds.getNorthEast());var bottom_left=_b_map.fromLatLngToDivPixel(bounds.getSouthWest());var hotel_offset=101;if(this.obj.b_type==="hotel"){hotel_offset=126}if(!this.obj.supress_positioning){if(position.x+hotel_offset>top_right.x){position.x=top_right.x-hotel_offset-5}else{if(position.x-hotel_offset<bottom_left.x+50){position.x=bottom_left.x+hotel_offset+50}}if(booking.env.b_site_experiment_searchresults_large_map&&position.x+hotel_offset>top_right.x-140){position.x=top_right.x-hotel_offset-140}}popup.css({top:position.y+"px",left:position.x+"px"});this.popup=popup;_open_info_window=popup;$(_b_map.getPane(google.maps.MAP_FLOAT_PANE)).append(popup);if(!this.obj.supress_positioning){var popup_height=popup.height();if(position.y+popup_height>bottom_left.y){position.y=position.y-(popup_height+20);popup.css({top:position.y+"px"})}}};bOverlay.prototype.remove=function(){$(this.popup).remove()};bOverlay.prototype.copy=function(){return new bOverlay(this.obj)};bOverlay.prototype.redraw=function(force){if(!force){return}}}function _buildLegendHTML(){if(booking.env.bigger_landing_page_map){var _legend_html='<div id="b_map_horizontal_legend"><h3>'+booking.env.map_legend+"</h3><table><tbody>";if(booking.env.b_action==="searchresults"){_legend_html+='<tr><td><img src="//q.bstatic.com/marker-hotel-orange.png" />';_legend_html+="</td><th>"+booking.env.map_hotel_matching_your_selection_criteria+"</th>";_legend_html+='<td><img src=" //r.bstatic.com/marker-hotel-grey.png" />';_legend_html+="</td><th>"+booking.env.map_other_hotel+"</th>"}else{if(booking.env.b_action==="hotel"){_legend_html+='<td><img src="//q.bstatic.com/marker-hotel-orange-large.png" /></td><th>'+booking.env.current_hotel+"</th>"}_legend_html+='<td><img src="//q.bstatic.com/marker-hotel-blue.png" />';_legend_html+="</td><th>"+booking.env.map_hotel+"</th>"}if(booking.env.b_site_experiment_json_clustering_on_map){_legend_html+='<td><img src="//q.bstatic.com/clusters/cluster.png" /></td><th><span style="text-transform: capitalize;">'+booking.env.map_hotels+"</span></th>"}_legend_html+='<td><img src="//r.bstatic.com/marker-landmark.png" /></td><th>'+booking.env.map_landmark+"</th>";_legend_html+='<td><img src="//q.bstatic.com/marker-city.png" /></td><th>'+booking.env.city+"</th>";_legend_html+='<td><img src="//q.bstatic.com/marker-airport.png" /></td><th>'+booking.env.airport+"</th></tr>";_legend_html+="</tbody></table>";_legend_html+="<p>"+booking.env.map_click_these_markers_on_the_map_for_more_detailed_information+"</p>";_legend_html+="</div>"}else{var _legend_html='<div id="b_map_legend"><h3>'+booking.env.map_legend+"</h3><table><tbody>";if(booking.env.b_action==="searchresults"){_legend_html+='<tr><td><img src="//q.bstatic.com/marker-hotel-orange.png" />';_legend_html+="</td><th>"+booking.env.map_hotel_matching_your_selection_criteria+"</th></tr>";_legend_html+='<tr><td><img src="//r.bstatic.com/marker-hotel-grey.png" />';_legend_html+="</td><th>"+booking.env.map_other_hotel+"</th></tr>"}else{if(booking.env.b_action==="hotel"){_legend_html+='<tr><td><img src="//q.bstatic.com/marker-hotel-orange-large.png" /></td><th>'+booking.env.current_hotel+"</th></tr>"}_legend_html+='<tr><td><img src="//q.bstatic.com/marker-hotel-blue.png" />';_legend_html+="</td><th>"+booking.env.map_hotel+"</th></tr>"}if(booking.env.b_site_experiment_json_clustering_on_map){_legend_html+='<td><img src="//q.bstatic.com/clusters/cluster.png" /></td><th><span style="text-transform: capitalize;">'+booking.env.map_hotels+"</span></th>"}_legend_html+='<tr><td><img src="//r.bstatic.com/marker-landmark.png" /></td><th>'+booking.env.map_landmark+"</th></tr>";_legend_html+='<tr><td><img src="//q.bstatic.com/marker-city.png" /></td><th>'+booking.env.city+"</th></tr>";_legend_html+='<tr><td><img src="//q.bstatic.com/marker-airport.png" /></td><th>'+booking.env.airport+"</th></tr>";_legend_html+="</tbody></table>";_legend_html+="<p>"+booking.env.map_click_these_markers_on_the_map_for_more_detailed_information+"</p>";_legend_html+='<p><a id="reload_currently_displayed_hotels" class="button" href="#">'+booking.env.map_legend_show_prices+"</a><small>("+booking.env.map_show_prices_and_availability_for_displayed_hotels+")</small></p>";_legend_html+="</div>"}return _legend_html}function initMarkerLight(){MarkerLight=function(obj,opts){if(!opts){opts={}}this.height_=opts.height||9;this.width_=opts.width||9;this.min_=opts.min||1;this.max_=opts.max||18;this.image_=opts.image;this.imageOver_=opts.imageOver;this.clicked_=0;this.zIndex_=opts.zOrder||1;this.latlng=obj.latLng;this.content=opts.content;this.label=opts.label;this.obj=obj};MarkerLight.prototype=new google.maps.Overlay();MarkerLight.prototype.initialize=function(map){var me=this;var div=document.createElement("div");div.style.position="absolute";div.style.cursor="pointer";div.style.zIndex=me.zIndex_;div.style.width=me.width_+"px";div.style.height=me.height_+"px";div.style.backgroundImage="url("+me.image_+")";div.style.backgroundRepeat="no-repeat";if(this.content&&this.content!=""){if(_b_show_label){var sp=document.createElement("span");sp.className="ml-text";sp.appendChild(document.createTextNode(this.label+": "+this.content+" "+booking.env.hotels.toLowerCase()));div.appendChild(sp)}else{var sp=document.createElement("span");sp.className="ml-text";sp.appendChild(document.createTextNode(this.content));div.appendChild(sp)}}GEvent.addDomListener(div,"click",function(event){if(!(_icon_mouse_down_flag&&_map_dragged_flag)){me.clicked_=1;GEvent.trigger(me,"click")}_icon_mouse_down_flag=false;_map_dragged_flag=false});GEvent.addDomListener(div,"mousedown",function(event){_icon_mouse_down_flag=true;_map_dragged_flag=false});google.maps.Event.addDomListener(div,"mouseover",function(){me.info_window=new bOverlay(me.obj);me.supress_positioning=false;_b_map.addOverlay(me.info_window);if(_b_map_focus&&_b_map_focus.title!=me.obj.title){google.maps.Event.trigger(_b_map_focus,"mouseout");_b_map_focus=null}});google.maps.Event.addDomListener(div,"mouseout",function(){if(me.info_window){me.info_window.remove()}});_b_map.getPane(G_MAP_MARKER_PANE).appendChild(div);this.map_=map;this.div_=div;var current_zoom=_b_map.getZoom();if(current_zoom>=this.min_&&current_zoom<=this.max_){this.show()}else{this.hide()}};MarkerLight.prototype.hide=function(){this.div_.style.display="none"};MarkerLight.prototype.show=function(){this.div_.style.display=""};MarkerLight.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_)};MarkerLight.prototype.copy=function(){var opts={};var obj=this.obj;opts.color=this.color_;opts.height=this.height_;opts.width=this.width_;opts.image=this.image_;opts.imageOver=this.image_;return new booking.map.MarkerLight(obj,opts)};MarkerLight.prototype.redraw=function(force){if(!force){return}var current_zoom=_b_map.getZoom();if(current_zoom>=this.min_&&current_zoom<=this.max_){this.show()}else{this.hide()}var divPixel=this.map_.fromLatLngToDivPixel(this.latlng);if(divPixel.x){this.div_.style.width=this.width_+"px";this.div_.style.left=(divPixel.x-(this.width_/2))+"px";this.div_.style.height=(this.height_)+"px";this.div_.style.top=(divPixel.y)-this.height_+"px"}else{this.div_.style.display="none"}};MarkerLight.prototype.getZIndex=function(m){return google.maps.Overlay.getZIndex(marker.getPoint().lat())-m.clicked*10000};MarkerLight.prototype.getPoint=function(){return this.latlng};MarkerLight.prototype.setStyle=function(style){for(s in style){this.div_.style[s]=style[s]}};MarkerLight.prototype.setImage=function(image){this.div_.style.background='url("'+image+'")'}}_b_icon_types={hotel:{image:"//q.bstatic.com/marker-hotel-blue.png",min:7,zOrder:10000,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},cluster:{image:"//q.bstatic.com/clusters/cluster.png",min:1,width:42,height:20,zOrder:10000,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},hotel_mini:{image:"//r.bstatic.com/marker-hotel-mini.png",min:4,max:12,zOrder:10000,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]},hotel_matching_criteria:{image:"//q.bstatic.com/marker-hotel-orange.png",min:9,zOrder:5000,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},hotel_matching_criteria_mini:{image:"//q.bstatic.com/marker-hotel-mini-orange.png",min:4,max:12,zOrder:5000,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]},hotel_not_matching_criteria:{image:"//q.bstatic.com/marker-hotel-grey.pngi",min:9,zOrder:100,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},hotel_not_matching_criteria_mini:{image:"//r.bstatic.com/marker-hotel-mini-grey.png",min:4,max:12,zOrder:100,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]},hotel_current:{image:"//q.bstatic.com/marker-hotel-orange-large.png",min:4,zOrder:100000,width:26,height:27,infoWindowAnchor:[13,27],iconAnchor:[13,27]},airport:{image:"//q.bstatic.com/marker-airport.png",min:5,zOrder:90,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},airport_current:{image:"//q.bstatic.com/marker-airport-large.png",min:5,zOrder:90,width:26,height:27,infoWindowAnchor:[13,27],iconAnchor:[13,27]},landmark:{image:"//r.bstatic.com/marker-landmark.png",min:12,zOrder:80,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},landmark_current:{image:"//r.bstatic.com/marker-landmark-large.png",min:12,zOrder:80,width:26,height:27,infoWindowAnchor:[13,27],iconAnchor:[13,27]},city:{image:"//q.bstatic.com/marker-city.png",min:4,max:16,zOrder:70,width:9,height:9,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]},city_current:{image:"//q.bstatic.com/marker-city-large.png",min:4,max:16,zOrder:70,width:15,height:15,infoWindowAnchor:[7.5,15],iconAnchor:[7.5,7.5]},country:{image:"//q.bstatic.com/marker-city.png",min:4,max:10,zOrder:60,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},region:{image:"//q.bstatic.com/marker-city.png",min:5,zOrder:50,infoWindowAnchor:[8.5,20],iconAnchor:[8.5,20]},district:{image:"//q.bstatic.com/marker-city.png",min:7,zOrder:40,width:9,height:9,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]},lat_long_current:{image:"//q.bstatic.com/marker-city.png",min:4,max:16,zOrder:40,width:9,height:9,infoWindowAnchor:[4.5,9],iconAnchor:[4.5,4.5]}};if(booking.env.b_site_experiment_json_clustering_on_map){for(var i in _b_icon_types){_b_icon_types[i].min=1;_b_icon_types[i].max=999}}function _buildMarker(obj){if(!obj.icon_type){obj.icon_type=obj.b_type}if(obj.b_type!="cluster"){var marker=new MarkerLight(obj,{image:_b_icon_types[obj.icon_type].image,width:(_b_icon_types[obj.icon_type].width)?_b_icon_types[obj.icon_type].width:17,height:(_b_icon_types[obj.icon_type].height)?_b_icon_types[obj.icon_type].height:20,min:_b_icon_types[obj.icon_type].min,max:_b_icon_types[obj.icon_type].max,zOrder:_b_icon_types[obj.icon_type].zOrder})}else{var marker=new MarkerLight(obj,{image:"//q.bstatic.com/clusters/cluster.png",width:42,height:20,content:obj.b_nr_hotels,label:obj.b_cluster_name,min:_b_icon_types[obj.icon_type].min,max:_b_icon_types[obj.icon_type].max,zOrder:_b_icon_types[obj.icon_type].zOrder})}if(typeof obj.url!="undefined"&&obj.url){marker.url=obj.url;google.maps.Event.addDomListener(marker,"click",function(){if(typeof(booking.google.mapTracker)!="undefined"){booking.google.trackEvent(booking.google.mapTracker,"Icon clicked: "+obj.b_type,document.body.id)}document.location=this.url})}else{google.maps.Event.addDomListener(marker,"click",function(){if(typeof booking.google.mapTracker!="undefined"){booking.google.trackEvent(booking.google.mapTracker,"Cluster clicked",document.body.id)}if(obj.b_bounding_box){var coords=obj.b_bounding_box.split(",");var sw=new google.maps.LatLng(coords[1],coords[0]),ne=new google.maps.LatLng(coords[3],coords[2]);var bounds=new google.maps.LatLngBounds(sw,ne);if(obj.b_nr_hotels>1){var _b_clusters_type=_b_cluster_mapping[obj.b_dest_type],_b_clear_markers=true,_b_current_zoom_level=_b_map.getZoom(),_b_new_zoom_level=_b_map.getBoundsZoomLevel(bounds);if(_b_current_zoom_level<_b_new_zoom_level){_b_map.setCenter(bounds.getCenter(),_b_map.getBoundsZoomLevel(bounds))}else{_b_map.setCenter(bounds.getCenter(),_b_current_zoom_level+1)}}else{_b_map.setCenter(bounds.getCenter(),14)}}else{_b_map.setCenter(obj.latLng);_b_map.setZoom(parseInt(_b_map.getZoom())+1)}return false})}return marker}function loadGoogleMapsAPI(){google.load("maps","2",{language:booking.env.b_lang,callback:_GoogleMapsApiCallback,other_params:"client=gme-booking&sensor=false"})}function _GoogleMapsApiCallback(){_google_api_is_loaded=true;booking.map.show()}function _createModalWindow(){if(booking.env.bigger_landing_page_map){$("#fixed_map_container").html('<div id="b_gmap"><span id="b_map_title"><h2>'+booking.env.map+'</h2><a href="#" id="close_map">'+booking.env.close_map+'</a></span><div id="b_gmap_inner"></div>'+_buildLegendHTML()+'</div><div id="b_shadow"></div>');if(!document.getElementById("show_more_dest")){$("#promo_map_box .landing").hide().before('<p style="text-align: right;" id="show_more_dest"><a href="#" style="background: url(//q.bstatic.com/static/img/my_hotels_actions.gif) no-repeat 0 3px; text-decoration: none; padding-left: 12px;">'+booking.env.more_destinations+"</a></p>")}_embed_map();_showMoreDest()}else{if(booking.env.b_action=="searchresults"){$("#open_map").hide();$("#frm").append('<input type="hidden" name="map" value="1" id="force_map">');$("#sr_map").show().html('<div id="b_map_container" class="static"><div id="b_gmap"><a href="#" id="close_map">'+booking.env.close_map+"</a>"+_buildLegendHTML()+'<div id="b_gmap_inner"></div></div></div>');$("#b_gmap, #b_gmap_inner").width($("#sr_map").width());setTimeout(function(){$("#b_gmap_inner").height($("#b_map_legend").height()+52)},1000);_setUpMapResize()}else{$(document.body).append('<div id="b_map_container"><div id="b_gmap"><span id="b_map_title"><h2>'+booking.env.map+'</h2><a href="#" id="close_map">'+booking.env.close_map+'</a></span><div id="b_gmap_inner"></div>'+_buildLegendHTML()+'</div><div id="b_shadow"></div></div>');_centerModalWindow()}}}function _setUpMapResize(){var map_resize_timeout=0;$(window).resize(function(){if(map_resize_timeout){clearTimeout(map_resize_timeout)}map_resize_timeout=setTimeout(function(){$("#b_gmap, #b_gmap_inner").width($("#searchresultsTmpl").width()-266)},100)})}function _embed_map(append){$("#b_shadow").hide();$("#b_map_title").hide();var b_gmap=$("#b_gmap");b_gmap.css({padding:"0px",width:_initial_width,height:"auto"}).parent().parent().css("height",b_gmap.height()+6);var map_inner=$("#b_gmap_inner").css({"float":"none",width:_initial_width});_map_is_embedded=1;var map_resize_timeout=0;if(_b_map){_b_map.checkResize()}$(window).resize(function(){if(_map_is_embedded===1){var wrapper_width=_map_wrapper.width();var map_width=map_inner.width();if(wrapper_width&&map_width&&wrapper_width!=map_width){if(map_resize_timeout){clearTimeout(map_resize_timeout)}map_resize_timeout=setTimeout(function(){map_resize_timeout=0;b_gmap.width(wrapper_width);map_inner.width(wrapper_width);_initial_width=wrapper_width;_b_map.checkResize()},400)}}});if(append===true){$("#b_map_legend").remove();show_popup=0;$("#b_gmap_inner").after(_buildLegendHTML());_map_wrapper.html($("#b_map_container").attr("id","fixed_map_container").css({left:"auto",top:"auto"})).show();setTimeout(function(){var new_wrapper_width=_map_wrapper.width();map_inner.width(new_wrapper_width);b_gmap.width(new_wrapper_width);_b_map.checkResize()},100);$("#promo_map_box").show()}show_popup=1;append_legend=1}function _showMoreDest(){$("p#show_more_dest a").toggle(function(){$(this).css("backgroundPosition","0 -10px").html(booking.env.show_map).parent().next().fadeIn();return false},function(){$(this).css("backgroundPosition","0 3px").html(booking.env.more_destinations).parent().next().fadeOut();return false})}function _centerModalWindow(){var scrollTop=(document.body.scrollTop==0)?(window.pageYOffset)?window.pageYOffset:(document.body.parentElement)?document.body.parentElement.scrollTop:0:document.body.scrollTop;var css_top=scrollTop+($(window).height()/2-$("#b_gmap").height()/2);var css_left=(document.body.offsetWidth-$("#b_gmap").width())/2;if(css_top<0){css_top=0}if(_b_map){_b_map.draggableObject.moveTo(new google.maps.Point(css_left,css_top));$("#b_map_container").css({top:css_top,left:css_left})}else{$("#b_map_container").css({top:css_top,left:css_left})}$("#b_gmap").bgiframe()}function _loadGoogleMap(){var include_center_in_bounds=true,center,zoom;if(_b_selected_hotel&&_b_target_coords){_b_force_no_clusters=true;var coords=_b_target_coords.split(",");var center=new google.maps.LatLng(coords[1],coords[0]);zoom=parseInt(_b_initial_zoom_level)}else{if(booking.env.b_map_google_bounding_box){var coords=booking.env.b_map_google_bounding_box.split(",");var sw=new google.maps.LatLng(coords[1],coords[0]),ne=new google.maps.LatLng(coords[3],coords[2]);var bounds=new google.maps.LatLngBounds(sw,ne);center=bounds.getCenter()}else{if(typeof _b_initial_zoom_level!="undefined"&&_b_initial_zoom_level){if(booking.env.b_action==="hotel"){_b_force_no_clusters=true}zoom=parseInt(_b_initial_zoom_level)}}}if(!center){if(booking.env.b_map_center_latitude&&booking.env.b_map_center_longitude){center=new google.maps.LatLng(booking.env.b_map_center_latitude,booking.env.b_map_center_longitude)}else{if(booking.env.b_latitude&&booking.env.b_longitude){center=new google.maps.LatLng(booking.env.b_latitude,booking.env.b_longitude)}}}initMarkerLight();booking.promotions.load(booking.env);_buildCustomOverlay();if(booking.env.b_site_experiment_increase_country_map_zoom){zoom++}_b_map=new google.maps.Map2(document.getElementById("b_gmap_inner"));if(zoom){_b_map.setCenter(center,zoom)}else{if(bounds){_b_map.setCenter(center);_b_map.setZoom(_b_map.getBoundsZoomLevel(bounds))}}_b_map.addControl(new google.maps.LargeMapControl());_b_map.addControl(new google.maps.MapTypeControl());_b_map.addControl(new google.maps.ScaleControl());_b_map.enableContinuousZoom();if(booking.env.b_action=="hotel"&&!booking.env.touch_os){_b_map.draggableObject=new google.maps.DraggableObject(document.getElementById("b_map_container"))}updateViewLink();if(booking.env.b_action=="searchresults"){booking.hotelsMatchingCriteria.load()}_processPromotions();if(booking.pageSubject){if(booking.env.b_action==="hotel"){_b_marker_ids.push(booking.pageSubject.b_hotel_id);_b_markers[booking.pageSubject.b_hotel_id]=booking.pageSubject}else{_b_marker_ids.push(booking.pageSubject.id);_b_markers[booking.pageSubject.id]=booking.pageSubject}}google.maps.Event.addDomListener(_b_map,"moveend",function(){_map_dragged_flag=true;if(typeof(booking.google.mapTracker)!="undefined"&&_zoomed===0){booking.google.trackEvent(booking.google.mapTracker,"Drag",document.body.id)}_zoomed=0;booking.map.load();booking.map.link()});google.maps.Event.addDomListener(_b_map,"zoomend",function(oldLevel,newLevel){if(booking.env.b_site_experiment_map_show_search_area){_redrawCircle()}if(typeof(booking.google.mapTracker)!="undefined"){_zoomed=1;var zoom_type="";if(typeof oldLevel!="undefined"&&typeof newLevel!="undefined"){if(oldLevel<newLevel){zoom_type="in"}else{zoom_type="out"}}booking.google.trackEvent(booking.google.mapTracker,"Zoom: "+zoom_type,document.body.id)}if(!_b_clear_markers){_b_clear_markers=true;_b_clusters_type=null}booking.map.link()});_b_map.savePosition();if(booking.env.b_site_experiment_searchresults_large_map){scrollMapTop()}}function _inflateBoundsBox(){var promo;for(var i in booking.promotions){if(booking.promotions.hasOwnProperty(i)&&(typeof booking.promotions[i]=="object")){promo=booking.promotions[i];if(!promo.latLng){promo.latLng=new google.maps.LatLng(promo.b_latitude,promo.b_longitude)}if((booking.env.b_action!=="searchresults"&&promo.b_type==="hotel")||booking.env.b_action==="place"||booking.env.b_action==="region"||(booking.env.b_action=="country"&&(promo.b_type==="city"||promo.b_type==="airport"))){_b_map_bounding_box.extend(promo.latLng)}}}}function _processPromotions(){for(var i in booking.promotions){if(booking.promotions.hasOwnProperty(i)&&typeof booking.promotions[i]=="object"){var promo=booking.promotions[i];promo.latLng=new google.maps.LatLng(promo.b_latitude,promo.b_longitude);promo.url=promo.url;promo.obj=booking.promotions[i];if(promo.b_type==="hotel"&&booking.env.b_action==="searchresults"){if(booking.hotelsMatchingCriteria[i]){if(_b_selected_hotel==promo.b_hotel_id||_b_selected_hotel==promo.id.replace(/\D/g,"")){promo.icon_type="hotel_current"}else{promo.icon_type="hotel_matching_criteria"}}else{promo.icon_type="hotel_not_matching_criteria"}_b_marker_ids.push(promo.b_hotel_id);_b_markers[promo.b_hotel_id]=promo}else{var index=promo.id.replace(/\D/g,"");if(index==""){index=Math.floor(Math.random()*999999)}_b_marker_ids.push(index);_b_markers[index]=promo}}}}function _addMarkersToMarkerManager(){var x=_b_marker_ids.length;while(x--){var i=_b_marker_ids[x];if(_b_markers[i]&&(_b_markers[i].icon_type||_b_markers[i].b_type)){if(!_b_markers[i].icon_type){_b_markers[i].icon_type=_b_markers[i].b_type}_b_markers[i]=_buildMarker(_b_markers[i]);_b_map.addOverlay(_b_markers[i]);if(_b_first_load_display_clicked_hotel&&i==_b_selected_hotel){_b_map_focus=_b_markers[i];_b_map.setCenter(_b_markers[i].latLng);_b_map.savePosition();google.maps.Event.trigger(_b_markers[i],"mouseover");_b_first_load_display_clicked_hotel=false}}}}function _clearMarkersAndRecenterOnNewHotel(){_b_map.clearOverlays();_b_marker_ids=[];_b_markers={};if(booking.pageSubject){if(booking.env.b_action==="hotel"){_b_marker_ids.push(booking.pageSubject.b_hotel_id);_b_markers[booking.pageSubject.b_hotel_id]=booking.pageSubject}else{_b_marker_ids.push(booking.pageSubject.id);_b_markers[booking.pageSubject.id]=booking.pageSubject}}_processPromotions();booking.loadCurrentHotels();_addMarkersToMarkerManager()}function _centerInHotel(force_no_pan){if(_b_previous_selected_hotel&&_b_markers[_b_previous_selected_hotel].obj){var previous_selected_hotel=_b_markers[_b_previous_selected_hotel].obj;if(booking.env.b_action=="searchresults"){previous_selected_hotel.icon_type="hotel_matching_criteria"}else{previous_selected_hotel.icon_type="hotel"}if(previous_selected_hotel.b_id){var id=previous_selected_hotel.b_id}else{var id=previous_selected_hotel.b_hotel_id}_b_map.removeOverlay(_b_markers[id]);_b_markers[previous_selected_hotel.b_id]=_buildMarker(previous_selected_hotel);_b_map.addOverlay(_b_markers[previous_selected_hotel.b_id])}if(_b_markers[_b_selected_hotel]){if(_b_markers[_b_selected_hotel].obj){var selected_hotel=_b_markers[_b_selected_hotel].obj;selected_hotel.icon_type="hotel_current"}_b_map.removeOverlay(_b_markers[_b_selected_hotel]);_b_markers[_b_selected_hotel]=_buildMarker(selected_hotel);_b_map.addOverlay(_b_markers[_b_selected_hotel])}if(booking.env.b_site_experiment_json_clustering_on_map){setTimeout(function(){if(_b_selected_hotel&&_b_markers[_b_selected_hotel].div_){google.maps.Event.trigger(_b_markers[_b_selected_hotel].div_,"mouseover");_b_selected_hotel=null}},500)}else{if(_b_selected_hotel&&_b_markers[_b_selected_hotel].div_){google.maps.Event.trigger(_b_markers[_b_selected_hotel].div_,"mouseover");_b_selected_hotel=null}}}function displayMapAndFocus(e){if(!_google_api_is_loaded){booking.google.AjaxApiLoader.load("booking.map.gmap")}else{if(typeof google.maps!="undefined"){if(google.maps.BrowserIsCompatible()){if(typeof $("#fixed_map_container_wrapper").get(0)!="undefined"){var _map_container=$("#fixed_map_container");var map_is_open=false;$("#embedded_map_loading").hide();_map_wrapper=$("#fixed_map_container_wrapper");if(_map_wrapper.width()!=0){_initial_width=_map_wrapper.width()}}else{if($("#b_map_container").length===0){var map_is_open=false}else{var map_is_open=true}}if(!map_is_open){_createModalWindow();_loadGoogleMap();booking.loadCurrentHotels();_addMarkersToMarkerManager();loadJSONHotels();$("window").unload(function(){GUnload()});$("#close_map").click(function(){$("#b_map_container").hide();$("#open_map").show();$("#force_map").remove();if(typeof(booking.google.mapTracker)!="undefined"){booking.google.trackEvent(booking.google.mapTracker,"Close",document.body.id)}if(booking.env.b_site_experiment_keep_map_open){window.location.hash="";$("#filterbox_options a, #sort_by a").each(function(){this.href=this.href.slice(0,-4)})}return false})}else{if(_map_is_embedded===1){_map_is_embedded=0;var map_container=$("#fixed_map_container").attr("id","b_map_container");$("#b_shadow").show();$("#b_map_title").show();$("#b_map_horizontal_legend").remove();var map_inner=$("#b_gmap_inner");map_inner.css({"float":"left",width:515,height:400});_b_map.checkResize();if(booking.env.append_legend===1){map_inner.after(_buildLegendHTML());booking.env.append_legend=0}$("#b_map_container").css({position:"absolute"});$("#b_gmap").css({width:640,height:427,padding:"10px 15px 15px"});map_container.remove();$(document.body).append(map_container);$("#promo_map_box").hide();$("#close_map").click(function(){_b_map.draggableObject.disable();_embed_map(true);if(typeof(booking.google.mapTracker)!="undefined"){booking.google.trackEvent(booking.google.mapTracker,"Close",document.body.id)}return false});if(!_b_map.draggableObject){_b_map.draggableObject=new google.maps.DraggableObject(document.getElementById("b_map_container"))}else{_b_map.draggableObject.enable()}}else{$("#b_map_container").show()}$("#open_map").hide();$("#frm").append('<input type="hidden" name="map" value="1" id="force_map">');if(typeof e.target!="undefined"){if(e.target.id!="open_map"){scrollMapTop()}}if(_b_selected_hotel&&_b_target_coords){_b_force_no_clusters=true;var coords=_b_target_coords.split(",");var center=new google.maps.LatLng(coords[1],coords[0]);_b_map.setCenter(center,parseInt(_b_initial_zoom_level));_centerInHotel(_b_selected_hotel,false)}else{if(booking.env.b_map_google_bounding_box){var coords=booking.env.b_map_google_bounding_box.split(",");var sw=new google.maps.LatLng(coords[1],coords[0]),ne=new google.maps.LatLng(coords[3],coords[2]);var bounds=new google.maps.LatLngBounds(sw,ne);_b_map.setCenter(bounds.getCenter(),_b_map.getBoundsZoomLevel(bounds))}else{if(typeof _b_initial_zoom_level!="undefined"&&_b_initial_zoom_level){if(booking.env.b_action==="hotel"){_b_force_no_clusters=true}_b_map.setZoom(parseInt(_b_initial_zoom_level))}}}scrollMapTop();if(_b_first_load_display_clicked_hotel){_b_first_load_display_clicked_hotel=false}}}else{$(".show_map").remove()}}else{setTimeout("booking.map.show",1000)}}}function removeNonVisibleMarkers(){var map_bounds=_b_map.getBounds();var x=_b_marker_ids.length;while(x--){var i=_b_marker_ids[x];if(_b_markers[i]&&!map_bounds.containsLatLng(_b_markers[i].latLng)){try{_b_map.removeOverlay(_b_markers[i])}catch(err){}delete _b_markers[i]}}}function loadJSONHotels(){var bounds=_b_map.getBounds();var bounding_box=bounds.getSouthWest().lng()+","+bounds.getSouthWest().lat()+","+bounds.getNorthEast().lng()+","+bounds.getNorthEast().lat();var url="/hotelsonmap."+booking.env.b_lang_for_url+".json"+booking.env.b_query_params_no_ext+";BBOX="+bounding_box;if(booking.env.dest_type&&booking.env.dest_id){url+=";dest_type="+booking.env.dest_type+";dest_id="+booking.env.dest_id}if(booking.env.b_site_experiment_json_clustering_on_map){url+=";cluster=1;zoomlevel="+_b_map.getZoom();if(_b_force_no_clusters){url+=";cluster_view_type=hotel";_b_force_no_clusters=false}else{if(_b_clusters_type){url+=";cluster_view_type="+_b_clusters_type}}}if(booking.env.b_checkin_date&&booking.env.b_checkout_date){url+=";checkin="+booking.env.b_checkin_date+";checkout="+booking.env.b_checkout_date}if(booking.env.b_param_pr_id){url+=";pr_id="+booking.env.b_param_pr_id}if(booking.env.b_param_class){url+=";class="+booking.env.b_param_class}if(booking.env.b_param_hotelfacility){url+=";hotelfacility="+booking.env.b_param_hotelfacility}if(booking.env.b_param_district_id){url+=";district_id="+booking.env.b_param_district_id}if(booking.env.b_param_hoteltag){url+=";hoteltag="+booking.env.b_param_hoteltag}if(booking.env.b_param_chaincode){url+=";chaincode="+booking.env.b_param_chaincode}if(booking.env.b_param_score_min){url+=";score_min="+booking.env.b_param_score_min}var download=new google.maps.DownloadUrl(url,booking.map.process)}function processJSONHotels(response,code){if(response&&code==200){placemarks=!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(response.replace(/"(\\.|[^"\\])*"/g,"")))&&eval("("+response+")");var placemark_count=0;if(placemarks.b_clusters_found){placemark_count=placemarks.b_clusters_found}if(placemarks.b_clusters_type){_b_clusters_type=placemarks.b_clusters_type}else{_b_clusters_type="hotel"}if(placemarks.b_hotels){placemarks=placemarks.b_hotels}if(booking.env.b_site_experiment_json_clustering_on_map){_b_map.clearOverlays();_b_markers={};_b_clear_markers=false;if(_b_clusters_type=="hotel"){if(booking.pageSubject){if(booking.env.b_action==="hotel"){_b_marker_ids.push(booking.pageSubject.b_hotel_id);_b_markers[booking.pageSubject.b_hotel_id]=booking.pageSubject}else{_b_marker_ids.push(booking.pageSubject.id);_b_markers[booking.pageSubject.id]=booking.pageSubject}}_processPromotions();booking.loadCurrentHotels();_addMarkersToMarkerManager()}if(booking.env.b_action==="searchresults"&&_b_clusters_type){$("#b_map_explain").remove();var icon_type=(_b_clusters_type=="anon")?"hotel":_b_clusters_type;var explain_html='<div id="b_map_explain">'+booking.env.showing_levels[icon_type];if(_b_clusters_type!="hotel"){explain_html+='<br><small><a href="#" id="click_to_zoom_in">'+booking.env.zoom_in+"</a></small>"}$("#b_gmap_inner").append(explain_html+"</div>");$("#click_to_zoom_in").click(function(){_b_map.setZoom(parseInt(_b_map.getZoom())+1)})}}booking.env.map_first_opened=false;_b_show_label=false;for(var i in placemarks){if(!_b_markers[i]){placemark=placemarks[i];if(_b_clusters_type!="hotel"){placemark.b_type="cluster";if(placemark.b_avg_lat&&placemark.b_avg_long){placemark.latLng=new google.maps.LatLng(placemark.b_avg_lat,placemark.b_avg_long);placemark.url=""}else{placemark.latLng=new google.maps.LatLng(placemark.b_latitude,placemark.b_longitude);placemark.url=booking.env.b_url_start+placemark.url;placemark.url+=booking.env.b_query_params_with_lang}}else{placemark.b_type="hotel";placemark.latLng=new google.maps.LatLng(placemark.b_latitude,placemark.b_longitude);if(booking.env.b_action==="searchresults"){if(booking.hotelsMatchingCriteria[i]||booking.hotelsMatchingCriteria[i.replace("hotel_","")]){if(i!=_b_selected_hotel){placemark.icon_type="hotel_matching_criteria"}else{placemark.icon_type="hotel_current"}}else{placemark.icon_type="hotel_not_matching_criteria"}}else{placemark.icon_type="hotel"}placemark.url=booking.env.b_url_start+placemark.url;placemark.url+=booking.env.b_query_params_with_lang}placemark=_buildMarker(placemark);_b_marker_ids.push(i);_b_markers[i]=placemark;_b_map.addOverlay(placemark)}}if(_b_selected_hotel){_centerInHotel()}}else{placemarks="Request failed with code "+code+"."}}function buildCurrentHotel(hotel){hotel.b_type="hotel";hotel.title=hotel.b_name;hotel.url=hotel.b_url;hotel.b_image_url=hotel.b_main_photo;hotel.latLng=new google.maps.LatLng(hotel.b_latitude,hotel.b_longitude);if(booking.env.b_action==="searchresults"){if(booking.hotelsMatchingCriteria[hotel.b_id]){if(hotel.b_id!=_b_selected_hotel){hotel.icon_type="hotel_matching_criteria"}else{hotel.icon_type="hotel_current"}}else{hotel.icon_type="hotel_not_matching_criteria"}}hotel.url=booking.env.b_url_start+hotel.url;_b_marker_ids.push(hotel.b_id);_b_markers[hotel.b_id]=hotel}function updateViewLink(){var map_center=_b_map.getCenter();var radius=Math.ceil(15.0588*Math.pow(2,10-_b_map.getZoom()));if(radius>150){radius=150}var display_hotels_url="/searchresults"+booking.env.b_query_params_with_lang+";latitude="+map_center.y+";longitude="+map_center.x+";radius="+radius;display_hotels_url+=";ssne=lat%3A+"+map_center.y+"+long%3A+"+map_center.x;$("#reload_currently_displayed_hotels").unbind("click").attr("href",display_hotels_url).click(function(){window.location.href=this.href})}function setZIndexOfMarkers(marker){return parseInt(GOverlay.getZIndex(marker.getPoint().lat()),10)+_b_icon_z_indices[this.icon.type]}function truncateDescription(description){var initial_length=_max_length_of_hotel_description;var counter=1;while(description.charAt(_max_length_of_hotel_description-counter)!=" "){counter=counter+1}return description.substr(0,_max_length_of_hotel_description-counter)+"..."}function attachClickEvents(){if(booking.env.bigger_landing_page_map){_map_is_embedded=1;if(!_b_initial_zoom_level){_b_initial_zoom_level=(booking.env.b_map_google_static_thumbnail_zoom_level)?booking.env.b_map_google_static_thumbnail_zoom_level:(booking.env.b_action=="country")?5:11}booking.map.show()}$(".show_map").click(function(e){if(_b_selected_hotel){_b_previous_selected_hotel=_b_selected_hotel}if(booking.env.b_action==="hotel"){_b_selected_hotel=$("input[name=hotel_id]").val()}else{_b_selected_hotel=this.id.replace(/\D/g,"")}if(this.getAttribute("data-bounding-box")){_b_initial_bounding_box=this.getAttribute("data-bounding-box")}else{_b_initial_zoom_level=this.getAttribute("rel")}if(_b_selected_hotel!=""){_b_first_load_display_clicked_hotel=true;_b_target_coords=this.getAttribute("data-coords")}if(!_b_initial_zoom_level){_b_initial_zoom_level=(booking.env.b_map_google_static_thumbnail_zoom_level)?booking.env.b_map_google_static_thumbnail_zoom_level:(booking.env.b_action=="country")?5:11}booking.map.show(e);if(booking.env.b_site_experiment_keep_map_open){window.location.hash="map";$("#filterbox_options a, #sort_by a").each(function(){this.href+="#map"})}if(typeof(booking.google.mapTracker)!="undefined"){booking.google.trackEvent(booking.google.mapTracker,"Display",document.body.id)}return false});if(!booking.env.b_site_experiment_tripadvisor_suppress_map_opening){if(booking.env.b_site_experiment_keep_map_open&&window.location.hash=="#map"){$("#show_map").click()}else{if(window.location.href.indexOf("map=1")!=-1){$("#show_map").click()}}}}function scrollMapTop(){var t=0;if($("#close_map").length){t=$("#close_map").offset().top}window.scrollTo(0,t)}return{init:attachClickEvents,show:displayMapAndFocus,hide:removeNonVisibleMarkers,gmap:loadGoogleMapsAPI,load:loadJSONHotels,process:processJSONHotels,buildCurrentHotel:buildCurrentHotel,link:updateViewLink,setz:setZIndexOfMarkers,trunc:truncateDescription,scrollMapTop:scrollMapTop}}();booking.ensureNamespaceExists("startup_load");booking[sNSStartupLoad].map={priority:5,init:function(){booking.map.init();return true}};
