/**
* Google Maps Samples
* Copyright (c) 2006-2007, Mashup Technologies, LLC
* All rights reserved.
* http://www.mashuptechnologies.com
* 
* The JavaScript code distributed with Google Maps Samples (the "Software") is licensed under the
* Lesser GNU (LGPL) open source license version 3.
* 
* http://www.gnu.org/licenses/lgpl.html
* 
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*/
Function.prototype.bind=function(object){var __method=this;return function(){__method.apply(object,arguments);}}
var mapApp={map:null,mapZoom:11,polygons:[],init:function(){if(GBrowserIsCompatible()){this.map=new GMap2(document.getElementById("mapContainer"));this.map.setCenter(new GLatLng(34.21,-77.88),this.mapZoom);this.map.addControl(new GLargeMapControl());}
else{}},drowCircle:function(lat,lon,opt){var polyRadius=opt&&opt.radius||50;var strokeColor=opt&&opt.strokeColor||"#CCCCCC";var strokeWeight=opt&&opt.strokeWeight||2;var strokeOpacity=opt&&opt.strokeOpacity||0.5;var fillColor=opt&&opt.fillColor||"#FFCCCC";var fillOpacity=opt&&opt.fillOpacity||0.5;var id=opt&&opt.id||null;var mapNormalProj=G_NORMAL_MAP.getProjection();var geoPoint=new GLatLng(lat,lon);var pointPixel=mapNormalProj.fromLatLngToPixel(geoPoint,this.mapZoom);var polyPoints=[];var polyNumSides=40;var polySideLength=9;for(var a=0;a<(polyNumSides+1);a++){var aRad=polySideLength*a*(Math.PI/180);var pixelX=pointPixel.x+polyRadius*Math.cos(aRad);var pixelY=pointPixel.y+polyRadius*Math.sin(aRad);var polyPixel=new GPoint(pixelX,pixelY);var polyPoint=mapNormalProj.fromPixelToLatLng(polyPixel,this.mapZoom);polyPoints.push(polyPoint);}
var polygon=new GPolygon(polyPoints,strokeColor,strokeWeight,strokeOpacity,fillColor,fillOpacity);polygon.customID=id;this.polygons.push(polygon);this.map.addOverlay(polygon);},findPolygon:function(point){for(i=0;i<this.polygons.length;i++){if(this.polygons[i].Contains(point))return this.polygons[i].customID;}
return null;},navigateToPolygon:function(id){for(i=0;i<this.polygons.length;i++){if(this.polygons[i].customID==id){if(this.polygons[i].center!=null){this.map.setCenter(new GLatLng(this.polygons[i].center[0],this.polygons[i].center[1]));}{this.map.setCenter(this.polygons[i].getVertex(0));}
break;}}}}
GPolygon.prototype.Contains=function(point){var j=0;var oddNodes=false;var x=point.lng();var y=point.lat();var vertexCount=this.getVertexCount();for(var i=0;i<vertexCount;i++){j++;if(j==vertexCount){j=0;}
if(((this.getVertex(i).lat()<y)&&(this.getVertex(j).lat()>=y))||((this.getVertex(j).lat()<y)&&(this.getVertex(i).lat()>=y))){if(this.getVertex(i).lng()+(y-this.getVertex(i).lat())/(this.getVertex(j).lat()-this.getVertex(i).lat())*(this.getVertex(j).lng()-this.getVertex(i).lng())<x){oddNodes=!oddNodes}}}
return oddNodes;}
GPolyline.prototype.Contains=GPolygon.prototype.Contains;
