
function AtlasContinentMap(projectURL,mapCanvas,polygon)
{this.projectURL=projectURL;this.mapCanvas=mapCanvas;this.polygon=polygon;this.allPoints=[];var _this=this;this.showWait();this.GoogleApiExtends();APIManager.addFunction(function(){new Ajax.Request(_this.projectURL+'ajax.get.php',{method:'get',parameters:{event:'LoadPolygonAndChilds',id:_this.polygon},onSuccess:function(transport){try{_this.polygons=transport.responseText.evalJSON();}catch(e){}
_this.initMap();if(_this.polygons)
{_this.showPolygons();}}});});UnLoad.addFunction(function(){GUnload();});}
AtlasContinentMap.prototype.showWait=function()
{$(this.mapCanvas).update('<div style="text-align: center; margin-top: 50px;"><b>Please Wait. Loading...</b></div> ');}
AtlasContinentMap.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);}
AtlasContinentMap.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;}
AtlasContinentMap.prototype.showPolygons=function()
{for(var i=0;i<this.polygons.childs.length;i++)
{this.showPolygon(this.polygons.childs[i]);}
var polyline=new GPolyline(this.convertPointToLatLng(this.allPoints));this.map.setCenter(polyline.getBounds().getCenter(),this.map.getBoundsZoomLevel(polyline.getBounds()));this.allPoints=[];}
AtlasContinentMap.prototype.showPolygon=function(pHash)
{try{var points=pHash.points.evalJSON();}catch(e){}
if(points)
{this.allPoints=this.allPoints.concat(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');});}}
AtlasContinentMap.prototype.GoogleApiExtends=function()
{GPolygon.prototype.setHash=function(hash)
{this.sfHash=hash;}
GPolygon.prototype.getHash=function()
{return this.sfHash;}}