
PP.Mapping=new function(){this.maps=[];this.addMap=function(map){this.maps[this.maps.length]=map;}
this.getMap=function(name){for(var m=0;m<this.maps.length;m++){if(this.maps[m].name==name)
return this.maps[m];}
return null;}
this.checkResizeMaps=function(){for(var i=0;i<this.maps.length;i++){this.maps[i].checkResize();}}
this.closeInfoWindows=function(){for(var i=0;i<this.maps.length;i++){this.maps[i].infoWindowControl.hide();}}
this.openInfoWindow=function(lpr){for(var i=0;i<this.maps.length;i++){this.maps[i].stackedPickerControl.openInfoWindow(lpr);}}
this.closeStackedPickers=function(){for(var i=0;i<this.maps.length;i++){this.maps[i].stackedPickerControl.hide();}}
this.toggleStreetviewBtns=function(lat,lng){var svc=new GStreetviewClient();this.tsvblat=lat;this.tsvblng=lng;svc.getNearestPanorama(new GLatLng(lat,lng),function(svd){if(svd==null||svd.location==null){if(onnostreetview){onnostreetview();}
return;}
var loc=svd.location;if((3958*3.1415926*Math.sqrt(Math.pow(loc.latlng.lat()-(PP.Mapping.tsvblat),2)
+Math.cos(loc.latlng.lat()/57.29578)*Math.cos((PP.Mapping.tsvblat)/57.29578)*Math.pow(loc.latlng.lng()-(PP.Mapping.tsvblng),2))/180)>0.2){if(onnostreetview){onnostreetview();}
return;}
var links=document.getElementsByTagName('a');for(i=0;i<links.length;i++){if(PP.Util.hasClass(links[i],'streetviewBtn')){links[i].style.display='';}}
var divs=document.getElementsByTagName('div');for(i=0;i<divs.length;i++){if(PP.Util.hasClass(divs[i],'streetviewBtn')){divs[i].style.display='';}}});}
this.Map=function(e,opts){this.name=e;this.savedLocations=[];this.savedLocations['uk']=[54.559323,-3.823242,5];this.savedLocations['home']=this.savedLocations['uk'];this.gotoLocation=function(name){var location=this.savedLocations[name];if(location){this.googleMap.setCenter(new GLatLng(location[0],location[1]),location[2]);this.googleMap.savePosition();}}
this.centerOnBounds=function(n,s,w,e){var bounds=new GLatLngBounds(new GLatLng(s,w),new GLatLng(n,e));var zoom=this.googleMap.getBoundsZoomLevel(bounds);var prj=this.googleMap.getCurrentMapType().getProjection();var indent=prj.fromPixelToLatLng(new GPoint(250,250),zoom);var topLeft=prj.fromPixelToLatLng(new GPoint(0,0),zoom);var latLngIndent=topLeft.lat()-indent.lat();var bounds=new GLatLngBounds(new GLatLng(s,w),new GLatLng(n+latLngIndent,e));this.googleMap.setCenter(bounds.getCenter(),this.googleMap.getBoundsZoomLevel(bounds));this.googleMap.savePosition();}
this.centerMap=function(bounds){var bleed=Math.pow(2,17-this.googleMap.getZoom())/150000;var newBounds=new GLatLngBounds(new GLatLng(bounds.getSouthWest().lat()-bleed,bounds.getSouthWest().lng()-bleed),new GLatLng(bounds.getNorthEast().lat()+bleed,bounds.getNorthEast().lng()+bleed));this.googleMap.setCenter(newBounds.getCenter(),this.googleMap.getBoundsZoomLevel(newBounds));}
this.setSearchPath=function(path,qs,controller){this.searchPath=path;this.searchQS=new PP.Ajax.QueryString(qs);this.controller=controller;this.removeCircle();this.loadVisible();}
this.markers=[];this.bounds=new GLatLngBounds();this.removeMarkers=function(){if(this.infoWindowControl)
this.infoWindowControl.hide();for(i=0;i<this.markers.length;i++)
this.googleMap.removeOverlay(this.markers[i]);this.markers=[];this.search=null;this.bounds=new GLatLngBounds();}
this.hideMarkers=function(){for(i=0;i<this.markers.length;i++)
this.googleMap.removeOverlay(this.markers[i]);}
this.showMarkers=function(){for(i=0;i<this.markers.length;i++)
this.googleMap.addOverlay(this.markers[i]);}
this.addMarker=function(lat,lng,label,id,count,icon){var marker=new GMarker(new GLatLng(lat,lng),(icon?icon:this.singleIcon));marker.label=label;marker.id=id;if(count==1&&this.infoWindowControl){this.infoWindowControl.handleMarker(marker);}
this.markers[this.markers.length]=marker;if(this.tooltipControl)
this.tooltipControl.handleMarker(marker);this.googleMap.addOverlay(marker);this.bounds.extend(marker.getPoint());return marker;}
this.clusteringSuspended=false;this.loadVisRequestNum=0;this.loadVisible=function(){if((this.searchPath||this.searchQS)&&!this.clusteringSuspended){this.loadingControl.show();var b=this.googleMap.getBounds();var ln=b.getNorthEast().lat();var ls=b.getSouthWest().lat();var le=b.getNorthEast().lng();var lw=b.getSouthWest().lng();if(lw>0&&le>0&&lw>le){lw=-180;}
if(lw<0&&le<0&&lw>le){le=180;}
this.searchQS.setValue('sp',this.searchPath);this.searchQS.setValue('sc',this.controller);this.searchQS.setValue('north',ln);this.searchQS.setValue('south',ls);this.searchQS.setValue('east',le);this.searchQS.setValue('west',lw);this.searchQS.setValue('zoom',this.googleMap.getZoom());var url=PP.resolveUrl('~/data/map?'+this.searchQS.toString());this.removeMarkers();var request=GXmlHttp.create();request.open("GET",url,true);var reqNum=++this.loadVisRequestNum;request.onreadystatechange=PP.Util.createClosure(this,function(reqNum){if(request.readyState==4&&reqNum==this.loadVisRequestNum){var clusters=eval('('+request.responseText+')');if(clusters.length==0){this.loadingControl.hide();}
for(var i=0;i<clusters.length;i++){var lat=parseFloat(clusters[i].lat);var lng=parseFloat(clusters[i].lng);var marker=this.addMarker(lat,lng,clusters[i].lbl,clusters[i].id,clusters[i].size,(clusters[i].size>1?this.multiIcon:this.singleIcon));if(clusters[i].size>1){GEvent.addListener(marker,'click',PP.Util.createClosure(this,function(n,s,e,w,marker){var bounds=new GLatLngBounds(new GLatLng(s,w),new GLatLng(n,e));var zoom=this.googleMap.getBoundsZoomLevel(bounds);if(zoom!=this.googleMap.getZoom())
this.centerMap(bounds);else
this.stackedPickerControl.onClick(marker);},clusters[i].n,clusters[i].s,clusters[i].e,clusters[i].w,marker));}}}},reqNum);request.send(null);}}
this.removeCircle=function(){if(this.circle){this.googleMap.removeOverlay(this.circle);this.circle=null;}}
this.drawCircle=function(center,radius,liColor,liWidth,liOpa,fillColor,fillOpa){this.removeCircle();var latConv=center.distanceFrom(new GLatLng(center.lat()+0.1,center.lng()))/100;var lngConv=center.distanceFrom(new GLatLng(center.lat(),center.lng()+0.1))/100;radius=radius*1.609344;var points=[];var step=5;for(var i=0;i<=360;i+=step){var pint=new GLatLng(center.lat()+(radius/latConv*Math.cos(i*Math.PI/180)),center.lng()+
(radius/lngConv*Math.sin(i*Math.PI/180)));points.push(pint);}
fillColor=fillColor||liColor||"#0055ff";fillOpa=fillOpa||0;liWidth=liWidth||5;this.circle=new GPolygon(points,liColor,liWidth,liOpa,fillColor,fillOpa);this.googleMap.addOverlay(this.circle);}
this.checkResize=function(){this.googleMap.checkResize();this.googleMap.setCenter(this.savedCenter,this.savedZoom);}
this.message=function(msg){this.messagePaneControl.show(msg);}
this.initStreetview=function(lat,lng,createpc,showpc){var svc=new GStreetviewClient();var map=this;map.svlat=lat;map.svlng=lng;svc.getNearestPanorama(new GLatLng(lat,lng),function(svd){if(svd==null||svd.location==null)
return;var loc=svd.location;if((3958*3.1415926*Math.sqrt(Math.pow(loc.latlng.lat()-(map.svlat),2)
+Math.cos(loc.latlng.lat()/57.29578)*Math.cos((map.svlat)/57.29578)*Math.pow(loc.latlng.lng()-(this.svlng),2))/180)>0.2){return;}
if(createpc){var node=document.createElement("div");node.id='_emMapStreetview';var wrapper=PP.getElementById('_emMapWrapper_'+e);wrapper.appendChild(node);node.style.position='absolute';node.style.width=PP.Util.getElementWidth(wrapper)+'px';node.style.height=PP.Util.getElementHeight(wrapper)+'px';node.style.top='0px';node.style.left='0px';if(!showpc)
node.style.display='none';var gsvp=new GStreetviewPanorama(node);gsvp.setLocationAndPOV(svd.location.latlng,svd.location.pov);}});}
this.initStreetviewOverlay=function(){this.streetviewOverlay=new GStreetviewOverlay();this.googleMap.addOverlay(this.streetviewOverlay);}
var wrapper=PP.getElementById('_emMapWrapper_'+e);this.singleIcon=new GIcon();this.singleIcon.image=opts.markersDir+'/Single.png';this.singleIcon.shadow=opts.markersDir+'/ShadowSingle.png';this.singleIcon.iconSize=new GSize(27,34);this.singleIcon.shadowSize=new GSize(45,34);this.singleIcon.iconAnchor=new GPoint(16,32);this.singleIcon.infoWindowAnchor=new GPoint(13,2);this.singleIcon.transparent=opts.markersDir+'/TransparentSingle.png';this.multiIcon=new GIcon();this.multiIcon.image=opts.markersDir+'/Multi.png';this.multiIcon.shadow=opts.markersDir+'/ShadowMulti.png';this.multiIcon.iconSize=new GSize(29,34);this.multiIcon.shadowSize=new GSize(44,34);this.multiIcon.iconAnchor=new GPoint(15,32);this.multiIcon.infoWindowAnchor=new GPoint(13,2);this.multiIcon.transparent=opts.markersDir+'/TransparentMulti.png';this.opts=opts;if(!opts.nomap){this.googleMap=new GMap2(PP.getElementById('_emMap_'+e),{size:new GSize(opts.size.width,opts.size.height)});this.googleMap.disableContinuousZoom();this.zoomControl=new PP.Mapping.ZoomControl(this);this.mapTypeControl=new GMapTypeControl();if(opts.largeZoom)
this.positionControl=new GLargeMapControl();else
this.positionControl=new GSmallMapControl();this.loadingControl=new PP.Mapping.LoadingControl(this);this.googleMap.addControl(this.loadingControl);this.tooltipControl=new PP.Mapping.TooltipControl(this);this.googleMap.addControl(this.tooltipControl);this.infoWindowControl=new PP.Mapping.InfoWindowControl(this);this.googleMap.addControl(this.infoWindowControl);this.stackedPickerControl=new PP.Mapping.StackedPickerControl(this);this.googleMap.addControl(this.stackedPickerControl);this.messagePaneControl=new PP.Mapping.MessagePaneControl(this);this.googleMap.addControl(this.messagePaneControl);this.loadingControl.hide();this.gotoLocation('uk');GEvent.addListener(this.googleMap,'moveend',PP.Util.createClosure(this,function(){this.loadVisible();this.savedCenter=this.googleMap.getCenter();this.savedZoom=this.googleMap.getZoom();},true));GEvent.addListener(this.googleMap,'addoverlay',PP.Util.createClosure(this,function(){if(this.loadingControl)
this.loadingControl.hide();},true));GEvent.addListener(this.googleMap,'mouseover',PP.Util.createClosure(this,function(){this.googleMap.addControl(this.mapTypeControl);this.googleMap.addControl(this.positionControl);},true));GEvent.addListener(this.googleMap,'mouseout',PP.Util.createClosure(this,function(){this.googleMap.removeControl(this.mapTypeControl);this.googleMap.removeControl(this.positionControl);},true));}
GEvent.addDomListener(window,'unload',GUnload);}
this.TypeControl=function(){this.btnNormal_click=function(){this.map.setMapType(G_NORMAL_MAP);PP.Util.removeClass(this.btnHybrid,'active');PP.Util.removeClass(this.btnSatellite,'active');PP.Util.addClass(this.btnNormal,'active');this.btnRoadView.style.display='none';this.btnSatView.style.display='block';this.btnHybView.style.display='block';this.active.innerHTML='Road View';}
this.btnSatellite_click=function(){this.map.setMapType(G_SATELLITE_MAP);PP.Util.removeClass(this.btnHybrid,'active');PP.Util.removeClass(this.btnNormal,'active');PP.Util.addClass(this.btnSatellite,'active');this.btnRoadView.style.display='block';this.btnSatView.style.display='none';this.btnHybView.style.display='block';this.active.innerHTML='Satellite View';}
this.btnHybrid_click=function(){this.map.setMapType(G_HYBRID_MAP);PP.Util.removeClass(this.btnSatellite,'active');PP.Util.removeClass(this.btnNormal,'active');PP.Util.addClass(this.btnHybrid,'active');this.btnRoadView.style.display='block';this.btnSatView.style.display='block';this.btnHybView.style.display='none';this.active.innerHTML='Hybrid View';}
this.over=function(div){PP.Util.addClass(div,'xMAP_type_option_over');}
this.out=function(div){PP.Util.removeClass(div,'xMAP_type_option_over');}}
this.TypeControl.prototype=new GControl();this.TypeControl.prototype.initialize=function(map){this.map=map;this.container=document.createElement("div");this.container.className='xMAP_type';var active=document.createElement("div");this.active=active;this.active.className='xMAP_type_active';this.container.appendChild(active);active.style.width='85px';active.innerHTML='Road View';var all=document.createElement("div");all.className='xMAP_type_all'
this.container.appendChild(all);PP.Util.attachEvent(this.container,'click',PP.Util.createClosure(this,function(){if(!PP.Util.hasClass(this.container,'xMAP_type_open')){PP.Util.addClass(this.container,'xMAP_type_open');}
else{PP.Util.removeClass(this.container,'xMAP_type_open');}}));PP.Util.attachEvent(document.body,'click',PP.Util.createClosure(this,function(){if(PP.Util.hasClass(this.container,'xMAP_type_open')){PP.Util.removeClass(this.container,'xMAP_type_open');}}));this.btnRoadView=document.createElement('div');this.btnRoadView.innerHTML='Road View';this.btnRoadView.className='xMAP_type_option'
this.btnRoadView.style.display='none';all.appendChild(this.btnRoadView);PP.Util.attachEvent(this.btnRoadView,'click',PP.Util.createClosure(this,this.btnNormal_click));PP.Util.attachEvent(this.btnRoadView,'mouseover',PP.Util.createClosure(this,this.over,this.btnRoadView));PP.Util.attachEvent(this.btnRoadView,'mouseout',PP.Util.createClosure(this,this.out,this.btnRoadView));this.btnSatView=document.createElement('div');this.btnSatView.innerHTML='Sattelite View';this.btnSatView.className='xMAP_type_option'
all.appendChild(this.btnSatView);PP.Util.attachEvent(this.btnSatView,'click',PP.Util.createClosure(this,this.btnSatellite_click));PP.Util.attachEvent(this.btnSatView,'mouseover',PP.Util.createClosure(this,this.over,this.btnSatView));PP.Util.attachEvent(this.btnSatView,'mouseout',PP.Util.createClosure(this,this.out,this.btnSatView));this.btnHybView=document.createElement('div');this.btnHybView.innerHTML='Hybrid View';this.btnHybView.className='xMAP_type_option'
all.appendChild(this.btnHybView);PP.Util.attachEvent(this.btnHybView,'click',PP.Util.createClosure(this,this.btnHybrid_click));PP.Util.attachEvent(this.btnHybView,'mouseover',PP.Util.createClosure(this,this.over,this.btnHybView));PP.Util.attachEvent(this.btnHybView,'mouseout',PP.Util.createClosure(this,this.out,this.btnHybView));map.getContainer().appendChild(this.container);return this.container;}
this.TypeControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(0,0));}
this.ZoomControl=function(emMap){this.emMap=emMap;this.enabled=true;this.setZoom=function(z){if(this.enabled)this.map.setZoom(z);}
this.btnPlus_click=function(){var zoom=this.map.getZoom();this.setZoom(zoom+1);}
this.btnMinus_click=function(){var zoom=this.map.getZoom();this.setZoom(zoom-1);}}
this.ZoomControl.prototype=new GControl();this.ZoomControl.prototype.initialize=function(map){this.map=map;var container=document.createElement("div");container.className='xMAP_zoom';var btnPlus=document.createElement("div");btnPlus.className='xMAP_zoom_plus';btnPlus.title='Zoom in';container.appendChild(btnPlus);var btnMinus=document.createElement("div");btnMinus.className='xMAP_zoom_minus';btnMinus.title='Zoom out';container.appendChild(btnMinus);GEvent.addDomListener(btnMinus,'click',PP.Util.createClosure(this,this.btnMinus_click));GEvent.addDomListener(btnPlus,'click',PP.Util.createClosure(this,this.btnPlus_click));map.getContainer().appendChild(container);return container;}
this.ZoomControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0));}
this.LoadingControl=function(emMap){this.emMap=emMap;this.show=function(){this.container.style.display='block';}
this.hide=function(){this.container.style.display='none';}}
this.LoadingControl.prototype=new GControl();this.LoadingControl.prototype.getDefaultPosition=function(){var mapSize=this.emMap.googleMap.getSize();return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0));}
this.LoadingControl.prototype.initialize=function(map){this.map=map;var mapSize=map.getSize();this.container=document.createElement("div");this.container.className='xMapLoading';this.container.style.width=mapSize.width+'px';this.container.style.height=mapSize.height+'px';this.container.style.textAlign='center';this.container.display='none';map.getContainer().appendChild(this.container);return this.container;}
this.TooltipControl=function(emMap){this.emMap=emMap;this.show=function(marker){this.container.style.display='block';this.container.style.visibility='hidden';this.container.innerHTML=marker.label;this.container.style.width='';var width=PP.Util.getElementWidth(this.container);if(width>150)
this.container.style.width='150px';var point=this.emMap.googleMap.getCurrentMapType().getProjection().fromLatLngToPixel(this.emMap.googleMap.getBounds().getSouthWest(),this.emMap.googleMap.getZoom());var offset=this.emMap.googleMap.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),this.emMap.googleMap.getZoom());var anchor=marker.getIcon().iconAnchor;var width=marker.getIcon().iconSize.width;var pos=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(offset.x-point.x-anchor.x+width-8,-offset.y+point.y+anchor.y-8));pos.apply(this.container);this.container.style.top='';this.container.style.visibility='visible';}
this.hide=function(){this.container.style.display='none';}
this.handleMarker=function(marker){GEvent.addListener(marker,'mouseover',PP.Util.createClosure(this,function(marker){this.show(marker);},marker));GEvent.addListener(marker,'mouseout',PP.Util.createClosure(this,function(){this.hide();}));GEvent.addListener(marker,'click',PP.Util.createClosure(this,function(){this.hide();}));}}
this.TooltipControl.prototype=new GControl();this.TooltipControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0));}
this.TooltipControl.prototype.initialize=function(map){this.map=map;var mapSize=map.getSize();this.container=document.createElement("div");this.container.className='xMapTooltip';this.container.style.position='absolute';this.container.style.display='none';map.getContainer().appendChild(this.container);return this.container;}
this.InfoWindowControl=function(emMap){this.emMap=emMap;this.width=160;this.height=200;this.shown=false;this.show=function(marker,id){this.shown=true;var container=this.emMap.googleMap.getContainer();this.contentDiv=document.createElement('div');this.contentDiv.className='xMAP_infoWindow';this.contentDiv.style.position='absolute';this.contentDiv.style.width='240px';this.contentDiv.style.height='150px';this.contentDiv.style.padding='5px';this.contentDiv.style.top=((this.emMap.googleMap.getSize().height/2)-90)+'px';this.contentDiv.style.left=((this.emMap.googleMap.getSize().width/2)-125)+'px';container.appendChild(this.contentDiv);PP.Ajax.loadElement(PP.resolveUrl('~/~mapinfowindow'+(id?id:marker.id)),'infoWindow',PP.Util.createClosure(this,function(){var links=this.contentDiv.getElementsByTagName('A');for(var i=0;i<links.length;i++){if(PP.Util.hasClass(links[i],'xMAP_closeBtn')){PP.Util.attachEvent(links[i],'click',PP.Util.createClosure(this,function(){this.hide();}));}}}),false,this.contentDiv);}
this.hide=function(){if(this.shown){this.shown=false;var container=this.emMap.googleMap.getContainer();container.removeChild(this.contentDiv);this.emMap.googleMap.checkResize();this.emMap.googleMap.clearOverlays();this.emMap.googleMap.enableDragging();this.emMap.clusteringSuspended=false;this.emMap.showMarkers();if(this.savedPosition){GEvent.removeListener(this.listener);this.emMap.googleMap.setCenter(this.savedPosition,this.savedZoom);this.savedPosition=null;this.savedZoom=null;}
this.emMap.clusteringSuspended=false;}}
this.centerZoom=function(marker){this.setMapCenter(marker,this.emMap.googleMap.getZoom());}
this.handleMarker=function(marker){GEvent.addListener(marker,'click',PP.Util.createClosure(this,this.onClick,marker));}
this.onClick=function(marker){this.win.innerHTML='';this.emMap.clusteringSuspended=true;this.savedPosition=this.emMap.googleMap.getCenter();this.savedZoom=this.emMap.googleMap.getZoom();var zoom=this.savedZoom;if(zoom<14)
zoom=14;this.setMapCenter(marker,zoom);this.emMap.hideMarkers();this.emMap.googleMap.addOverlay(new GMarker(marker.getPoint(),this.emMap.singleIcon));this.show(marker,marker.id);this.emMap.googleMap.disableDragging();this.listener=GEvent.addListener(this.emMap.googleMap,'zoomend',PP.Util.createClosure(this,this.centerZoom,marker));}
this.setMapCenter=function(marker,zoom){var markerPoint=this.emMap.googleMap.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),zoom);var pos=this.emMap.googleMap.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(markerPoint.x,(markerPoint.y-(this.emMap.googleMap.getSize().height/2))+((this.emMap.googleMap.getSize().height-this.height)/2)),zoom);this.emMap.googleMap.setCenter(pos,zoom);}}
this.InfoWindowControl.prototype=new GControl();this.InfoWindowControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(0,0));}
this.InfoWindowControl.prototype.initialize=function(map){this.map=map;var mapSize=map.getSize();this.win=document.createElement("div");this.win.className='infoWindow';this.win.style.position='absolute';this.win.style.width=mapSize.width+'px';this.win.style.height='80px';this.win.style.display='none';map.getContainer().appendChild(this.win);return this.win;}
this.MessagePaneControl=function(emMap){this.emMap=emMap;this.show=function(msg){this.win.innerHTML=msg;this.win.style.display='block';}}
this.MessagePaneControl.prototype=new GControl();this.MessagePaneControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(5,5));}
this.MessagePaneControl.prototype.initialize=function(map){this.map=map;var mapSize=map.getSize();this.win=document.createElement("div");this.win.className='messagePane';this.win.style.position='absolute';this.win.style.display='none';map.getContainer().appendChild(this.win);return this.win;}
this.StackedPickerControl=function(emMap){this.emMap=emMap;this.height=120;this.shown=false;this.show=function(marker){if(!this.shown){this.shown=true;var container=this.emMap.googleMap.getContainer();this.contentDiv=document.createElement('div');this.contentDiv.className='xMAP_stackedWindow';this.contentDiv.style.position='absolute';this.contentDiv.style.width=(this.emMap.googleMap.getSize().width-5)+'px';this.contentDiv.style.height=(this.emMap.googleMap.getSize().height-5)+'px';this.contentDiv.style.padding='5px';this.contentDiv.style.top='0';this.contentDiv.style.left='0';this.contentDiv.innerHTML='';container.appendChild(this.contentDiv);PP.Ajax.loadElement(PP.resolveUrl('~/~mapstackedwindow'+(marker.id)),'stackedWindow',PP.Util.createClosure(this,function(){var links=this.contentDiv.getElementsByTagName('A');for(var i=0;i<links.length;i++){if(PP.Util.hasClass(links[i],'xMAP_closeBtn')){PP.Util.attachEvent(links[i],'click',PP.Util.createClosure(this,function(){this.hide();}));}}
var divs=this.contentDiv.getElementsByTagName('DIV');for(var i=0;i<divs.length;i++){if(PP.Util.hasClass(divs[i],'mapProperty')){var lpr=divs[i].onclick();PP.Util.attachEvent(divs[i],'click',PP.Util.createClosure(this,function(lpr){this.openInfoWindow(lpr);},lpr));}}}),true,this.contentDiv);}}
this.hide=function(dec){if(this.shown){this.shown=false;var container=this.emMap.googleMap.getContainer();container.removeChild(this.contentDiv);if(!dec){this.emMap.clusteringSuspended=false;this.emMap.googleMap.setCenter(this.savedPosition);}}}
this.openInfoWindow=function(lpr){if(this.shown){var ids='.'+this.marker.id;if(ids.indexOf('.'+lpr)>-1){this.hide(true);this.emMap.infoWindowControl.onClick(this.marker,lpr);}}}
this.centerZoom=function(marker){this.setMapCenter(marker,this.emMap.googleMap.getZoom());}
this.onClick=function(marker){this.marker=marker;this.content.innerHTML='';this.show(marker);this.emMap.clusteringSuspended=true;}
this.showInfoWindow=function(lpr){this.hide();this.emMap.infoWindowControl.onClick(this.marker,lpr);}
this.setMapCenter=function(marker,zoom){var markerPoint=this.emMap.googleMap.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),zoom);var pos=this.emMap.googleMap.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(markerPoint.x,(markerPoint.y-(this.emMap.googleMap.getSize().height/2))+((this.emMap.googleMap.getSize().height-this.height)/2)),zoom);this.emMap.googleMap.setCenter(pos,zoom);}}
this.StackedPickerControl.prototype=new GControl();this.StackedPickerControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(0,0));}
this.StackedPickerControl.prototype.initialize=function(map){this.map=map;var mapSize=map.getSize();this.container=document.createElement("div");this.container.className='xMAP_stackedPickerBg';this.container.style.position='absolute';this.container.style.display='none';this.content=document.createElement("div");this.content.className='xMAP_stackedPicker';this.container.appendChild(this.content);map.getContainer().appendChild(this.container);return this.container;}};