
function AtlasMainMap(projectURL,mapCanvas)
{this.projectURL=projectURL;this.mapCanvas=mapCanvas;var _this=this;this.showWait();this.GoogleApiExtends();APIManager.addFunction(function(){new Ajax.Request(_this.projectURL+'ajax.get.php',{method:'get',parameters:{event:'LoadPolygonAndChilds',id:0},onSuccess:function(transport){try{_this.polygons=transport.responseText.evalJSON();}catch(e){}
_this.initMap();if(_this.polygons)
{_this.showPolygons();}}});});UnLoad.addFunction(function(){GUnload();});}
AtlasMainMap.prototype.showWait=function()
{$(this.mapCanvas).update('<div style="text-align: center; margin-top: 50px;"><b>Please Wait. Loading...</b></div> ');}
AtlasMainMap.prototype.initMap=function()
{this.map=new GMap2($(this.mapCanvas));this.map.addControl(new GLargeMapControl());this.map.addControl(new GMapTypeControl());this.map.enableScrollWheelZoom();this.map.setCenter(new GLatLng(0,0),1);}
AtlasMainMap.prototype.convertPointToLatLng=function(points)
{var LatLngPoints=[];for(var i=0;i<points.length;i++)
{LatLngPoints.push(new GLatLng(points[i].lat,points[i].lng));}
return LatLngPoints;}
AtlasMainMap.prototype.showPolygons=function()
{for(var i=0;i<this.polygons.childs.length;i++)
{this.showPolygon(this.polygons.childs[i]);}}
AtlasMainMap.prototype.showPolygon=function(pHash)
{try{var points=pHash.points.evalJSON();}catch(e){}
if(points)
{var polygon=new GPolygon(this.convertPointToLatLng(points),pHash.color,1,1,pHash.color,0.2);polygon.setHash({id:pHash.id,name:pHash.name,spotcount:pHash.spotcount,surfinginfo:pHash.surfinginfo,url:pHash.url});this.map.addOverlay(polygon);_this=this;GEvent.addListener(polygon,"click",function(point){pHash=this.getHash();redirect(_this.projectURL+'atlas/'+pHash.url+'.html');});}}
AtlasMainMap.prototype.GoogleApiExtends=function()
{GPolygon.prototype.setHash=function(hash)
{this.sfHash=hash;}
GPolygon.prototype.getHash=function()
{return this.sfHash;}}