(function(){var getType=function(type){var custom=Element.Events.get(type);return custom?custom.base:type};var checkOverOut=function(el,e){if(el==e.target||el.hasChild(e.target)){var related=e.relatedTarget;if(related==undefined)return true;if(related===false)return false;return($type(el)!='document'&&related!=el&&related.prefix!='xul'&&!el.hasChild(related))}};var check=function(e,test){var target=e.target;var isOverOut=/^(mouseover|mouseout)$/.test(e.type);var els=this.getElements(test);var match=els.indexOf(target);if(match>=0)return els[match];for(var i=els.length;i--;){var el=els[i];if(el==target||el.hasChild(target)){return(!isOverOut||checkOverOut(el,e))?el:false}}};var splitType=function(type){if(type.test(/.*?\(.*?\)/)){return{event:type.match(/.*?(?=\()/),selector:type.split('(')[1].replace(/\)$/,"")}}return{event:type}};var oldAddEvent=Element.prototype.addEvent,oldAddEvents=Element.prototype.addEvents,oldRemoveEvent=Element.prototype.removeEvent,oldRemoveEvents=Element.prototype.removeEvents;Element.implement({addEvent:function(type,fn){var splitted=splitType(type);if(splitted.selector){var monitors=this.retrieve('$moo:delegateMonitors',{});if(!monitors[type]){var monitor=function(e){var el=check.call(this,e,splitted.selector);if(el)this.fireEvent(type,[e,el],0,el)}.bind(this);monitors[type]=monitor;oldAddEvent.call(this,splitted.event,monitor)}}return oldAddEvent.apply(this,arguments)},removeEvent:function(type,fn){var splitted=splitType(type);if(splitted.selector){var events=this.retrieve('events');if(!events[type]||(fn&&!events[type].contains(fn)))return this;if(fn)events[type].erase(fn);else events[type].empty();if(events[type].length==0){var monitors=this.retrieve('$moo:delegateMonitors',{});oldRemoveEvent(splitted.event,monitors[type]);delete monitors[type]}return this}return oldRemoveEvent.apply(this,arguments)},fireEvent:function(type,args,delay,bind){var events=this.retrieve('events');if(!events||!events[type])return this;events[type].keys.each(function(fn){fn.create({'bind':bind||this,'delay':delay,'arguments':args})()},this);return this}})})();var toggleModal=function(backgroundColor,options){if($("modal")){$("modal").dispose();return false}var options=$merge({zIndex:10000000,opacity:.8,events:$empty()},options);if(!$type(backgroundColor)&&!$("modal"))return false;return new Element("div",{id:"modal",styles:{position:"absolute",top:0,left:0,width:window.getScrollWidth(),height:window.getScrollHeight(),background:backgroundColor,"z-index":options.zIndex},opacity:options.opacity,events:options.events}).inject(document.body)};var generalMap=new Class({Implements:[Options,Events],options:{maxPoints:300,zoomTriggerLevel:9,maxClusterIconSize:40,minClusterIconSize:25,mapMoveEndWait:700,start_lat:42.03297,start_lng:12.3486,start_zoom:6,start_query:'',lang:'it',msg_hotel_visible:'%s Hotels visibile on map',msg_beb_visible:'%s Bed And Breakfast visibile on map',msg_default_suggestion:'Please Click on a marker to zoom in to a city, or move the map to the area of interest',msg_no_geocode:'No result was found for your query',msg_popup_blocked:'Your Browser is blocking this page to open the requested page. Please allow the page "maps.bbdormire.com" to open pop-ups.<br/><a href="%s" target="_blank">To open the requested page click here</a>',msg_more_than:'',msg_no_bb:'',msg_default_address:'',msg_price_any:''},curSelectedMarker:null,markerCities:null,timer:null,requestCount:1,requestType:1,curZoom:null,requestHotels:false,requestBBs:false,citiesVisible:false,baseHrefBB:'',baseHrefHotels:'',numHotels:0,numBBs:0,roomType:'',icons:[],initReqFormSend:function(){this.timer=$clear(this.timer);$('mapLoading').setStyle('display','');this.purgeList();$('reqForm').neLat2.set('value',this.map_obj.getBounds().getNorthEast().lat());$('reqForm').neLng2.set('value',this.map_obj.getBounds().getNorthEast().lng());$('reqForm').swLat2.set('value',this.map_obj.getBounds().getSouthWest().lat());$('reqForm').swLng2.set('value',this.map_obj.getBounds().getSouthWest().lng());$('reqForm').z2.set('value',this.curZoom);$('reqForm').numBBs.set('value',this.numBBs);$('reqForm').numHotels.set('value',this.numHotels);if(this.requestBBs){$('reqForm').requestBBs.set('value','1')}else{$('reqForm').requestBBs.set('value','')}if(this.requestHotels){$('reqForm').requestHotels.set('value','1')}else{$('reqForm').requestHotels.set('value','')}if(parseFloat($('searchFormBudget').value)>0){$('reqForm').budget.set('value',parseFloat($('searchFormBudget').value))}else{$('reqForm').budget.set('value','0');$('searchFormBudget').value=$('searchFormBudget').get('alt')}$('reqForm').send()},initSearchForm:function(){$(this.searchForm).addEvent('submit',function(event){event.stop();var request_bb;var request_hotels;$(this.searchForm).getElements('input[type=radio]').each(function(el){if(el.value=='bb')request_bb=el.checked;if(el.value=='h')request_hotels=el.checked}.bind(this));var search_here=(this.curZoom>this.options.zoomTriggerLevel&&($(this.searchForm).searchFormAdress.value==''||$(this.searchForm).searchFormAdress.value==this.options.msg_default_address));if(request_bb!=this.requestBBs||this.requestHotels!=request_hotels||!search_here){this.requestBBs=request_bb;this.requestHotels=request_hotels;this.purgeList(true);if(search_here){this.initReqFormSend()}else{this.geocode($(this.searchForm).searchFormAdress.value)}}}.bind(this))},initReqForm:function(){new Element('form',{'method':'post','action':'/aj/m.php','id':'reqForm','styles':{'display':'none'}}).injectInside(document.body);new Array('neLat1','neLng1','swLat1','swLng1','neLat2','neLng2','swLat2','swLng2','z1','z2','numBBs','numHotels','requestBBs','requestHotels','budget','cur','lang').each(function(el){new Element('input',{type:'hidden',name:el}).injectInside($('reqForm'))});$('reqForm').set('send',{'link':'cancel',onRequest:function(){},onComplete:function(response){$('mapLoading').setStyle('display','none');if(response==null||response=="")return;var rows=response.split("\n");var responseHeader=rows[0].split("|");rows.splice(0,1);$('reqForm').neLat1.set('value',responseHeader[0]);$('reqForm').neLng1.set('value',responseHeader[1]);$('reqForm').swLat1.set('value',responseHeader[2]);$('reqForm').swLng1.set('value',responseHeader[3]);$('reqForm').z1.set('value',responseHeader[4]);$('smallLabelContainer').setStyle('display','none');if(parseInt($('reqForm').z1.value)<=this.options.zoomTriggerLevel){if(this.markerCities==null){this.markerCities=new Array();this.left_no_bb_msg.setStyle('display','none');responseHeader[5]=parseInt(responseHeader[5]);responseHeader[6]=parseInt(responseHeader[6]);rows.each(function(r){r=r.trim();if(r!="")var cP=this.createCluster(r.split("|"),responseHeader[5],responseHeader[6]);if($chk(cP))this.markerCities.push(cP)}.bind(this));this.triggerCities(true)}}else{rows.each(function(r){this.addToList(r)}.bind(this));if($('reqForm').requestHotels.get('value')==1){$(this.messageContainer).set('text',(this.numHotels>=this.options.maxPoints?this.options.msg_more_than+' ':'')+this.options.msg_hotel_visible.sprintf([this.numHotels]));this.left_no_bb_msg.setStyle('display','none')}else{$(this.messageContainer).set('text',(this.numBBs>=this.options.maxPoints?this.options.msg_more_than+' ':'')+this.options.msg_beb_visible.sprintf([this.numBBs]));if(this.numBBs==0){this.left_no_bb_msg.setStyle('display','')}else{this.left_no_bb_msg.setStyle('display','none')}}$(this.messageContainer).flash('#fffea1',this.messageBGcolor,3,'background-color',500)}}.bind(this)})},triggerCities:function(show){if(!this.markerCities)return;if(show&&!this.citiesVisible){this.markerCities.each(function(m){this.map_obj.addOverlay(m)}.bind(this));$(this.messageContainer).set('text',this.options.msg_default_suggestion);$(this.messageContainer).flash(this.messageBGcolor,'#fffea1',3,'background-color',500);this.citiesVisible=true}else if(!show&&this.citiesVisible){this.markerCities.each(function(m){this.map_obj.removeOverlay(m)}.bind(this));this.citiesVisible=false}},force_hotels:function(){$(this.searchForm).getElements('input[type=radio]').each(function(el){if(el.value=='bb')el.checked=false;if(el.value=='h')el.checked=true});this.requestBBs=false;this.requestHotels=true;this.purgeList(true);this.initReqFormSend()},initialize:function(mapContainer,listContainer,searchForm,messageContainer,options){this.setOptions(options);var origTimer=this.options.mapMoveEndWait;this.options.mapMoveEndWait=1;this.mapContainer=mapContainer;this.listContainer=listContainer;this.searchForm=searchForm;this.messageContainer=messageContainer;this.initReqForm();this.initSearchForm();$('reqForm').lang.value=this.options.lang;this.baseHrefBB='http://'+(this.options.lang=='it'?'www':this.options.lang)+'.bbdormire.com/bed-and-breakfast-';this.baseHrefHotels='http://'+(this.options.lang=='en'?'':this.options.lang+'.')+'hotels.bbdormire.com/Hotel.aspx?fileName=';new Watermark_form({collection:$$('#searchForm input[type=text]')});this.map_obj=new GMap2($(this.mapContainer));this.geoCoder=new GClientGeocoder();window.addEvent('resize',function(){if($chk(this.markerCities)&&this.map_obj.getZoom()<=this.options.zoomTriggerLevel){}else{this.timer=this.initReqFormSend.delay(this.options.mapMoveEndWait,this)}this.map_obj.checkResize()}.bind(this));var MapmoveEventListener=GEvent.bind(this.map_obj,"moveend",this,function(){this.curZoom=this.map_obj.getZoom();if(this.curZoom>this.options.zoomTriggerLevel||!$chk(this.markerCities)){this.timer=this.initReqFormSend.delay(this.options.mapMoveEndWait,this);this.triggerCities(false)}else if(this.curZoom<=this.options.zoomTriggerLevel){this.timer=$clear(this.timer);this.purgeList();this.triggerCities(true);$('reqForm').z1.set('value','1')}});var MapmovestartEventListener=GEvent.bind(this.map_obj,"movestart",this,function(){this.timer=$clear(this.timer);$('mapLoading').setStyle('display','none')});document.addEvent('unload',function(){GEvent.removeListener(MapmovestartEventListener);GEvent.removeListener(MapmoveEventListener);GUnload()});$(this.listContainer).addEvent('mouseout',function(){this.showLargeLabel('',false)}.bind(this));this.messageBGcolor=$(this.messageContainer).getStyle('background-color');this.left_default_msg=$('left_nav').getElements('div.default_message')[0];this.left_no_bb_msg=$('left_nav').getElements('div.no_bb_message')[0];this.left_no_bb_msg.getElements('a')[0].addEvent('click',function(){this.force_hotels()}.bind(this));var icon=new GIcon();icon.image="/img/mapicons/lodging_c.png";icon.iconSize=new GSize(17,22);icon.iconAnchor=new GPoint(8,11);this.icons.push(icon);var icon=new GIcon();icon.image="/img/mapicons/beb_c.png";icon.iconSize=new GSize(22,19);icon.iconAnchor=new GPoint(11,9);this.icons.push(icon);this.map_obj.setUIToDefault();this.map_obj.setCenter(new GLatLng(this.options.start_lat,this.options.start_lng),this.options.start_zoom);var largeTipContainer=new Element('div',{'class':'bbdormire_tip',id:'largeLabelContainer',styles:{'display':'none'}}).injectInside($(this.mapContainer));new Element('div',{'class':'tip-top'}).inject(largeTipContainer);var tipCenter=new Element('div',{'class':'tip'}).inject(largeTipContainer);new Element('div',{'class':'tip-title',id:'largeLabelTitle'}).inject(tipCenter);new Element('div',{'class':'tip-text',id:'largeLabelDiv'}).inject(tipCenter);new Element('div',{'class':'tip-bottom'}).inject(largeTipContainer);new Element('div',{id:'smallLabelContainer','class':'smallMapLabel',styles:{'display':'none'}}).injectInside($(this.mapContainer));var tablebody=new Element('tbody').injectInside(new Element('table').injectInside(new Element('div',{id:'mapLoading','class':'mapBox',styles:{'display':'none'}}).injectInside($(this.mapContainer))));tr=new Element('tr').injectInside(tablebody);new Element('td',{'class':'mapBoxL'}).injectInside(tr);new Element('img',{'src':'/img/loading/hor_pro149x11.gif'}).injectInside(new Element('td',{'class':'mapBoxC'}).injectInside(tr));new Element('td',{'class':'mapBoxR'}).injectInside(tr);var that=this;var mdlc=new Element('div',{'id':'modal_container','class':'abs_center','styles':{'display':'none','top':'30%'}}).injectInside(document.body);mdlc.innerHTML='<b class="b1h"></b><b class="b2h"></b><b class="b3h"></b><b class="b4h"></b><div style="padding:10px;">&nbsp;</div><b class="b4bh"></b><b class="b3bh"></b><b class="b2bh"></b><b class="b1h"></b>';$('list_strutture').addEvents({'mouseover(.ob)':function(e){this.morph({backgroundColor:'#bbeded'});that.showLargeLabel(this.get('id'),true)},'mouseout(.ob)':function(e){this.morph({backgroundColor:'#ffffff'});that.showLargeLabel(this.get('id'),false)},'mousedown(.ob)':function(e,el){var win_opened=null;var dest_win=null;if(this.get('id').substr(0,1)=='h'){dest_win=that.baseHrefHotels+this.retrieve('properties').href+'&languageCode='+(that.options.lang=='zh'?'CS':that.options.lang.toUpperCase())}else{dest_win=that.baseHrefBB+this.retrieve('properties').href+'.htm'}win_opened=window.open(dest_win);if(!win_opened||!win_opened.top){$('modal_container').getElements('div')[0].innerHTML='<p style="font-size:1.1em;">'+that.options.msg_popup_blocked.sprintf([dest_win])+'</p>';toggleModal("#555",{zIndex:1000,events:{click:function(){$('modal_container').setStyle('display','none');$("modal").fade(0);(function(){toggleModal()}).delay(500)}}});$('modal_container').setStyle('display','')}}});$(this.map_obj.getPane(G_MAP_MARKER_PANE)).addEvents({'mouseover(.b,.h)':function(e){var l_id=this.get('id').substr(7);$(l_id).morph({backgroundColor:'#bbeded'});that.showLargeLabel(l_id,true)},'mouseout(.b,.h)':function(e){var l_id=this.get('id').substr(7);$(l_id).morph({backgroundColor:'#ffffff'});that.showLargeLabel(l_id,false)},'mousedown(.b,.h)':function(e,el){var l_id=this.get('id').substr(7);var win_opened=null;var dest_win=null;if(this.get('id').substr(7,1)=='h'){dest_win=that.baseHrefHotels+$(l_id).retrieve('properties').href+'&languageCode='+(that.options.lang=='zh'?'CS':that.options.lang.toUpperCase())}else{dest_win=that.baseHrefBB+$(l_id).retrieve('properties').href+'.htm'}win_opened=window.open(dest_win);if(!win_opened||!win_opened.top){$('modal_container').getElements('div')[0].innerHTML='<p style="font-size:1.1em;">'+that.options.msg_popup_blocked.sprintf([dest_win])+'</p>';toggleModal("#555",{zIndex:1000,events:{click:function(){$('modal_container').setStyle('display','none');$("modal").fade(0);(function(){toggleModal()}).delay(500)}}});$('modal_container').setStyle('display','')}}});this.options.mapMoveEndWait=origTimer;if(this.options.start_query!=''){this.geocode(this.options.start_query);this.options.start_query=''}},geocode:function(address){this.geoCoder.getLocations(address,function(result){if(result.Status.code==G_GEO_SUCCESS){if(result.Placemark.length>1){arResults=new Array();for(var i=0;i<result.Placemark.length;i++){var t=result.Placemark[i];arResults.push({'text':t.address,'params':t})}if(!$chk(this.mGeoSuggest)){this.mGeoSuggest=new mSuggest({InputBox:$('searchFormAdress'),SuggestArray:arResults,EffectDuration:500,SuggestItem:1,callback:function(params){var p=params.Point.coordinates;this.map_obj.setCenter(new GLatLng(p[1],p[0]),(params.AddressDetails.Accuracy<8?params.AddressDetails.Accuracy+7:params.AddressDetails.Accuracy))}.bind(this)});this.mGeoSuggest.ShowSuggestions()}else{this.mGeoSuggest.EmptySuggestions();this.mGeoSuggest.ResetCursor();this.mGeoSuggest.AddSuggestions(arResults);this.mGeoSuggest.ShowSuggestions()}}else{var p=result.Placemark[0].Point.coordinates;this.map_obj.setCenter(new GLatLng(p[1],p[0]),(result.Placemark[0].AddressDetails.Accuracy<8?result.Placemark[0].AddressDetails.Accuracy+7:result.Placemark[0].AddressDetails.Accuracy))}}else{alert(this.options.msg_no_geocode)}}.bind(this))},showSmallLabel:function(latlng,msg,icon){if(msg==''){$('smallLabelContainer').setStyle('display','none')}else{if($('smallLabelContainer').getStyle('display')!=""){$('smallLabelContainer').set('text',msg);var point=this.map_obj.getCurrentMapType().getProjection().fromLatLngToPixel(this.map_obj.getBounds().getSouthWest(),this.map_obj.getZoom());var offset=this.map_obj.getCurrentMapType().getProjection().fromLatLngToPixel(latlng,this.map_obj.getZoom());var pos=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(offset.x-point.x-icon.iconAnchor.x,point.y-offset.y+icon.iconAnchor.y));pos.apply($('smallLabelContainer'));$('smallLabelContainer').setStyle('display','')}}},showLargeLabel:function(id_el,show){if(show){if($('largeLabelContainer').getStyle('display')!=""){var in_html="";if(id_el.substr(0,1)=='b'){in_html+='<img src="http://www.bbdormire.com/img/beb/'+($(id_el).retrieve('properties').thumb=='0'?'default.gif':id_el.substr(2)+'/th.gif')+'" />'}else if($(id_el).retrieve('properties').thumb!=''){in_html+='<img src="http://media.hot'+'elscomb'+'ined.com/HT'+$(id_el).retrieve('properties').thumb+'.jpg" />'}in_html+=$(id_el).retrieve('properties').descrizione;$('largeLabelDiv').set('html',in_html+'&hellip;');$('largeLabelTitle').set('html',$(id_el).get('html'));var marker=$(id_el).retrieve('marker');var point=this.map_obj.getCurrentMapType().getProjection().fromLatLngToPixel(this.map_obj.getBounds().getSouthWest(),this.map_obj.getZoom());var offset=this.map_obj.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),this.map_obj.getZoom());var icon=marker.getIcon();var pos=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(offset.x-point.x-icon.iconAnchor.x+icon.iconSize.width,point.y-offset.y));pos.apply($('largeLabelContainer'));$('largeLabelContainer').setStyle('display','');if($('largeLabelContainer').getCoordinates().right>window.getCoordinates().right-10){$('largeLabelContainer').setStyle('left',$('largeLabelContainer').getStyle('left').toInt()-$('largeLabelContainer').getStyle('width').toInt()-icon.iconSize.width)}if($('largeLabelContainer').getCoordinates().top<$(this.mapContainer).getCoordinates().top+10){$('largeLabelContainer').setStyle('bottom',$('largeLabelContainer').getStyle('bottom').toInt()-$('largeLabelContainer').getStyle('height').toInt()-icon.iconSize.height)}this.curSelectedMarker=marker;marker.triggerHighlight()}}else{$('largeLabelContainer').setStyle('display','none');if(this.curSelectedMarker!=null)this.curSelectedMarker.triggerHighlight();this.curSelectedMarker=null}},createCluster:function(rowdata,minP,maxP){rowdata[3]=parseInt(rowdata[3]);var text=rowdata[4]+" ("+rowdata[3]+")";var point=new GLatLng(rowdata[1],rowdata[2]);var size=0;if(rowdata[3]>=maxP){size=this.options.maxClusterIconSize}else if(rowdata[3]<=minP){size=this.options.minClusterIconSize}else{size=parseInt(((this.options.maxClusterIconSize-this.options.minClusterIconSize)/(maxP-minP))*(rowdata[3]-minP)+this.options.minClusterIconSize)}var roundIcon=MapIconMaker.createFlatIcon({width:size,height:size,label:String(rowdata[3]),labelColor:"#ffffff",primaryColor:"#003cff",shape:"roundrect"});var marker=new MarkerLight(point,{'icon':roundIcon,'mouseover':function(){this.showSmallLabel(point,text,roundIcon)}.bind(this),'mouseout':function(){this.showSmallLabel(point,'')}.bind(this),'click':function(){this.map_obj.setCenter(point,this.options.zoomTriggerLevel+2)}.bind(this)});return marker},addToList:function(pointData){if(pointData=="")return;pointData=pointData.split("|");var li_id=pointData[0]+'_'+pointData[1];if($(li_id))return;var marker=new MarkerLight(new GLatLng(pointData[2],pointData[3]),{'classe':pointData[0],'icon':(pointData[0]=='h'?this.icons[0]:this.icons[1]),'id':'marker_'+pointData[0]+'_'+pointData[1],'imageOver':'/img/mapicons/'+(pointData[0]=='h'?'lodging_c_hover.png':'beb_c_hover.png')});this.map_obj.addOverlay(marker);var e_t="";if(pointData[0]=='h'&&pointData[7]!='')for(i=0;i<parseInt(pointData[7]);i++)e_t+="*";new Element('li',{'id':li_id,'class':'ob','html':pointData[4]+(pointData[0]=='h'?' '+e_t:'')}).store('marker',marker).store('properties',{descrizione:pointData[5],classe:(pointData[0]=='h'?'hotel':'beb'),'href':pointData[6],'thumb':(pointData[0]=='h'?pointData[8]:pointData[7])}).injectInside($(this.listContainer));if(pointData[0]=='h'){this.numHotels++}else if(pointData[0]=='b'){this.numBBs++}},purgeList:function(clean){if(this.map_obj.getZoom()<=this.options.zoomTriggerLevel||clean==true){$(this.listContainer).getElements('li.ob').each(function(el){this.map_obj.removeOverlay(el.retrieve('marker'));el.store('marker','').store('description','');el.dispose()}.bind(this));this.numHotels=0;this.numBBs=0;this.left_default_msg.setStyle('display','');if(clean){$('reqForm').neLat1.set('value','');$('reqForm').neLng1.set('value','');$('reqForm').swLat1.set('value','');$('reqForm').swLng1.set('value','');$('reqForm').z1.set('value','')}}else{this.left_default_msg.setStyle('display','none');var mapbounds=this.map_obj.getBounds();$(this.listContainer).getElements('li.ob').each(function(el){var marker=el.retrieve('marker');if(!mapbounds.containsLatLng(marker.getPoint())){this.map_obj.removeOverlay(marker);if(el.retrieve('properties').classe=="hotel"){this.numHotels--}else if(el.retrieve('properties').classe=="beb"){this.numBBs--}el.store('marker','').store('description','');el.dispose()}}.bind(this))}}});var Watermark_form=new Class({Implements:[Options],options:{color:'#aeaeae',collection:$$('input[type=text]')},initialize:function(options){this.setOptions(options);var cl=this.options.color;this.options.collection.each(function(el){el.store('original_color',el.getStyle('color'));el.set('value',el.get('alt'));el.setStyle('color',cl);el.addEvent('focus',function(){if(el.get('value')==el.get('alt')){el.set('value','');el.setStyle('color',el.retrieve('original_color'))}});el.addEvent('blur',function(){if(el.get('value')==''){el.set('value',el.get('alt'));el.setStyle('color',cl)}})})}});var mSuggest=new Class({Implements:[Options,Events],options:{InputBox:false,SuggestArray:[],callback:function(){return},EffectDuration:500},initialize:function(options){this.setOptions(options);this.InputBox=this.options.InputBox;this.InputBoxProperties=[];this.ToggleFX=null;this.timerClose=null;this.ListPos=null;this.ChosenItem=null;this.isClosing=false;this.CreateSuggestionBox();this.AddSuggestions(this.options.SuggestArray);this.InputBox.set('autosuggest',false);this.AddInputEvents()},AddSuggestions:function(suggestions){var i=1;suggestions.each(function(suggestion){this.InjectItem(suggestion,i);i++}.bind(this))},CreateSuggestionBox:function(){var parCoord=this.InputBox.getCoordinates();new Element('div',{'class':'suggestions',id:'geoSuggestionsConatiner',styles:{'display':'block','opacity':'0','width':(parCoord['width']-2),'top':(parCoord['top']+parCoord['height']+12),'left':(parCoord['left']+2)},events:{'mouseenter':function(){$clear(this.timerClose)}.bind(this),'mouseleave':function(){this.BeginFade()}.bind(this)}}).injectInside(document.body);this.ToggleFX=new Fx.Morph($('geoSuggestionsConatiner'),{duration:this.options.EffectDuration})},AddInputEvents:function(){this.InputBox.addEvents({'keyup':function(event){event=new Event(event);if(event.key=="up"){if(this.options.SuggestArray.length>0)this.TraverseList(1)}else if(event.key=="down"){if(this.options.SuggestArray.length>0)this.TraverseList(-1)}else if(event.key=="enter"){if(this.options.SuggestArray.length>0&&this.ChosenItem!=null){this.SelectItem(this.ChosenItem)}event.stop()}else{this.ListPos=null}}.bind(this),'mouseenter':function(){$clear(this.timerClose)}.bind(this),'mouseleave':function(){if($('geoSuggestionsConatiner').getStyle('opacity')=="1")this.BeginFade()}.bind(this)})},HighlightItem:function(){if($('s'+this.ListPos))this.ChosenItem=this.options.SuggestArray[this.ListPos]},TraverseList:function(direction){var countdir=-1;if(direction>0)countdir=1;if(this.ListPos==null){this.ListPos=0}else{this.ListPos=this.ListPos+countdir}if(this.ListPos<0){this.ListPos=(this.options.SuggestArray.length-1)}this.HighlightItem()},ResetCursor:function(){this.ListPos=0;this.ChosenItem=null},InjectItem:function(item,index){new Element('div',{id:('s'+index),'class':'suggestionentry','text':item.text,events:{'mouseenter':function(){this.addClass('suggestionentry_mouseover')},'mouseleave':function(){this.removeClass('suggestionentry_mouseover')}}}).injectInside($('geoSuggestionsConatiner'));$('s'+index).addEvent('click',function(){this.SelectItem(item)}.bind(this))},SelectItem:function(item){this.InputBox.value=item.text;this.options.callback(item.params);this.HideSuggestions()},DoFade:function(){$clear(this.timerClose);this.HideSuggestions()},BeginFade:function(){if(!this.isClosing)this.timerClose=this.DoFade.bind(this).delay(1000)},CloseSuggestions:function(){this.ToggleFX.set({'opacity':0})},HideSuggestions:function(){this.ListPos=null;this.isClosing=true;this.ToggleFX.start({'opacity':[1,0]})},ShowSuggestions:function(){this.isClosing=false;this.ToggleFX.start({'opacity':[0,1]})},EmptySuggestions:function(){$('geoSuggestionsConatiner').getElements('div').each(function(el){el.dispose()})}});function MarkerLight(latlng,opts){this.latlng=latlng;if(!opts)opts={};this.isHighlighted=false;this.height_=opts.icon.iconSize.height||32;this.width_=opts.icon.iconSize.width||32;this.image_=opts.icon.image||"";this.anchorX_=opts.icon.iconAnchor.x||0;this.anchorY_=opts.icon.iconAnchor.y||0;this.imageOver_=opts.imageOver||"";this.clicked_=0;this.class_=opts.classe||"";this.id_=opts.id||"";this.mouseOverCallback=opts.mouseover||null;this.mouseOutCallback=opts.mouseout||null;this.mouseClick=opts.click||null};MarkerLight.prototype=new GOverlay();MarkerLight.prototype.initialize=function(map){if(Browser.Engine.trident4){var div=new Element('div',{'class':this.class_,'styles':{position:'absolute',cursor:'pointer',width:this.width_,height:this.height_}});new Element('span',{'styles':{width:this.width_,height:this.height_,display:'inline-block','filter':'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', src=\''+this.image_+'\', sizingMethod=\'scale\')'}}).injectInside(div)}else{var div=new Element('div',{'styles':{position:'absolute',cursor:'pointer',background:'transparent url("'+this.image_+'") 0pt 0pt no-repeat',width:this.width_,height:this.height_}})}if(this.id_!='')div.set('id',this.id_);if(this.class_!='')div.set('class',this.class_);if(this.mouseOverCallback)div.addEvent('mouseover',function(e){this.mouseOverCallback();e.stop()}.bind(this));if(this.mouseOutCallback)div.addEvent('mouseout',function(e){this.mouseOutCallback();e.stop()}.bind(this));if(this.mouseClick)div.addEvent('click',this.mouseClick);map.getPane(G_MAP_MARKER_PANE).appendChild(div);this.map_=map;this.div_=div};MarkerLight.prototype.getIcon=function(){var icon=new GIcon();icon.image=this.image_;icon.iconSize=new GSize(this.width_,this.height_);icon.iconAnchor=new GPoint(this.anchorX_,this.anchorY_);return icon};MarkerLight.prototype.remove=function(){this.div_.dispose()};MarkerLight.prototype.copy=function(){return new MarkerLight(this.latlng,{'imageOver':this.imageOver,'icon':this.getIcon()})};MarkerLight.prototype.redraw=function(force){if(!force)return;var divPixel=this.map_.fromLatLngToDivPixel(this.latlng);this.div_.setStyles({width:this.width_,height:this.height_,left:(divPixel.x-this.anchorX_),top:(divPixel.y-this.anchorY_)})};MarkerLight.prototype.bringToFront_=function(){this.div_.style.zIndex=1e9};MarkerLight.prototype.sendBack_=function(){this.div_.style.zIndex=GOverlay.getZIndex(this.latlng.lat())};MarkerLight.prototype.triggerHighlight=function(){if(this.isHighlighted){this.isHighlighted=false;this.setImage(this.image_);this.sendBack_()}else{this.isHighlighted=true;this.setImage(this.imageOver_);this.bringToFront_()}};MarkerLight.prototype.getPoint=function(){return this.latlng};MarkerLight.prototype.setImage=function(image){if(image==null||image=="")return;if(Browser.Engine.trident4){this.div_.childNodes[0].setStyle('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', src=\''+this.image_+'\', sizingMethod=\'scale\')')}else{this.div_.setStyle('background','url("'+image+'")')}};var MapIconMaker={};MapIconMaker.createMarkerIcon=function(opts){var width=opts.width||32;var height=opts.height||32;var primaryColor=opts.primaryColor||"#ff0000";var strokeColor=opts.strokeColor||"#000000";var cornerColor=opts.cornerColor||"#ffffff";var baseUrl="http://chart.apis.google.com/chart?cht=mm";var iconUrl=baseUrl+"&chs="+width+"x"+height+"&chco="+cornerColor.replace("#","")+","+primaryColor.replace("#","")+","+strokeColor.replace("#","")+"&ext=.png";var icon=new GIcon(G_DEFAULT_ICON);icon.image=iconUrl;icon.iconSize=new GSize(width,height);icon.shadowSize=new GSize(Math.floor(width*1.6),height);icon.iconAnchor=new GPoint(width/2,height);icon.imageMap=[width/2,height,(7/16)*width,(5/8)*height,(5/16)*width,(7/16)*height,(7/32)*width,(5/16)*height,(5/16)*width,(1/8)*height,(1/2)*width,0,(11/16)*width,(1/8)*height,(25/32)*width,(5/16)*height,(11/16)*width,(7/16)*height,(9/16)*width,(5/8)*height];for(var i=0;i<icon.imageMap.length;i++){icon.imageMap[i]=parseInt(icon.imageMap[i])}return icon};MapIconMaker.createFlatIcon=function(opts){var width=opts.width||32;var height=opts.height||32;var primaryColor=opts.primaryColor||"#ff0000";var shadowColor=opts.shadowColor||"#000000";var label=MapIconMaker.escapeUserText_(opts.label)||"";var labelColor=opts.labelColor||"#000000";var labelSize=opts.labelSize||0;var shape=opts.shape||"circle";var shapeCode=(shape==="circle")?"it":"itr";var baseUrl="http://chart.apis.google.com/chart?cht="+shapeCode;var iconUrl=baseUrl+"&chs="+width+"x"+height+"&chco="+primaryColor.replace("#","")+","+shadowColor.replace("#","")+"ff,ffffff01"+"&chl="+label+"&chx="+labelColor.replace("#","")+","+labelSize;var icon=new GIcon(G_DEFAULT_ICON);icon.image=iconUrl+"&chf=bg,s,00000000"+"&ext=.png";icon.iconSize=new GSize(width,height);icon.iconAnchor=new GPoint(width/2,height/2);icon.imageMap=[];if(shapeCode==="itr"){icon.imageMap=[0,0,width,0,width,height,0,height]}else{var polyNumSides=8;var polySideLength=360/polyNumSides;var polyRadius=Math.min(width,height)/2;for(var a=0;a<(polyNumSides+1);a++){var aRad=polySideLength*a*(Math.PI/180);var pixelX=polyRadius+polyRadius*Math.cos(aRad);var pixelY=polyRadius+polyRadius*Math.sin(aRad);icon.imageMap.push(parseInt(pixelX),parseInt(pixelY))}}return icon};MapIconMaker.createLabeledMarkerIcon=function(opts){var primaryColor=opts.primaryColor||"#DA7187";var strokeColor=opts.strokeColor||"#000000";var starPrimaryColor=opts.starPrimaryColor||"#FFFF00";var starStrokeColor=opts.starStrokeColor||"#0000FF";var label=MapIconMaker.escapeUserText_(opts.label)||"";var labelColor=opts.labelColor||"#000000";var addStar=opts.addStar||false;var pinProgram=(addStar)?"pin_star":"pin";var baseUrl="http://chart.apis.google.com/chart?cht=d&chdp=mapsapi&chl=";var iconUrl=baseUrl+pinProgram+"'i\\"+"'["+label+"'-2'f\\"+"hv'a\\]"+"h\\]o\\"+primaryColor.replace("#","")+"'fC\\"+labelColor.replace("#","")+"'tC\\"+strokeColor.replace("#","")+"'eC\\";if(addStar){iconUrl+=starPrimaryColor.replace("#","")+"'1C\\"+starStrokeColor.replace("#","")+"'0C\\"}iconUrl+="Lauto'f\\";var icon=new GIcon(G_DEFAULT_ICON);icon.image=iconUrl+"&ext=.png";icon.iconSize=(addStar)?new GSize(23,39):new GSize(21,34);return icon};MapIconMaker.escapeUserText_=function(text){if(text===undefined){return null}text=text.replace(/@/,"@@");text=text.replace(/\\/,"@\\");text=text.replace(/'/,"@'");text=text.replace(/\[/,"@[");text=text.replace(/\]/,"@]");return encodeURIComponent(text)};Element.implement({flash:function(to,from,reps,prop,dur){if(!reps){reps=1}if(!prop){prop='background-color'}if(!dur){dur=250}this.get('tween').cancel();var effect=new Fx.Tween(this,{duration:dur,link:'chain'});for(x=1;x<=reps;x++){effect.start(prop,from,to).start(prop,to,from)}}});String.implement({sprintf:function(args){str=this;var re=/([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;var a=b=[],numSubstitutions=0,numMatches=0;while(a=re.exec(str)){var leftpart=a[1],pPad=a[2],pJustify=a[3],pMinLength=a[4];var pPrecision=a[5],pType=a[6],rightPart=a[7];numMatches++;if(pType=='%'){subst='%'}else{if(numSubstitutions>=args.length){if(console){console.log('Error! Not enough function args ('+(args.length-1)+', excluding the string)\nfor the number of substitution parameters in string ('+numSubstitutions+' so far).')}}var param=args[numSubstitutions];var pad='';if(pPad&&pPad.substr(0,1)=="'")pad=leftpart.substr(1,1);else if(pPad)pad=pPad;var justifyRight=true;if(pJustify&&pJustify==="-")justifyRight=false;var minLength=-1;if(pMinLength)minLength=parseInt(pMinLength);var precision=-1;if(pPrecision&&pType=='f')precision=parseInt(pPrecision.substring(1));var subst=param;if(pType=='b')subst=parseInt(param).toString(2);else if(pType=='c')subst=String.fromCharCode(parseInt(param));else if(pType=='d')subst=parseInt(param)?parseInt(param):0;else if(pType=='u')subst=Math.abs(param);else if(pType=='f')subst=(precision>-1)?Math.round(parseFloat(param)*Math.pow(10,precision))/Math.pow(10,precision):parseFloat(param);else if(pType=='o')subst=parseInt(param).toString(8);else if(pType=='s')subst=param;else if(pType=='x')subst=(''+parseInt(param).toString(16)).toLowerCase();else if(pType=='X')subst=(''+parseInt(param).toString(16)).toUpperCase();numSubstitutions++}str=leftpart+subst+rightPart}return str}});

