function MarkerManager(map,opt_opts){var me=this;me.map_=map;me.mapZoom_=map.getZoom();me.projection_=map.getCurrentMapType().getProjection();opt_opts=opt_opts||{};me.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var mapTypes=map.getMapTypes();var mapMaxZoom=mapTypes[0].getMaximumResolution();for(var i=0;i<mapTypes.length;i++){var mapTypeMaxZoom=mapTypes[i].getMaximumResolution();if(mapTypeMaxZoom>mapMaxZoom){mapMaxZoom=mapTypeMaxZoom;}}
me.maxZoom_=opt_opts.maxZoom||mapMaxZoom;me.trackMarkers_=opt_opts.trackMarkers;me.show_=opt_opts.show||true;var padding;if(typeof opt_opts.borderPadding==="number"){padding=opt_opts.borderPadding;}else{padding=MarkerManager.DEFAULT_BORDER_PADDING_;}
me.swPadding_=new GSize(-padding,padding);me.nePadding_=new GSize(padding,-padding);me.borderPadding_=padding;me.gridWidth_=[];me.grid_=[];me.grid_[me.maxZoom_]=[];me.numMarkers_=[];me.numMarkers_[me.maxZoom_]=0;GEvent.bind(map,"moveend",me,me.onMapMoveEnd_);me.removeOverlay_=function(marker){map.removeOverlay(marker);me.shownMarkers_--;};me.addOverlay_=function(marker){if(me.show_){map.addOverlay(marker);me.shownMarkers_++;}};me.resetManager_();me.shownMarkers_=0;me.shownBounds_=me.getMapGridBounds_();}
MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;MarkerManager.prototype.resetManager_=function(){var me=this;var mapWidth=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var zoom=0;zoom<=me.maxZoom_;++zoom){me.grid_[zoom]=[];me.numMarkers_[zoom]=0;me.gridWidth_[zoom]=Math.ceil(mapWidth/me.tileSize_);mapWidth<<=1;}};MarkerManager.prototype.clearMarkers=function(){var me=this;me.processAll_(me.shownBounds_,me.removeOverlay_);me.resetManager_();};MarkerManager.prototype.getTilePoint_=function(latlng,zoom,padding){var pixelPoint=this.projection_.fromLatLngToPixel(latlng,zoom);return new GPoint(Math.floor((pixelPoint.x+padding.width)/this.tileSize_),Math.floor((pixelPoint.y+padding.height)/this.tileSize_));};MarkerManager.prototype.addMarkerBatch_=function(marker,minZoom,maxZoom){var mPoint=marker.getPoint();marker.MarkerManager_minZoom=minZoom;if(this.trackMarkers_){GEvent.bind(marker,"changed",this,this.onMarkerMoved_);}
var gridPoint=this.getTilePoint_(mPoint,maxZoom,GSize.ZERO);for(var zoom=maxZoom;zoom>=minZoom;zoom--){var cell=this.getGridCellCreate_(gridPoint.x,gridPoint.y,zoom);cell.push(marker);gridPoint.x=gridPoint.x>>1;gridPoint.y=gridPoint.y>>1;}};MarkerManager.prototype.isGridPointVisible_=function(point){var me=this;var vertical=me.shownBounds_.minY<=point.y&&point.y<=me.shownBounds_.maxY;var minX=me.shownBounds_.minX;var horizontal=minX<=point.x&&point.x<=me.shownBounds_.maxX;if(!horizontal&&minX<0){var width=me.gridWidth_[me.shownBounds_.z];horizontal=minX+width<=point.x&&point.x<=width-1;}
return vertical&&horizontal;};MarkerManager.prototype.onMarkerMoved_=function(marker,oldPoint,newPoint){var me=this;var zoom=me.maxZoom_;var changed=false;var oldGrid=me.getTilePoint_(oldPoint,zoom,GSize.ZERO);var newGrid=me.getTilePoint_(newPoint,zoom,GSize.ZERO);while(zoom>=0&&(oldGrid.x!==newGrid.x||oldGrid.y!==newGrid.y)){var cell=me.getGridCellNoCreate_(oldGrid.x,oldGrid.y,zoom);if(cell){if(me.removeFromArray_(cell,marker)){me.getGridCellCreate_(newGrid.x,newGrid.y,zoom).push(marker);}}
if(zoom===me.mapZoom_){if(me.isGridPointVisible_(oldGrid)){if(!me.isGridPointVisible_(newGrid)){me.removeOverlay_(marker);changed=true;}}else{if(me.isGridPointVisible_(newGrid)){me.addOverlay_(marker);changed=true;}}}
oldGrid.x=oldGrid.x>>1;oldGrid.y=oldGrid.y>>1;newGrid.x=newGrid.x>>1;newGrid.y=newGrid.y>>1;--zoom;}
if(changed){me.notifyListeners_();}};MarkerManager.prototype.removeMarker=function(marker){var me=this;var zoom=me.maxZoom_;var changed=false;var point=marker.getPoint();var grid=me.getTilePoint_(point,zoom,GSize.ZERO);while(zoom>=0){var cell=me.getGridCellNoCreate_(grid.x,grid.y,zoom);if(cell){me.removeFromArray_(cell,marker);}
if(zoom===me.mapZoom_){if(me.isGridPointVisible_(grid)){me.removeOverlay_(marker);changed=true;}}
grid.x=grid.x>>1;grid.y=grid.y>>1;--zoom;}
if(changed){me.notifyListeners_();}
me.numMarkers_[marker.MarkerManager_minZoom]--;};MarkerManager.prototype.addMarkers=function(markers,minZoom,opt_maxZoom){var maxZoom=this.getOptMaxZoom_(opt_maxZoom);for(var i=markers.length-1;i>=0;i--){this.addMarkerBatch_(markers[i],minZoom,maxZoom);}
this.numMarkers_[minZoom]+=markers.length;};MarkerManager.prototype.getOptMaxZoom_=function(opt_maxZoom){return opt_maxZoom||this.maxZoom_;};MarkerManager.prototype.getMarkerCount=function(zoom){var total=0;for(var z=0;z<=zoom;z++){total+=this.numMarkers_[z];}
return total;};MarkerManager.prototype.getMarker=function(lat,lng,zoom){var me=this;var mPoint=new GLatLng(lat,lng);var gridPoint=me.getTilePoint_(mPoint,zoom,GSize.ZERO);var marker=new GMarker(mPoint);var cellArray=me.getGridCellNoCreate_(gridPoint.x,gridPoint.y,zoom);if(cellArray!=undefined){for(var i=0;i<cellArray.length;i++)
{if(lat==cellArray[i].getLatLng().lat()&&lng==cellArray[i].getLatLng().lng())
{marker=cellArray[i];}}}
return marker;};MarkerManager.prototype.addMarker=function(marker,minZoom,opt_maxZoom){var me=this;var maxZoom=this.getOptMaxZoom_(opt_maxZoom);me.addMarkerBatch_(marker,minZoom,maxZoom);var gridPoint=me.getTilePoint_(marker.getPoint(),me.mapZoom_,GSize.ZERO);if(me.isGridPointVisible_(gridPoint)&&minZoom<=me.shownBounds_.z&&me.shownBounds_.z<=maxZoom){me.addOverlay_(marker);me.notifyListeners_();}
this.numMarkers_[minZoom]++;};GBounds.prototype.containsPoint=function(point){var outer=this;return(outer.minX<=point.x&&outer.maxX>=point.x&&outer.minY<=point.y&&outer.maxY>=point.y);};MarkerManager.prototype.getGridCellCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];if(!gridCol){gridCol=grid[x]=[];return(gridCol[y]=[]);}
var gridCell=gridCol[y];if(!gridCell){return(gridCol[y]=[]);}
return gridCell;};MarkerManager.prototype.getGridCellNoCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];return gridCol?gridCol[y]:undefined;};MarkerManager.prototype.getGridBounds_=function(bounds,zoom,swPadding,nePadding){zoom=Math.min(zoom,this.maxZoom_);var bl=bounds.getSouthWest();var tr=bounds.getNorthEast();var sw=this.getTilePoint_(bl,zoom,swPadding);var ne=this.getTilePoint_(tr,zoom,nePadding);var gw=this.gridWidth_[zoom];if(tr.lng()<bl.lng()||ne.x<sw.x){sw.x-=gw;}
if(ne.x-sw.x+1>=gw){sw.x=0;ne.x=gw-1;}
var gridBounds=new GBounds([sw,ne]);gridBounds.z=zoom;return gridBounds;};MarkerManager.prototype.getMapGridBounds_=function(){var me=this;return me.getGridBounds_(me.map_.getBounds(),me.mapZoom_,me.swPadding_,me.nePadding_);};MarkerManager.prototype.onMapMoveEnd_=function(){var me=this;me.objectSetTimeout_(this,this.updateMarkers_,0);};MarkerManager.prototype.objectSetTimeout_=function(object,command,milliseconds){return window.setTimeout(function(){command.call(object);},milliseconds);};MarkerManager.prototype.visible=function(){return this.show_?true:false;};MarkerManager.prototype.isHidden=function(){return!this.show_;};MarkerManager.prototype.show=function(){this.show_=true;this.refresh();};MarkerManager.prototype.hide=function(){this.show_=false;this.refresh();};MarkerManager.prototype.toggle=function(){this.show_=!this.show_;this.refresh();};MarkerManager.prototype.refresh=function(){var me=this;if(me.shownMarkers_>0){me.processAll_(me.shownBounds_,me.removeOverlay_);}
if(me.show_){me.processAll_(me.shownBounds_,me.addOverlay_);}
me.notifyListeners_();};MarkerManager.prototype.updateMarkers_=function(){var me=this;me.mapZoom_=this.map_.getZoom();var newBounds=me.getMapGridBounds_();if(newBounds.equals(me.shownBounds_)&&newBounds.z===me.shownBounds_.z){return;}
if(newBounds.z!==me.shownBounds_.z){me.processAll_(me.shownBounds_,me.removeOverlay_);if(me.show_){me.processAll_(newBounds,me.addOverlay_);}}else{me.rectangleDiff_(me.shownBounds_,newBounds,me.removeCellMarkers_);if(me.show_){me.rectangleDiff_(newBounds,me.shownBounds_,me.addCellMarkers_);}}
me.shownBounds_=newBounds;me.notifyListeners_();};MarkerManager.prototype.notifyListeners_=function(){GEvent.trigger(this,"changed",this.shownBounds_,this.shownMarkers_);};MarkerManager.prototype.processAll_=function(bounds,callback){for(var x=bounds.minX;x<=bounds.maxX;x++){for(var y=bounds.minY;y<=bounds.maxY;y++){this.processCellMarkers_(x,y,bounds.z,callback);}}};MarkerManager.prototype.processCellMarkers_=function(x,y,z,callback){var cell=this.getGridCellNoCreate_(x,y,z);if(cell){for(var i=cell.length-1;i>=0;i--){callback(cell[i]);}}};MarkerManager.prototype.removeCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.removeOverlay_);};MarkerManager.prototype.addCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.addOverlay_);};MarkerManager.prototype.rectangleDiff_=function(bounds1,bounds2,callback){var me=this;me.rectangleDiffCoords_(bounds1,bounds2,function(x,y){callback.apply(me,[x,y,bounds1.z]);});};MarkerManager.prototype.rectangleDiffCoords_=function(bounds1,bounds2,callback){var minX1=bounds1.minX;var minY1=bounds1.minY;var maxX1=bounds1.maxX;var maxY1=bounds1.maxY;var minX2=bounds2.minX;var minY2=bounds2.minY;var maxX2=bounds2.maxX;var maxY2=bounds2.maxY;var x,y;for(x=minX1;x<=maxX1;x++){for(y=minY1;y<=maxY1&&y<minY2;y++){callback(x,y);}
for(y=Math.max(maxY2+1,minY1);y<=maxY1;y++){callback(x,y);}}
for(y=Math.max(minY1,minY2);y<=Math.min(maxY1,maxY2);y++){for(x=Math.min(maxX1+1,minX2)-1;x>=minX1;x--){callback(x,y);}
for(x=Math.max(minX1,maxX2+1);x<=maxX1;x++){callback(x,y);}}};MarkerManager.prototype.removeFromArray_=function(array,value,opt_notype){var shift=0;for(var i=0;i<array.length;++i){if(array[i]===value||(opt_notype&&array[i]===value)){array.splice(i--,1);shift++;}}
return shift;};
function CallParentConstructor(currentObject,parent){if(arguments.length>2){parent.apply(currentObject,Array.prototype.slice.call(arguments,2));}
else{parent.call(currentObject);}};
function MarkerSpreader(map,threshold,spreadRadiusFunction){this.map=map;this.threshold=(threshold?threshold:-1);this.spreadRadiusFunction=(spreadRadiusFunction?spreadRadiusFunction:this.defaultSpreadRadiusFunction);}
MarkerSpreader.prototype.defaultSpreadRadiusFunction=function(center,numberOfElements){if(numberOfElements<10)
return 0.04;else
return 0.08;}
MarkerSpreader.prototype.compareMarkers=function(marker1,marker2){var ll1=marker1.getLatLng();var ll2=marker2.getLatLng();if((window.spreader.threshold<=0&&ll1.equals(ll2))||(window.spreader.threshold>0&&ll1.distanceFrom(ll2)<this.threshold)){return 0;}
else{if(ll1.lat()<ll2.lat()){return-1;}
else if(ll1.lat()>ll2.lat()){return 1;}
else{if(ll1.lng()<ll2.lng()){return-1;}
else if(ll1.lng()>ll2.lng()){return 1;}
else{return 0;}}}}
MarkerSpreader.prototype.spreadMarkers=function(markers){if(markers.length==0)
return new Array();window.spreader=this;markers.sort(this.compareMarkers);var ret=new Array();var clusters=new Array();var lastMarker=markers[0];clusters.push(new Array());var clusterIndex=clusters.length-1;clusters[clusterIndex].push(lastMarker);for(i=1;i<markers.length;i++){var actMarker=markers[i];if(this.compareMarkers(lastMarker,actMarker)!=0){clusters.push(new Array());clusterIndex=clusters.length-1;lastMarker=actMarker;}
clusters[clusterIndex].push(actMarker);}
var projector=new google.maps.MercatorProjection(20);var projectionZoomLevel=16;for(i=0;i<clusters.length;i++){var cluster=clusters[i];if(cluster.length==1){ret.push(cluster[0]);}
else{ret.push(cluster[0]);var centerLL=cluster[0].getLatLng();var radiusLL=this.spreadRadiusFunction(centerLL,cluster.length);var firstPointLL=new google.maps.LatLng(centerLL.lat(),centerLL.lng()+radiusLL);var center=projector.fromLatLngToPixel(centerLL,projectionZoomLevel);var firstPoint=projector.fromLatLngToPixel(firstPointLL,projectionZoomLevel);var radius=firstPoint.x-center.x;var delta=2*Math.PI/(cluster.length-1);for(j=1;j<cluster.length;j++){var angle=j*delta;var point=new google.maps.Point(center.x+radius*Math.cos(angle),center.y+radius*Math.sin(angle));cluster[j].setLatLng(projector.fromPixelToLatLng(point,projectionZoomLevel));ret.push(cluster[j]);}}}
return ret;};
GenericMarker.prototype=new google.maps.Marker(new google.maps.Marker(0,0));function GenericMarker(defaultErrorText,markerInfo,opts,addPopup){if(defaultErrorText){this.defaultErrorText=defaultErrorText;this.markerInfo=markerInfo;var latlng=new google.maps.LatLng(this.markerInfo.lat,this.markerInfo.lng);CallParentConstructor(this,google.maps.Marker,latlng,opts);this.clickListener=null;if(addPopup){var me=this;this.clickListener=google.maps.Event.addListener(this,"click",function(){me.showPopup();});}}}
GenericMarker.prototype.showPopup=function(){}
GenericMarker.prototype.getMarkerInfo=function(){return this.markerInfo;}
TravelMarker.prototype=new GenericMarker();function TravelMarker(waitingText,defaultErrorText,markerInfo,opts){CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,true);this.waitingText=waitingText;this.popupText=null;}
TravelMarker.prototype.showPopup=function(){if(this.popupText){this.openInfoWindowHtml(this.popupText);}
else{this.loadPopupText();}}
TravelMarker.prototype.loadPopupText=function(){this.openInfoWindowHtml(this.waitingText+'<span class="loading"></span>');var me=this;var url='?page=AjaxHtmlDispatcher';var params='id='+this.markerInfo.link+"&class=travels&method=load";google.maps.DownloadUrl(url,function(data,responseCode){me.doLoadedInfos(data,responseCode);},params);}
TravelMarker.prototype.doLoadedInfos=function(data,responseCode){if(responseCode==200){this.popupText=data;this.showPopup();}
else{this.showDefaultErrorMessage();}}
TravelMarker.prototype.showDefaultErrorMessage=function(){this.openInfoWindowHtml('<span class="error">'+this.defaultErrorText+'</span>');}
GalleryMarker.prototype=new GenericMarker();function GalleryMarker(defaultErrorText,detailText,pictureByText,markerInfo,opts){if(!opts){opts=this.buildDefaultOpts(markerInfo);}
CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,true);this.detailText=detailText;this.pictureByText=pictureByText;this.html='';this.createPopupHtml();}
GalleryMarker.prototype.buildDefaultOpts=function(markerInfo){var customIcon=new google.maps.Icon();customIcon.image=markerInfo.icon;customIcon.iconSize=new google.maps.Size(markerInfo.iconsize.width,markerInfo.iconsize.height);customIcon.iconAnchor=new google.maps.Point(markerInfo.iconsize.width/2,markerInfo.iconsize.height/2);customIcon.infoWindowAnchor=new google.maps.Point(markerInfo.iconsize.width,markerInfo.iconsize.height/2);var opts={title:markerInfo.title+" - "+markerInfo.author,icon:customIcon};return opts;}
GalleryMarker.prototype.createPopupHtml=function(){this.html='<div class="clearfix">'+'<table>'+'<tr>'+'<td colspan="2">'+'<a href="'+this.markerInfo.link+'">'+'<img src="'+this.markerInfo.src+'" title="'+
this.markerInfo.title+'" alt="'+this.markerInfo.title+'" class="mapImage" />'+'</a>'+'</td>'+'</tr>'+'<tr>'+'<td colspan="2">'+'<span class="mapImageTitle">'+this.markerInfo.title+'</span>'+'</td>'+'</tr>'+'<tr>'+'<td style="width: 1.5em">'+'<span>'+this.pictureByText+':</span>'+'</td>'+'<td>'+'<span>'+this.markerInfo.author+'</span>'+'</td>'+'</tr>'+'<tr>'+'<td colspan="2" style="text-align: center">'+'<a href="'+this.markerInfo.link+'">'+this.detailText+'</a>'+'</td>'+'</tr>'+'</table>'+'</div>';}
GalleryMarker.prototype.showPopup=function(){this.openInfoWindowHtml(this.html);}
SelectableMarker.prototype=new GenericMarker();function SelectableMarker(defaultErrorText,markerInfo,opts,addPopup,iconsPath,selectedIcon,mapHandler){CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,addPopup);this.iconsPath=iconsPath;this.selectedIcon=selectedIcon;this.mapHandler=mapHandler;this.selected=false;this.defaultImage=this.getIcon().image;}
SelectableMarker.prototype.selectMarker=function(openPopup){if(this.mapHandler&&this.mapHandler.resetIcons)
this.mapHandler.resetIcons();this.selected=true;this.setImage(this.iconsPath+this.selectedIcon);if(openPopup)
this.openInfoWindowHtml(this.html);}
SelectableMarker.prototype.isSelected=function(){return this.selected;}
SelectableMarker.prototype.resetIcon=function(){this.selected=false;this.setImage(this.defaultImage);}
UserTopTenMarker.prototype=new SelectableMarker();function UserTopTenMarker(preferredIconPath,mapHandler,canvasId,defaultErrorText,labels,markerInfo,selectedIcon,opts,listHandler){CallParentConstructor(this,SelectableMarker,defaultErrorText,markerInfo,opts,true,preferredIconPath,selectedIcon,mapHandler);this.html='';this.canvasId=canvasId;this.labels=labels;this.editable=markerInfo.editable;this.listHandler=listHandler;this.createPopupHtml();}
UserTopTenMarker.prototype.getMarkerInfo=function(){return this.markerInfo;}
UserTopTenMarker.prototype.createPopupHtml=function(){this.html='<div class="ballonWrapper">'+'<div class="baloonTitle">'+'<span>'+this.labels.locationLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<span>'+this.markerInfo.location+'</span>'+'</div>';if(this.markerInfo.descrizione.length!=0){this.html+='<div class="baloonTitle2">'+'<span>'+this.labels.descriptionLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<span>'+this.markerInfo.descrizione+'</span>'+'</div>';}
if(this.markerInfo.categories.length!=0){this.html+='<div class="baloonTitle2">'+'<span>'+this.labels.categoriesLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<ul>';for(var i=0,l=this.markerInfo.categories.length;i<l;i++){this.html+='<li style="display: block;">'+this.markerInfo.categories[i].value+'</li>';}
this.html+='</ul>'+'</div>';}
this.html+='</div>';if(this.editable){this.html+='<div class="baloonEditor">'+'<a class="resetForm noUnderline" href="javascript://" onclick="'+'$(\''+this.canvasId+'\').mapHandler.deleteNode('+
this.markerInfo.nid+')">'+this.labels.removeLabel+'</a>'+'<a class="resetForm noUnderline" href="javascript://" onclick="'+'$(\''+this.canvasId+'\').mapHandler.changeNodeType('+
this.markerInfo.nid+', '+(!this.markerInfo.preferred)+')">'+
(this.markerInfo.preferred?this.labels.toVisitedLabel:this.labels.toFavouriteLabel)+'</a>'+'</div>';}}
UserTopTenMarker.prototype.showPopup=function(){if(this.listHandler){this.listHandler.updateDetails(this.markerInfo);this.selectMarker(true);}
else{this.openInfoWindowHtml(this.html);}}
PlacesMapMarker.prototype=new SelectableMarker();function PlacesMapMarker(themePath,defaultErrorText,locationLabel,mapHandler,markerInfo,selectedIcon,opts){CallParentConstructor(this,SelectableMarker,defaultErrorText,markerInfo,opts,true,themePath,selectedIcon,mapHandler);this.locationLabel=locationLabel;this.mapHandler=mapHandler;this.html='';this.createPopupHtml();}
PlacesMapMarker.prototype.createPopupHtml=function(){this.html='<div style="width: 210px; height: 50px; overflow: auto;">'+'<div style="color: #505050">'+'<span>'+this.locationLabel+'</span>'+'</div>'+'<div>'+'<span>'+this.markerInfo.location+'</span>'+'</div>'+'</div>';}
PlacesMapMarker.prototype.showPopup=function(){this.selectMarker(true);if(this.mapHandler&&this.mapHandler.markerSelected){this.mapHandler.markerSelected(this.markerInfo);}}
PhotoMapMarker.prototype=new GenericMarker();function PhotoMapMarker(defaultErrorText,locationLabel,markerInfo,opts,avoidPopup){CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,!avoidPopup);this.html='';this.locationLabel=locationLabel;this.createPopupHtml();}
PhotoMapMarker.prototype.createPopupHtml=function(){this.html='<div style="width: 210px; height: 50px; overflow: auto;">'+'<div style="color: #505050">'+'<span>'+this.locationLabel+'</span>'+'</div>'+'<div>'+'<span>'+this.markerInfo.location+'</span>'+'</div>'+'</div>';}
PhotoMapMarker.prototype.showPopup=function(){this.openInfoWindowHtml(this.html);}
TravelBlogMarker.prototype=new GenericMarker();function TravelBlogMarker(preferredIconPath,mapHandler,canvasId,defaultErrorText,labels,markerInfo,selectedIcon,opts){CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,true,preferredIconPath,selectedIcon,mapHandler);this.html='';this.canvasId=canvasId;this.labels=labels;this.editable=markerInfo.editable;this.createPopupHtml();if(!this.markerInfo.stayInPage){var me=this;if(this.markerInfo.hidePopup){if(this.clickListener){google.maps.Event.removeListener(this.clickListener);this.clickListener=null;}}
this.clickListener=google.maps.Event.addListener(this,"click",function(){window.location=me.markerInfo.link});}}
TravelBlogMarker.prototype.getMarkerInfo=function(){return this.markerInfo;}
TravelBlogMarker.prototype.createPopupHtml=function(){this.html='<div style="width: 210px; height: 80px;">'+'<div style="color: #505050">'+'<span>'+this.labels.location+'</span>'+'</div>'+'<div>'+'<span>'+this.markerInfo.location+'</span>'+'</div>';if(this.markerInfo.nextLink){this.html+='<div style="margin-left: 5px">'+'<a  style="margin-left: 5px!important" class="resetForm" href= '+this.markerInfo.nextLink+'>'+this.markerInfo.nextLinkdescr+'</a>'+'</div>';}
if(this.markerInfo.link&&this.markerInfo.showMarkerLink){this.html+='<div style="margin-left: 5px">'+'<a  style="margin-left: 5px!important" class="resetForm" href= '+this.markerInfo.link+'>'+this.markerInfo.linkdescr+'</a>'+'</div>';}
if(this.markerInfo.prevLink){this.html+='<div>'+'<a  style="margin-left: 5px!important" class="resetForm" href= '+this.markerInfo.prevLink+'>'+this.markerInfo.prevLinkdescr+'</a>'+'</div>';}
this.html+='</div>';}
TravelBlogMarker.prototype.showPopup=function(){this.openInfoWindowHtml(this.html);}
AdviceMarker.prototype=new GenericMarker();function AdviceMarker(defaultErrorText,markerInfo,opts,addPopup,labels,avoidShowLink){CallParentConstructor(this,GenericMarker,defaultErrorText,markerInfo,opts,addPopup);this.labels=labels;this.avoidShowLink=avoidShowLink;this.html='';this.createPopupHtml();}
AdviceMarker.prototype.createPopupHtml=function(){this.html='<div class="ballonWrapper">'+(this.markerInfo.address?'<div class="baloonTitle">'+'<span>'+this.labels.locationLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<span>'+this.markerInfo.address+'</span>'+'</div>':'')+'<div class="baloonTitle">'+'<span>'+this.labels.titleLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<span><b>'+this.markerInfo.title+'</b></span>'+'</div>'+'<div class="baloonTitle">'+'<span>'+this.labels.descriptionLabel+'</span>'+'</div>'+'<div class="baloonValue">'+'<span>'+this.markerInfo.body+'</span>'+'</div>'+'</div>'+(this.avoidShowLink?'':'<div class="baloonFooter">'+'<div class="right">'+'<a href="'+this.markerInfo.itemLink+'">Visualizza</a>'+'</div>'+'</div>');};
AdviceMarker.selectMarker=function(itemID,scrollTo){var items=$$('div.advicesWrapper ul li');for(var i=0;i<items.length;i++){if(items[i].id!=itemID){Element.removeClassName(items[i],'on');}
else{Element.addClassName(items[i],'on');}}
if(scrollTo){Effect.ScrollTo(itemID);}}
AdviceMarker.prototype.showPopup=function(){AdviceMarker.selectMarker(this.markerInfo.itemID,false);this.openInfoWindowHtml(this.html);};
var RomePosition=new google.maps.LatLng(41.54,12.29);function GenericMapHandler(defaultErrorText,canvasId,zoomLevel,largeControl,enableMouseWheelZoom){this.canvasId=canvasId;if(canvasId!=null){this.defaultErrorText=defaultErrorText;this.defaultZoomLevel=zoomLevel;this.map=new google.maps.Map2($(canvasId));if(largeControl)
this.map.setUI(this.map.getDefaultUI());else
this.map.addControl(new google.maps.SmallMapControl());if(!enableMouseWheelZoom)
this.map.disableScrollWheelZoom();this.map.setCenter(RomePosition,zoomLevel);this.mgr=new MarkerManager(this.map);}
this.markers=new Array();}
GenericMapHandler.prototype.reset=function(){this.mgr.clearMarkers();this.map.setCenter(RomePosition,this.defaultZoomLevel);}
GenericMapHandler.prototype.resetIcons=function(){for(var i=0,l=this.markers.length;i<l;i++){try{this.markers[i].resetIcon();}catch(e){}}}
SnpGoogleMapHandler.prototype=new GenericMapHandler();function SnpGoogleMapHandler(waitingText,defaultErrorText,canvasId,zoomLevel,largeControl){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl);this.waitingText=waitingText;this.pastMarkers=new Array();this.futureMarkers=new Array();}
SnpGoogleMapHandler.prototype.setPastMarkers=function(markers){this.pastMarkers=markers;}
SnpGoogleMapHandler.prototype.setFutureMarkers=function(markers){this.futureMarkers=markers;}
SnpGoogleMapHandler.prototype.showMarkers=function(future){var markers=(future?this.futureMarkers:this.pastMarkers);var markersArray=new Array();for(var i=0;i<markers.length;i++){var markerInfo=markers[i];var marker=new TravelMarker(this.waitingText,this.defaultErrorText,markerInfo);markersArray.push(marker);}
this.mgr.clearMarkers();var ms=new MarkerSpreader(this.map);var spreadedMarkers=ms.spreadMarkers(markersArray);if(spreadedMarkers.length!=0){this.mgr.addMarkers(spreadedMarkers,0);this.mgr.refresh();}}
GalleryGoogleMapHandler.prototype=new GenericMapHandler();function GalleryGoogleMapHandler(defaultErrorText,detailText,pictureByText,canvasId,zoomLevel,largeControl){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl);this.detailText=detailText;this.pictureByText=pictureByText;}
GalleryGoogleMapHandler.prototype.setMarkers=function(markers){this.mgr.clearMarkers();var markersArray=new Array();for(var i=0;i<markers.length;i++){var markerInfo=markers[i];var marker=new GalleryMarker(this.defaultErrorText,this.detailText,this.pictureByText,markerInfo);markersArray.push(marker);}
var ms=new MarkerSpreader(this.map);var spreadedMarkers=ms.spreadMarkers(markersArray);if(spreadedMarkers.length!=0){this.mgr.addMarkers(spreadedMarkers,0);this.mgr.refresh();}}
Top10MapHandler.prototype=new GenericMapHandler();function Top10MapHandler(userId,texts,labels,canvasId,baseUrl,zoomLevel,largeControl,preferredIconPath,listHandler){CallParentConstructor(this,GenericMapHandler,texts.defaultErrorText,canvasId,zoomLevel,largeControl);this.userId=userId;this.texts=texts;this.labels=labels;this.baseUrl=baseUrl;this.preferredIconPath=preferredIconPath;this.listHandler=listHandler;this.markers=new Array();$(this.canvasId).mapHandler=this;}
Top10MapHandler.prototype.deleteItemFailure=function(message){new GeneralScript().showErrorMessage(message);}
Top10MapHandler.prototype.doDeleteItem=function(transport){var jsonText=transport.responseText;eval('jsonResp = '+jsonText);if(jsonResp.code==200){this.updateMarkers();if(this.listHandler)this.listHandler.updateDetails(null);}
else{if(jsonResp.msg){this.deleteItemFailure(jsonResp.msg);}
else{this.deleteItemFailure(this.texts.removeErrorText);}}}
Top10MapHandler.prototype.deleteNode=function(nid){var params={'elementId':nid};var me=this;AjaxRequest(this.baseUrl+'?page=AjaxDispatcher&class=topten&method=remove',{parameters:params,onSuccess:function(transport){me.doDeleteItem(transport);},onFailure:function(){me.deleteItemFailure(this.texts.removeErrorText);}});}
Top10MapHandler.prototype.doChangeNodeType=function(transport){var jsonText=transport.responseText;eval('jsonResp = '+jsonText);if(jsonResp.code==200){this.updateMarkers();}
else{if(jsonResp.msg){this.deleteItemFailure(jsonResp.msg);}
else{this.deleteItemFailure(this.texts.changeTypeErrorText);}}}
Top10MapHandler.prototype.changeNodeType=function(nid,favourite){var params={'elementId':nid,'favourite':favourite};var me=this;AjaxRequest(this.baseUrl+'?page=AjaxDispatcher&class=topten&method=change',{parameters:params,onSuccess:function(transport){me.doChangeNodeType(transport);},onFailure:function(){me.deleteItemFailure(this.texts.changeTypeErrorText);}});}
Top10MapHandler.prototype.doUpdateMarkers=function(transport){var jsonText=transport.responseText;eval('jsonResp = '+jsonText);if(jsonResp.code==200){var selNid=null;var selMarker=null;var markerInfo=null;for(var j=0,ml=this.markers.length;j<ml;j++){if(this.markers[j].isSelected()){markerInfo=this.markers[j].getMarkerInfo();selNid=this.markers[j].getMarkerInfo().nid;break;}}
this.mgr.clearMarkers();var topten=jsonResp.topten;var markersArray=new Array();for(var i=0,l=topten.length;i<l;i++){var opts={title:topten[i].location};if(this.preferredIconPath){var customIcon=null;var selectedIcon=null;if(topten[i].preferred){customIcon=new google.maps.Icon();customIcon.shadow=this.preferredIconPath+"/images/ombra-preferiti.png";customIcon.image=this.preferredIconPath+"/images/preferred.png";customIcon.iconSize=new GSize(32,32);customIcon.shadowSize=new GSize(45,32);customIcon.iconAnchor=new GPoint(7,30);customIcon.infoWindowAnchor=new GPoint(16,1);opts={title:topten[i].location.replace(/(<([^>]+)>)/ig,""),icon:customIcon};selectedIcon="/images/preferred-over.png";}
else{customIcon=new google.maps.Icon();customIcon.shadow=this.preferredIconPath+"/images/ombra-visitati.png";customIcon.image=this.preferredIconPath+"/images/flagvisitati.png";customIcon.iconSize=new GSize(33,34);customIcon.shadowSize=new GSize(48,34);customIcon.iconAnchor=new GPoint(3,33);customIcon.infoWindowAnchor=new GPoint(31,4);opts={title:topten[i].location.replace(/(<([^>]+)>)/ig,""),icon:customIcon};selectedIcon="/images/flagvisitati-over.png";}}
var marker=new UserTopTenMarker(this.preferredIconPath,this,this.canvasId,this.texts.defaultErrorText,this.labels,topten[i],selectedIcon,opts,this.listHandler);if(topten[i].nid==selNid)
selMarker=marker;markersArray.push(marker);}
var ms=new MarkerSpreader(this.map);this.markers=ms.spreadMarkers(markersArray);if(this.markers.length!=0){this.mgr.addMarkers(this.markers,0);this.mgr.refresh();if(selMarker){selMarker.selectMarker(true);}}
if(this.listHandler&&selMarker)this.listHandler.updateDetailsInfo(selMarker.getMarkerInfo());}
else{}}
Top10MapHandler.prototype.updateMarkers=function(){var me=this;var params={'user':this.userId};AjaxRequest(me.baseUrl+'?page=AjaxDispatcher&class=topten&method=update',{parameters:params,onSuccess:function(transport){me.doUpdateMarkers(transport);},onFailure:function(){}});}
PhotoMapHandler.prototype=new GenericMapHandler();function PhotoMapHandler(defaultErrorText,locationLabel,canvasId,zoomLevel,largeControl){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl);this.locationLabel=locationLabel;}
PhotoMapHandler.prototype.setMarker=function(markerInfo){this.mgr.clearMarkers();var marker=new PhotoMapMarker(this.defaultErrorText,this.locationLabel,markerInfo);this.mgr.addMarker(marker,0);this.mgr.refresh();marker.showPopup();}
PlacesMapHandler.prototype=new GenericMapHandler();function PlacesMapHandler(defaultErrorText,locationLabel,canvasId,iconsPath,mapHandler,zoomLevel,largeControl){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl,false);this.locationLabel=locationLabel;this.iconsPath=iconsPath;this.mapHandler=mapHandler;this.visitedMarkers=new Array();this.favouritesMarkers=new Array();this.suggestedMarkers=new Array();}
PlacesMapHandler.prototype.markerSelected=function(markerInfo){this.mapHandler.markerSelected(markerInfo);}
PlacesMapHandler.prototype.selectPosition=function(position){this.markers[position].showPopup();}
PlacesMapHandler.prototype.createMarkers=function(markersInfo,type,shadowIcon){var markers=new Array();for(var i=0;i<markersInfo.length;i++){var markerInfo=markersInfo[i].info;markerInfo.lat=markersInfo[i].extinfo.latlng[0];markerInfo.lng=markersInfo[i].extinfo.latlng[1];markerInfo.south=markersInfo[i].extinfo.bb[0];markerInfo.east=markersInfo[i].extinfo.bb[1];markerInfo.north=markersInfo[i].extinfo.bb[2];markerInfo.west=markersInfo[i].extinfo.bb[3];markerInfo.location=markersInfo[i].extinfo.label;var opts=null;if((i+1)<=10){var customIcon=new google.maps.Icon();customIcon.shadow=this.iconsPath+shadowIcon;var selectedIcon=null;if(type=='visited'){customIcon.image=this.iconsPath+"/images/marker-visitati-"+(i+1)+".png";customIcon.iconSize=new GSize(33,34);customIcon.shadowSize=new GSize(48,32);customIcon.iconAnchor=new GPoint(3,33);customIcon.infoWindowAnchor=new GPoint(31,4);selectedIcon="/images/flagvisitati-over.png";}
else if(type=='preferred'){customIcon.image=this.iconsPath+"/images/marker-preferiti-"+(i+1)+".png";customIcon.iconSize=new GSize(32,32);customIcon.shadowSize=new GSize(36,32);customIcon.iconAnchor=new GPoint(7,30);customIcon.infoWindowAnchor=new GPoint(16,1);selectedIcon="/images/preferred-over.png";}
else if(type=='suggested'){customIcon.image=this.iconsPath+"/images/marker-suggeriti.png";customIcon.iconSize=new GSize(34,34);customIcon.shadowSize=new GSize(40,34);customIcon.iconAnchor=new GPoint(16,32);customIcon.infoWindowAnchor=new GPoint(24,2);selectedIcon="/images/suggested-over.png";}
opts={title:markerInfo.location.replace(/(<([^>]+)>)/ig,""),icon:customIcon};var marker=new PlacesMapMarker(this.iconsPath,this.defaultErrorText,this.locationLabel,this,markerInfo,selectedIcon,opts);markers.push(marker);}}
return markers;}
PlacesMapHandler.prototype.setVisitedMarkers=function(markersInfo){this.visitedMarkers=this.createMarkers(markersInfo,'visited',"/images/ombra-visitati.png");}
PlacesMapHandler.prototype.setFavouritesMarkers=function(markersInfo){this.favouritesMarkers=this.createMarkers(markersInfo,'preferred',"/images/ombra-preferiti.png");}
PlacesMapHandler.prototype.setSuggestedMarkers=function(markersInfo){this.suggestedMarkers=this.createMarkers(markersInfo,'suggested',"/images/ombra-suggeriti.png");}
PlacesMapHandler.prototype.updateMarkers=function(type){if(type=='visited'){this.markers=this.visitedMarkers;this.showVisitedMarkers();}
else if(type=='preferred'){this.markers=this.favouritesMarkers;this.showFavouritesMarkers();}
else if(type=='suggested'){this.markers=this.suggestedMarkers;this.showSuggestedMarkers();}}
PlacesMapHandler.prototype.showVisitedMarkers=function(){this.mgr.clearMarkers();this.mgr.addMarkers(this.visitedMarkers,0);this.mgr.refresh();}
PlacesMapHandler.prototype.showFavouritesMarkers=function(){this.mgr.clearMarkers();this.mgr.addMarkers(this.favouritesMarkers,0);this.mgr.refresh();}
PlacesMapHandler.prototype.showSuggestedMarkers=function(){this.mgr.clearMarkers();this.mgr.addMarkers(this.suggestedMarkers,0);this.mgr.refresh();}
AddressMapHandler.prototype=new GenericMapHandler();function AddressMapHandler(defaultErrorText,addressNotFoundErrorText,outOfCountryErrorText,canvasId,baseUrl,zoomLevel,largeControl,iconType,iconPreferredPath,input,selectedNationField,selectedDistrictField,selectedProvinceField,selectedCityField,selectedLatitudeField,selectedLongitudeField,selectedSouthField,selectedEastField,selectedNorthField,selectedWestField,waitingPanelId){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl,true);this.addressNotFoundErrorText=addressNotFoundErrorText;this.outOfCountryErrorText=outOfCountryErrorText;this.clickHandler=null;this.baseUrl=baseUrl;this.geocoder=new google.maps.ClientGeocoder();this.iconType=iconType;this.iconPreferredPath=iconPreferredPath;this.input_field=$(input);this.nation_field=$(selectedNationField);this.district_field=$(selectedDistrictField);this.province_field=$(selectedProvinceField);this.city_field=$(selectedCityField);this.latitude_field=$(selectedLatitudeField);this.longitude_field=$(selectedLongitudeField);this.south_field=$(selectedSouthField);this.east_field=$(selectedEastField);this.north_field=$(selectedNorthField);this.west_field=$(selectedWestField);this.waitingPanel=$(waitingPanelId);this.resetFields(true);}
AddressMapHandler.prototype.getIcon=function(){var customIcon=null;switch(this.iconType){case'visitati':customIcon=new google.maps.Icon();customIcon.shadow=this.iconPreferredPath+'/images/ombra-visitati.png';customIcon.image=this.iconPreferredPath+"/images/flagvisitati.png";customIcon.iconSize=new GSize(33,34);customIcon.shadowSize=new GSize(48,34);customIcon.iconAnchor=new GPoint(3,33);customIcon.infoWindowAnchor=new GPoint(31,4);default:break;}
return customIcon;}
AddressMapHandler.prototype.showError=function(errorMessage){var gs=new GeneralScript();if(this.waitingPanel)gs.hideComponent(this.waitingPanel);gs.showErrorMessage(errorMessage);}
AddressMapHandler.prototype.AddressToMap=function(response){this.resetFields(false);if(!response||response.Status.code!=200){this.showError(this.addressNotFoundErrorText);}else{try{var place=null;var point=null;var countryCode=null;for(var i=0;i<response.Placemark.length;i++){if("IT"==countryCode){break;}
place=null;point=null;countryCode=null;try{place=response.Placemark[i];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);countryCode=place.AddressDetails.Country.CountryNameCode;}catch(e){}}
if(countryCode==null){throw"No country code";}
if(countryCode!="IT"){this.showError(this.outOfCountryErrorText);}else{try{var south=place.ExtendedData.LatLonBox.south;var east=place.ExtendedData.LatLonBox.east;var north=place.ExtendedData.LatLonBox.north;var west=place.ExtendedData.LatLonBox.west;var bounds=new GLatLngBounds(new GLatLng(south,west),new GLatLng(north,east));this.map.setCenter(bounds.getCenter(),this.map.getBoundsZoomLevel(bounds));this.south_field.setValue(south);this.east_field.setValue(east);this.north_field.setValue(north);this.west_field.setValue(west);}catch(e){this.map.setCenter(point);}
var location=place.address;var country='';try{country=place.AddressDetails.Country.CountryNameCode;}catch(e){}
var region='';try{region=place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;}catch(e){}
var prov='';try{prov=place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;}catch(e){}
var locality='';try{locality=place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;}catch(e){}
var params={'country':country,'region':region,'prov':prov,'locality':locality};var me=this;AjaxRequest(this.baseUrl+'?page=AjaxDispatcher&class=map&method=placesToIds',{parameters:params,onSuccess:function(transport){me.updatePlaceFields(transport);},onFailure:function(){me.showError(me.defaultErrorText);}});this.input_field.setValue(location);this.latitude_field.setValue(place.Point.coordinates[1]);this.longitude_field.setValue(place.Point.coordinates[0]);var opts={title:location.replace(/(<([^>]+)>)/ig,""),icon:this.getIcon()};var marker=new PhotoMapMarker(this.defaultErrorText,'',{'location':location,'lat':place.Point.coordinates[1],'lng':place.Point.coordinates[0]},opts);this.mgr.addMarker(marker,0);this.mgr.refresh();setTimeout(function(){marker.showPopup();},10);}}catch(e){this.showError(this.addressNotFoundErrorText);}}}
AddressMapHandler.prototype.ClickToMap=function(response){this.resetFields(false);if(!response||response.Status.code!=200){this.showError(this.addressNotFoundErrorText);}else{var place=response.Placemark[0];var point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);var countryCode=place.AddressDetails.Country.CountryNameCode;if(countryCode!="IT"){this.showError(this.outOfCountryErrorText);}else{try{var south=place.ExtendedData.LatLonBox.south;var east=place.ExtendedData.LatLonBox.east;var north=place.ExtendedData.LatLonBox.north;var west=place.ExtendedData.LatLonBox.west;this.south_field.setValue(south);this.east_field.setValue(east);this.north_field.setValue(north);this.west_field.setValue(west);}catch(e){}
var location=place.address;var country=-1;try{country=place.AddressDetails.Country.CountryNameCode;}catch(e){}
var region=-1;try{region=place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;}catch(e){}
var prov=-1;try{prov=place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;}catch(e){}
var locality=-1;try{locality=place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;}catch(e){}
var params={'country':country,'region':region,'prov':prov,'locality':locality};var me=this;AjaxRequest(this.baseUrl+'?page=AjaxDispatcher&class=map&method=placesToIds',{parameters:params,onSuccess:function(transport){me.updatePlaceFields(transport);},onFailure:function(){me.showError(me.defaultErrorText);}});this.input_field.setValue(location);this.latitude_field.setValue(place.Point.coordinates[1]);this.longitude_field.setValue(place.Point.coordinates[0]);var opts={title:location.replace(/(<([^>]+)>)/ig,""),icon:this.getIcon()};var marker=new PhotoMapMarker(this.defaultErrorText,'',{'location':location,'lat':place.Point.coordinates[1],'lng':place.Point.coordinates[0]},opts);this.mgr.addMarker(marker,0);this.mgr.refresh();setTimeout(function(){marker.showPopup();},10);}}}
AddressMapHandler.prototype.showLocation=function(){var address=this.input_field.getValue();if(address){var me=this;if(this.waitingPanel)new GeneralScript().showComponent(this.waitingPanel);this.geocoder.getLocations(address,function(response){me.AddressToMap(response);});}}
AddressMapHandler.prototype.findLocation=function(address){this.input_field.setValue(address);this.showLocation();}
AddressMapHandler.prototype.redraw=function(address){this.resetFields(true);}
AddressMapHandler.prototype.resetFields=function(recenter){if(this.waitingPanel)new GeneralScript().hideComponent(this.waitingPanel);this.mgr.clearMarkers();this.input_field.disabled=false;this.resetValues(true);if(recenter){this.map.checkResize();this.map.setCenter(RomePosition,this.defaultZoomLevel);}
try{this.input_field.focus();}catch(e){}
var me=this;if(this.clickHandler==null){this.clickHandler=GEvent.addListener(this.map,"click",function(overlay,latlng){if(latlng){new GeneralScript().showComponent(me.waitingPanel);me.geocoder.getLocations(latlng,function(response){me.ClickToMap(response);});}});}}
AddressMapHandler.prototype.restoreFields=function(){try{this.nation_field.value=this.nation_field.old_value;this.district_field.value=this.district_field.old_value;this.province_field.value=this.province_field.old_value;this.city_field.value=this.city_field.old_value;this.latitude_field.value=this.latitude_field.old_value;this.longitude_field.value=this.longitude_field.old_value;this.south_field.value=this.south_field.old_value;this.east_field.value=this.east_field.old_value;this.north_field.value=this.north_field.old_value;this.west_field.value=this.west_field.old_value;this.input_field.value=this.input_field.old_value;}catch(e){}}
AddressMapHandler.prototype.resetValues=function(resetText){this.nation_field.old_value=this.nation_field.value;this.district_field.old_value=this.district_field.value;this.province_field.old_value=this.province_field.value;this.city_field.old_value=this.city_field.value;this.latitude_field.old_value=this.latitude_field.value;this.longitude_field.old_value=this.longitude_field.value;this.south_field.old_value=this.south_field.value;this.east_field.old_value=this.east_field.value;this.north_field.old_value=this.north_field.value;this.west_field.old_value=this.west_field.value;this.input_field.old_value=this.input_field.value;this.nation_field.setValue('-1');this.district_field.setValue('-1');this.province_field.setValue('-1');this.city_field.setValue('-1');this.latitude_field.setValue('-1');this.longitude_field.setValue('-1');this.south_field.setValue('-1');this.east_field.setValue('-1');this.north_field.setValue('-1');this.west_field.setValue('-1');if(resetText){this.input_field.setValue('');}}
AddressMapHandler.prototype.updatePlaceFields=function(transport){if(this.waitingPanel)new GeneralScript().hideComponent(this.waitingPanel);var jsonText=transport.responseText;eval('jsonResp = '+jsonText);if(jsonResp.code==200){this.nation_field.setValue(jsonResp.country);this.district_field.setValue(jsonResp.region);this.province_field.setValue(jsonResp.prov);this.city_field.setValue(jsonResp.locality);}
else{this.nation_field.setValue(-1);this.district_field.setValue(-1);this.province_field.setValue(-1);this.city_field.setValue(-1);if(jsonResp.msg){this.showError(jsonResp.msg);}
else{this.showError(this.defaultErrorText);}}}
AddressMapHandler.prototype.setInfo=function(details,showPopup){this.resetFields(false);if(!details.editable){this.input_field.onblur=null;this.input_field.disabled=true;if(this.clickHandler)GEvent.removeListener(this.clickHandler);this.clickHandler=null;}
this.input_field.setValue(details.label);this.district_field.setValue(details.location[0]);this.province_field.setValue(details.location[1]);this.city_field.setValue(details.location[2]);this.latitude_field.setValue(details.latlng[0]);this.longitude_field.setValue(details.latlng[1]);this.south_field.setValue(details.bb[0]);this.east_field.setValue(details.bb[1]);this.north_field.setValue(details.bb[2]);this.west_field.setValue(details.bb[3]);var bounds=new GLatLngBounds(new GLatLng(details.bb[0],details.bb[3]),new GLatLng(details.bb[2],details.bb[1]));opts={'title':details.label.replace(/(<([^>]+)>)/ig,""),'icon':this.getIcon()};var marker=new PhotoMapMarker(this.defaultErrorText,'',{'location':details.label,'lat':details.latlng[0],'lng':details.latlng[1]},opts);this.mgr.addMarker(marker,0);this.mgr.refresh();if(showPopup)setTimeout(function(){marker.showPopup();},100);this.map.setCenter(marker.getLatLng(),this.map.getBoundsZoomLevel(bounds));}
TravelBlogMapHandler.prototype=new GenericMapHandler();function TravelBlogMapHandler(texts,labels,canvasId,zoomLevel,largeControl,preferredIconPath,url){CallParentConstructor(this,GenericMapHandler,texts.defaultErrorText,canvasId,zoomLevel,largeControl);this.texts=texts;this.labels=labels;this.preferredIconPath=preferredIconPath;this.markers=new Array();this.backupMarkers=new Array();this.baseUrl=url;$(this.canvasId).mapHandler=this;}
TravelBlogMapHandler.prototype.setMarkers=function(markers){var markersArray=new Array();this.orderedMarkers=new Array();this.backupMarkers=markers;var current=null;for(var i=0,l=markers.length;i<l;i++){var opts={title:markers[i].location};if(this.preferredIconPath){var customIcon=null;var selectedIcon=null;if(markers[i].current){customIcon=new google.maps.Icon();customIcon.shadow=this.preferredIconPath+"/images/ombra-preferiti.png";customIcon.image=this.preferredIconPath+"/images/preferred.png";customIcon.iconSize=new GSize(32,32);customIcon.shadowSize=new GSize(36,32);customIcon.iconAnchor=new GPoint(3,33);customIcon.infoWindowAnchor=new GPoint(31,4);opts={'title':markers[i].location.replace(/(<([^>]+)>)/ig,""),'icon':customIcon};selectedIcon="/images/preferred-over.png";}
else{customIcon=new google.maps.Icon();customIcon.shadow=this.preferredIconPath+"/images/ombra-visitati.png";customIcon.image=this.preferredIconPath+"/images/flagvisitati.png";customIcon.iconSize=new GSize(33,34);customIcon.shadowSize=new GSize(48,34);customIcon.iconAnchor=new GPoint(3,33);customIcon.infoWindowAnchor=new GPoint(31,4);opts={'title':markers[i].location.replace(/(<([^>]+)>)/ig,""),'icon':customIcon};selectedIcon="/images/flagvisitati-over.png";}}
var marker=new TravelBlogMarker(this.preferredIconPath,this,this.canvasId,this.texts.defaultErrorText,this.labels,markers[i],selectedIcon,opts);this.orderedMarkers.push(marker);markersArray.push(marker);if(markers[i].current){current=marker;}}
this.markers=markersArray;this.mgr.clearMarkers();this.map.clearOverlays();this.createPolyline();var ms=new MarkerSpreader(this.map);this.markers=ms.spreadMarkers(markersArray);if(this.markers.length!=0){this.mgr.addMarkers(this.markers,0);var bb=this.getBB();this.map.setCenter(bb.getCenter(),Math.max(this.map.getBoundsZoomLevel(bb),5));this.mgr.refresh();}
if(current)setTimeout(function(){current.showPopup();},10);}
TravelBlogMapHandler.prototype.createPolyline=function(){var points=new Array();for(var i=0;i<this.markers.length;i++){points.push(this.markers[i].getLatLng());}
var polyline=new google.maps.Polyline(points,"#cc0000",4);this.map.addOverlay(polyline);}
TravelBlogMapHandler.prototype.getBB=function(){var o=this.markers[0].getLatLng().lng();var e=this.markers[0].getLatLng().lng();var n=this.markers[0].getLatLng().lat();var s=this.markers[0].getLatLng().lat();for(var i=1;i<this.markers.length;i++){if(this.markers[i].getLatLng().lat()<s)s=this.markers[i].getLatLng().lat();if(this.markers[i].getLatLng().lat()>n)n=this.markers[i].getLatLng().lat();if(this.markers[i].getLatLng().lng()<o)o=this.markers[i].getLatLng().lng();if(this.markers[i].getLatLng().lng()>e)e=this.markers[i].getLatLng().lng();}
return new google.maps.LatLngBounds(new google.maps.LatLng(s,o),new google.maps.LatLng(n,e));}
TravelBlogMapHandler.prototype.updateMap=function(nid,index){var params={'nid':nid,'index':index};var me=this;AjaxRequest(this.baseUrl+"?page=AjaxDispatcher&class=travelblog&method=reloadmap",{parameters:params,onSuccess:function(transport){var jsonText=transport.responseText;eval('jsonResp = '+jsonText);if(jsonResp.code==200){me.setMarkers(jsonResp.data);}
else{me.showError(this.defaultErrorText);}},onFailure:function(){me.showError(this.defaultErrorText);}});}
TravelBlogMapHandler.prototype.showError=function(errorMessage){var gs=new GeneralScript();if(this.waitingPanel)gs.hideComponent(this.waitingPanel);gs.showErrorMessage(errorMessage);}
TravelBlogMapHandler.prototype.showStop=function(index){var bm=this.backupMarkers;for(var i=0;i<bm.length;i++){bm[i].current=false;}
if(index<bm.length){bm[index].current=true;this.setMarkers(bm);}else{this.setMarkers(bm);var bb=this.getBB();this.map.setZoom(Math.max(this.map.getBoundsZoomLevel(bb)-1,5));this.map.panTo(bb.getCenter());}};
AdvicesMapHandler.prototype=new GenericMapHandler();function AdvicesMapHandler(defaultErrorText,canvasId,zoomLevel,largeControl,baseUrl,iconsPath,scrollToID,labels,avoidShowLink){CallParentConstructor(this,GenericMapHandler,defaultErrorText,canvasId,zoomLevel,largeControl,false);this.baseUrl=baseUrl;this.iconsPath=iconsPath;this.scrollToID=scrollToID;this.labels=labels;this.avoidShowLink=avoidShowLink;this.markers=new Array();$(canvasId).mapHandler=this;}
AdvicesMapHandler.prototype.update=function(){}
AdvicesMapHandler.prototype.getIcon=function(){return null;}
AdvicesMapHandler.prototype.setMarkers=function(markersInfo,avoidRecenter){this.reset();var markers=new Array();for(var i=0;i<markersInfo.length;i++){var info=markersInfo[i];var customIcon=new google.maps.Icon();customIcon.shadow=this.iconsPath+"/images/icon-consigli-ombra.png";customIcon.image=this.iconsPath+"/images/icon-"+info.type+"-map.png";customIcon.iconSize=new GSize(34,38);customIcon.shadowSize=new GSize(50,38);customIcon.iconAnchor=new GPoint(2,38);customIcon.infoWindowAnchor=new GPoint(32,1);var opts={title:info.title,icon:customIcon};var marker=new AdviceMarker(this.defaultErrorText,info,opts,true,this.labels,this.avoidShowLink);markers.push(marker);}
if(markers.length!=0){var ms=new MarkerSpreader(this.map);var markersArray=ms.spreadMarkers(markers);if(!avoidRecenter){var bb=this.getBB(markersArray);this.map.setZoom(Math.max(this.map.getBoundsZoomLevel(bb)-1,5));this.map.panTo(bb.getCenter());}
this.markers=markersArray;this.mgr.addMarkers(markersArray,0);this.mgr.refresh();}}
AdvicesMapHandler.prototype.getBB=function(markers){var o=markers[0].getLatLng().lng();var e=markers[0].getLatLng().lng();var n=markers[0].getLatLng().lat();var s=markers[0].getLatLng().lat();for(var i=1;i<markers.length;i++){if(markers[i].getLatLng().lat()<s)s=markers[i].getLatLng().lat();if(markers[i].getLatLng().lat()>n)n=markers[i].getLatLng().lat();if(markers[i].getLatLng().lng()<o)o=markers[i].getLatLng().lng();if(markers[i].getLatLng().lng()>e)e=markers[i].getLatLng().lng();}
return new google.maps.LatLngBounds(new google.maps.LatLng(s,o),new google.maps.LatLng(n,e));}
AdvicesMapHandler.prototype.setLocation=function(lat,lng,south,east,north,west,text,avoidPopup,scrollAfterMarker){var bounds=new google.maps.LatLngBounds(new google.maps.LatLng(south,west),new google.maps.LatLng(north,east));var point=new google.maps.LatLng(lat,lng);var zoom=this.map.getBoundsZoomLevel(bounds)+1;this.map.setCenter(point,zoom);if(text){setTimeout(function(){marker.showPopup()},10);}
if(scrollAfterMarker&&this.scrollToID&&$(this.scrollToID).viewportOffset().top<0){Effect.ScrollTo(this.scrollToID,{offset:0});}}
AdvicesMapHandler.prototype.relocate=function(locationObj){if($(locationObj.district).value<0&&$(locationObj.district).value<0&&$(locationObj.city).value<0){this.map.setCenter(RomePosition,this.defaultZoomLevel);}
else{if($(locationObj.province).value==-1||$(locationObj.city).value!=-1){this.setLocation($(locationObj.latitude).value,$(locationObj.longitude).value,$(locationObj.south).value,$(locationObj.east).value,$(locationObj.north).value,$(locationObj.west).value,null,true);}}}
AdvicesMapHandler.prototype.showMarker=function(nid){for(var i=0;i<this.markers.length;i++){var marker=this.markers[i];var info=marker.getMarkerInfo();if(info.nid==nid){var bb=new google.maps.LatLngBounds(new google.maps.LatLng(info.bb[0],info.bb[3]),new google.maps.LatLng(info.bb[2],info.bb[1]));var zoom=Math.max(this.map.getBoundsZoomLevel(bb),10);this.map.setCenter(marker.getLatLng(),zoom);if($(this.scrollToID).viewportOffset().top<0){Effect.ScrollTo(this.scrollToID,{offset:0});}
setTimeout(function(){marker.showPopup()},10);return;}}};
function WizardWidget(){this.onLeaveListeners=new Array();this.onEnterListeners=new Array();this.currentPanel=0;this.panels=new Array();for(var i=0;i<arguments.length;i++){this.panels.push(arguments[i]);}}
WizardWidget.prototype.clearPreListeners=function(){this.onLeaveListeners=new Array();}
WizardWidget.prototype.clearPostListeners=function(){this.onEnterListeners=new Array();}
WizardWidget.prototype.addOnLeaveListener=function(listener){this.onLeaveListeners.push(listener);}
WizardWidget.prototype.addOnEnterListener=function(listener){this.onEnterListeners.push(listener);}
WizardWidget.prototype.fireOnLeaveListeners=function(index){for(var i=0;i<this.onLeaveListeners.length;i++){try{if(!this.onLeaveListeners[i].onPanelLeave(index))
return false;}catch(e){return false;}}
return true;}
WizardWidget.prototype.fireOnEnterListeners=function(index){for(var i=0;i<this.onEnterListeners.length;i++){try{if(!this.onEnterListeners[i].onPanelEnter(index))
return false;}catch(e){return false;}}
return true;}
WizardWidget.prototype.showNext=function(){if(this.fireOnLeaveListeners(this.currentPanel)){if(this.currentPanel<(this.panels.length-1)){this.currentPanel++;}
new GeneralScript().showComponent(this.getCurrentPanel());new GeneralScript().hideComponent(this.getPanel(this.currentPanel-1));this.fireOnEnterListeners(this.currentPanel);}}
WizardWidget.prototype.showPrev=function(){if(this.fireOnLeaveListeners(this.currentPanel)){if(this.currentPanel>0){this.currentPanel--;}
new GeneralScript().showComponent(this.getCurrentPanel());new GeneralScript().hideComponent(this.getPanel(this.currentPanel+1));this.fireOnLeaveListeners(this.currentPanel);}}
WizardWidget.prototype.getCurrentPanel=function(){return $(this.panels[this.currentPanel]);}
WizardWidget.prototype.getPanel=function(index){return $(this.panels[index]);}
WizardWidget.prototype.init=function(){this.currentPanel=0;for(var i=0;i<this.panels.length;i++){new GeneralScript().hideComponent(this.getPanel(i));}
new GeneralScript().showComponent(this.getPanel(0));this.fireOnEnterListeners(this.currentPanel);};
(function(){function log(){if(typeof(console)!='undefined'&&typeof(console.log)=='function'){Array.prototype.unshift.call(arguments,'[Ajax Upload]');console.log(Array.prototype.join.call(arguments,' '));}}
function addEvent(el,type,fn){if(el.addEventListener){el.addEventListener(type,fn,false);}else if(el.attachEvent){el.attachEvent('on'+type,function(){fn.call(el);});}else{throw new Error('not supported or DOM not loaded');}}
function addResizeEvent(fn){var timeout;addEvent(window,'resize',function(){if(timeout){clearTimeout(timeout);}
timeout=setTimeout(fn,100);});}
if(document.documentElement.getBoundingClientRect){var getOffset=function(el){var box=el.getBoundingClientRect();var doc=el.ownerDocument;var body=doc.body;var docElem=doc.documentElement;var clientTop=docElem.clientTop||body.clientTop||0;var clientLeft=docElem.clientLeft||body.clientLeft||0;var zoom=1;if(body.getBoundingClientRect){var bound=body.getBoundingClientRect();zoom=(bound.right-bound.left)/body.clientWidth;}
if(zoom>1){clientTop=0;clientLeft=0;}
var top=box.top/zoom+(window.pageYOffset||docElem&&docElem.scrollTop/zoom||body.scrollTop/zoom)-clientTop,left=box.left/zoom+(window.pageXOffset||docElem&&docElem.scrollLeft/zoom||body.scrollLeft/zoom)-clientLeft;return{top:top,left:left};};}else{var getOffset=function(el){var top=0,left=0;do{top+=el.offsetTop||0;left+=el.offsetLeft||0;el=el.offsetParent;}while(el);return{left:left,top:top};};}
function getBox(el){var left,right,top,bottom;var offset=getOffset(el);left=offset.left;top=offset.top;right=left+el.offsetWidth;bottom=top+el.offsetHeight;return{left:left,right:right,top:top,bottom:bottom};}
function addStyles(el,styles){for(var name in styles){if(styles.hasOwnProperty(name)){el.style[name]=styles[name];}}}
function copyLayout(from,to){var box=getBox(from);addStyles(to,{position:'absolute',left:box.left+'px',top:box.top+'px',width:from.offsetWidth+'px',height:from.offsetHeight+'px'});}
var toElement=(function(){var div=document.createElement('div');return function(html){div.innerHTML=html;var el=div.firstChild;return div.removeChild(el);};})();var getUID=(function(){var id=0;return function(){return'ValumsAjaxUpload'+id++;};})();function fileFromPath(file){return file.replace(/.*(\/|\\)/,"");}
function getExt(file){return(-1!==file.indexOf('.'))?file.replace(/.*[.]/,''):'';}
function hasClass(el,name){var re=new RegExp('\\b'+name+'\\b');return re.test(el.className);}
function addClass(el,name){if(!hasClass(el,name)){el.className+=' '+name;}}
function removeClass(el,name){var re=new RegExp('\\b'+name+'\\b');el.className=el.className.replace(re,'');}
function removeNode(el){el.parentNode.removeChild(el);}
window.AjaxUpload=function(button,options){this._settings={action:'upload.php',name:'userfile',data:{},autoSubmit:true,responseType:false,hoverClass:'hover',disabledClass:'disabled',onChange:function(file,extension){},onSubmit:function(file,extension){},onComplete:function(file,response){}};for(var i in options){if(options.hasOwnProperty(i)){this._settings[i]=options[i];}}
if(button.jquery){button=button[0];}else if(typeof button=="string"){if(/^#.*/.test(button)){button=button.slice(1);}
button=document.getElementById(button);}
if(!button||button.nodeType!==1){throw new Error("Please make sure that you're passing a valid element");}
if(button.nodeName.toUpperCase()=='A'){addEvent(button,'click',function(e){if(e&&e.preventDefault){e.preventDefault();}else if(window.event){window.event.returnValue=false;}});}
this._button=button;this._input=null;this._disabled=false;this.enable();this._rerouteClicks();};AjaxUpload.prototype={setData:function(data){this._settings.data=data;},disable:function(){addClass(this._button,this._settings.disabledClass);this._disabled=true;var nodeName=this._button.nodeName.toUpperCase();if(nodeName=='INPUT'||nodeName=='BUTTON'){this._button.setAttribute('disabled','disabled');}
if(this._input){this._input.parentNode.style.visibility='hidden';}},enable:function(){removeClass(this._button,this._settings.disabledClass);this._button.removeAttribute('disabled');this._disabled=false;},_createInput:function(){var self=this;var input=document.createElement("input");input.setAttribute('type','file');input.setAttribute('name',this._settings.name);addStyles(input,{'position':'absolute','right':0,'margin':0,'padding':0,'fontSize':'480px','cursor':'pointer'});var div=document.createElement("div");addStyles(div,{'display':'block','position':'absolute','overflow':'hidden','margin':0,'padding':0,'opacity':0,'direction':'ltr','zIndex':2147483583});if(div.style.opacity!=="0"){if(typeof(div.filters)=='undefined'){throw new Error('Opacity not supported by the browser');}
div.style.filter="alpha(opacity=0)";}
addEvent(input,'change',function(){if(!input||input.value===''){return;}
var file=fileFromPath(input.value);if(false===self._settings.onChange.call(self,file,getExt(file))){self._clearInput();return;}
if(self._settings.autoSubmit){self.submit();}});addEvent(input,'mouseover',function(){addClass(self._button,self._settings.hoverClass);});addEvent(input,'mouseout',function(){removeClass(self._button,self._settings.hoverClass);input.parentNode.style.visibility='hidden';});div.appendChild(input);document.body.appendChild(div);this._input=input;},_clearInput:function(){if(!this._input){return;}
removeNode(this._input.parentNode);this._input=null;this._createInput();removeClass(this._button,this._settings.hoverClass);},_rerouteClicks:function(){var self=this;addEvent(self._button,'mouseover',function(){if(self._disabled){return;}
if(!self._input){self._createInput();}
var div=self._input.parentNode;copyLayout(self._button,div);div.style.visibility='visible';});},_createIframe:function(){var id=getUID();var iframe=toElement('<iframe src="javascript:false;" name="'+id+'" />');iframe.setAttribute('id',id);iframe.style.display='none';document.body.appendChild(iframe);return iframe;},_createForm:function(iframe){var settings=this._settings;var form=toElement('<form method="post" enctype="multipart/form-data"></form>');form.setAttribute('action',settings.action);form.setAttribute('target',iframe.name);form.style.display='none';document.body.appendChild(form);for(var prop in settings.data){if(settings.data.hasOwnProperty(prop)){var el=document.createElement("input");el.setAttribute('type','hidden');el.setAttribute('name',prop);el.setAttribute('value',settings.data[prop]);form.appendChild(el);}}
return form;},_getResponse:function(iframe,file){var toDeleteFlag=false,self=this,settings=this._settings;addEvent(iframe,'load',function(){if(iframe.src=="javascript:'%3Chtml%3E%3C/html%3E';"||iframe.src=="javascript:'<html></html>';"){if(toDeleteFlag){setTimeout(function(){removeNode(iframe);},0);}
return;}
var doc=iframe.contentDocument?iframe.contentDocument:window.frames[iframe.id].document;if(doc.readyState&&doc.readyState!='complete'){return;}
if(doc.body&&doc.body.innerHTML=="false"){return;}
var response;if(doc.XMLDocument){response=doc.XMLDocument;}else if(doc.body){response=doc.body.innerHTML;if(settings.responseType&&settings.responseType.toLowerCase()=='json'){if(doc.body.firstChild&&doc.body.firstChild.nodeName.toUpperCase()=='PRE'){response=doc.body.firstChild.firstChild.nodeValue;}
if(response){response=eval("("+response+")");}else{response={};}}}else{response=doc;}
settings.onComplete.call(self,file,response);toDeleteFlag=true;iframe.src="javascript:'<html></html>';";});},submit:function(){var self=this,settings=this._settings;if(!this._input||this._input.value===''){return;}
var file=fileFromPath(this._input.value);if(false===settings.onSubmit.call(this,file,getExt(file))){this._clearInput();return;}
var iframe=this._createIframe();var form=this._createForm(iframe);removeNode(this._input.parentNode);removeClass(self._button,self._settings.hoverClass);form.appendChild(this._input);form.submit();removeNode(form);form=null;removeNode(this._input);this._input=null;this._getResponse(iframe,file);this._createInput();}};})();
var popupManager={};popupManager.constants={'darkCover':'popupManager_darkCover_div','darkCoverStyle':['position:fixed;','top:0px;','left:0px;','padding-right:0px;','padding-bottom:0px;','background-color:#000000;','opacity:0.5;','-moz-opacity:0.5;','filter:alpha(opacity=0.5);','z-index:10000;','width:100%;','height:100%;'].join(''),'openidSpec':{'identifier_select':'http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select','namespace2':'http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0'}};popupManager.getWindowInnerSize=function(){var width=0;var height=0;var elem=null;if('innerWidth'in window){width=window.innerWidth;height=window.innerHeight;}else{if(('BackCompat'===window.document.compatMode)&&('body'in window.document)){elem=window.document.body;}else if('documentElement'in window.document){elem=window.document.documentElement;}
if(elem!==null){width=elem.offsetWidth;height=elem.offsetHeight;}}
return[width,height];};popupManager.getParentCoords=function(){var width=0;var height=0;if('screenLeft'in window){width=window.screenLeft;height=window.screenTop;}else if('screenX'in window){width=window.screenX;height=window.screenY;}
return[width,height];};popupManager.getCenteredCoords=function(width,height){var parentSize=this.getWindowInnerSize();var parentPos=this.getParentCoords();var xPos=parentPos[0]+
Math.max(0,Math.floor((parentSize[0]-width)/2));var yPos=parentPos[1]+
Math.max(0,Math.floor((parentSize[1]-height)/2));return[xPos,yPos];};popupManager.darkenScreen=function(){var darkCover=window.document.getElementById(window.popupManager.constants['darkCover']);if(!darkCover){darkCover=window.document.createElement('div');darkCover['id']=window.popupManager.constants['darkCover'];darkCover.setAttribute('style',window.popupManager.constants['darkCoverStyle']);window.document.body.appendChild(darkCover);}
darkCover.style.display='block';var abc=0;};popupManager.createPopupOpener=(function(openidParams){var interval_=null;var popupWindow_=null;var that=this;var shouldEscape_=('shouldEncodeUrls'in openidParams)?openidParams.shouldEncodeUrls:true;var encodeIfRequested_=function(url){return(shouldEscape_?encodeURIComponent(url):url);};var identifier_=('identifier'in openidParams)?encodeIfRequested_(openidParams.identifier):this.constants.openidSpec.identifier_select;var identity_=('identity'in openidParams)?encodeIfRequested_(openidParams.identity):this.constants.openidSpec.identifier_select;var openidNs_=('namespace'in openidParams)?encodeIfRequested_(openidParams.namespace):this.constants.openidSpec.namespace2;var onOpenHandler_=(('onOpenHandler'in openidParams)&&('function'===typeof(openidParams.onOpenHandler)))?openidParams.onOpenHandler:this.darkenScreen;var onCloseHandler_=(('onCloseHandler'in openidParams)&&('function'===typeof(openidParams.onCloseHandler)))?openidParams.onCloseHandler:null;var onFailureHandler_=(('onFailureHandler'in openidParams)&&('function'===typeof(openidParams.onFailureHandler)))?openidParams.onFailureHandler:null;var urlToOpen_=('urlToOpen'in openidParams)?openidParams.urlToOpen:null;var returnToUrl_=('returnToUrl'in openidParams)?openidParams.returnToUrl:null;var realm_=('realm'in openidParams)?openidParams.realm:null;var endpoint_=('opEndpoint'in openidParams)?openidParams.opEndpoint:null;var extensions_=('extensions'in openidParams)?openidParams.extensions:null;var keyValueConcat_=function(keyValuePairs){var result="";for(key in keyValuePairs){result+=['&',key,'=',encodeIfRequested_(keyValuePairs[key])].join('');}
return result;};var buildUrlToOpen_=function(){if(urlToOpen_){return urlToOpen_}
else{var connector='&';var encodedUrl=null;var urlToOpen=null;if((null===endpoint_)||(null===returnToUrl_)){return null;}
if(endpoint_.indexOf('?')===-1){connector='?';}
encodedUrl=encodeIfRequested_(returnToUrl_);urlToOpen=[endpoint_,connector,'openid.ns=',openidNs_,'&openid.mode=checkid_setup','&openid.claimed_id=',identifier_,'&openid.identity=',identity_,'&openid.return_to=',encodedUrl].join('');if(realm_!==null){urlToOpen+="&openid.realm="+encodeIfRequested_(realm_);}
if(extensions_!==null){urlToOpen+=keyValueConcat_(extensions_);}
urlToOpen+='&openid.ns.ui='+encodeURIComponent('http://specs.openid.net/extensions/ui/1.0');urlToOpen+='&openid.ui.mode=popup';return urlToOpen;}};var isPopupClosed_=function(){try{var nonPop=!popupWindow_;var closed=popupWindow_.closed;return(nonPop||closed);}catch(e){}};var waitForPopupClose_=function(){if(isPopupClosed_()){popupWindow_=null;var darkCover=window.document.getElementById(window.popupManager.constants['darkCover']);if(darkCover){darkCover.style.display='none';}
if(window.popupResult){if(onCloseHandler_!==null){onCloseHandler_();}}
else{if(onFailureHandler_!==null){onFailureHandler_();}}
if((null!==interval_)){window.clearInterval(interval_);interval_=null;}}};window.popupResult=false;return{popup:function(width,height){var urlToOpen=buildUrlToOpen_();if(onOpenHandler_!==null){onOpenHandler_();}
var coordinates=that.getCenteredCoords(width,height);popupWindow_=window.open(urlToOpen,"","width="+width+",height="+height+",status=1,location=1,resizable=yes"+",left="+coordinates[0]+",top="+coordinates[1]);interval_=window.setInterval(waitForPopupClose_,80);return true;}};});
function AjaxRequest(url,object){if(window.GUnload){var params="";if(object.parameters){for(var field in object.parameters){var value=object.parameters[field];if(typeof value!='function'){params+=field+"="+escape(value)+"&";}}
params=params.substr(0,params.length-1);}
if(params.length!=0){google.maps.DownloadUrl(url,function(data,responseCode){var response={'code':responseCode,'responseText':data};if(responseCode==200){if(object.onSuccess)
object.onSuccess(response);}
else{if(object.onFailure)
object.onFailure();}},params);}
else{google.maps.DownloadUrl(url,function(data,responseCode){var response={'code':responseCode,'responseText':data};if(responseCode==200){if(object.onSuccess)
object.onSuccess(response);}
else{if(object.onFailure)
object.onFailure();}});}}
else{if(!object.method){object.method='post';}
new Ajax.Request(url,object);}}
