var geocoder;
var map;
var bounds;
var home_record_string;
var infowindowLevel = 0;
var cm_openInfowindow;
var default_zoomLevel=17;
var infowindow;
var lat=34.3656591;
var lng=-89.5332313;
var mapMarkers=[];
var mapHTMLS=[];
var overlay;
USGSOverlay.prototype = new google.maps.OverlayView();

function mapinitialize()
{
	var myLatlng = new google.maps.LatLng(lat,lng);
	var myOptions = {
	 zoom: default_zoomLevel,
	 center: myLatlng,
	  mapTypeControl: false,
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.ANDROID},
      mapTypeId: google.maps.MapTypeId.ROADMAP 
	};
	return  new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

function initialize(userid) {
	 
	var flag=1;
	var myLatlng = new google.maps.LatLng(lat,lng);
	var prv_center=myLatlng;
	 
	var map = mapinitialize(myLatlng);
	
	mapoverlay(map,default_zoomLevel);
	treemarker(map);
	
	for(i=0;i<tentarray.length;i++)
	{
		commonmarker(map,userid,i);	
		if(tentarray[i][9]==userid)
		{
			flag=0;
		}
	}
	
	if(flag && userid>0 && document.getElementById('TentDrag').value==1)
	{
		 loginusermarker(map)
	}
	
	google.maps.event.addListener(map, 'zoom_changed', function() {
		var current_zoomLevel = map.getZoom();
		//overlay.onRemove();
		overlay.onRemove();
		mapoverlay(map,current_zoomLevel);
		if(default_zoomLevel>current_zoomLevel){
			map.setZoom(default_zoomLevel);
		}
	});

	google.maps.event.addListener(map, 'drag', function() {
		  var ri_distance=map.getZoom();
			if(getDistace(map.getCenter().lat(),map.getCenter().lng(),myLatlng.lat(),myLatlng.lng())>ri_distance)
			{
				map.setCenter(prv_center);
			}
		prv_center=map.getCenter();
	});
	
	google.maps.event.addListener(map, 'tilesloaded', function() {							
     document.getElementById("searchid").style.display = '';
    });

	
}
function createInfowindow(tentname,hometown,desc,username,url)
{ 
	var contentString="<div id='mapcontent'><a href='"+webURL+"/tents/index/"+url+"' class='tentpagelink'>"+username+map_errors.vars.map_tent+"</a><br>";
	contentString=contentString+"<b>"+map_errors.vars.map_tent_name+"</b> <label>"+	tentname +"</label><br>";
	contentString=contentString+"<b>"+map_errors.vars.map_hometown+"</b> <label>"+	hometown +"</label><br>";
	contentString=contentString+"<b style='width:200px'>"+map_errors.vars.map_description+" </b>"+ trim(desc)+".. <a href='"+webURL+"/tents/index/"+url+"' class='tentpagelink'>"+map_errors.vars.map_moreinfo+"</a></div>";
	
	return  new google.maps.InfoWindow({
			content:contentString,
			maxWidth:200
		});		
}
function commonmarker(map,userid,i)
{
		var lng=tentarray[i][7];
		var lat=tentarray[i][8];
		
		if(tentarray[i][9]==userid)
		{
			baseIcon= imgURL+'/mytent.png';
		}
		else
		{
			baseIcon= imgURL+'/tent.png';
		}
		if(document.getElementById('TentDrag').value==1 && tentarray[i][9]==userid)
		{
			drag=true;
		}
		else
		{
			drag=false;
		}	
		
		var latlng = new google.maps.LatLng(lat,lng);
		var prv_drag_point = latlng;
	 			
		var marker = new google.maps.Marker({
		position: latlng,
		map: map,
		icon:baseIcon,
		draggable: drag
		});
	
		 google.maps.event.addListener(marker, "dragstart", function() {
			  //map.closeInfoWindow();
			});
	
		  google.maps.event.addListener(marker, "dragend", function() {
		
		/*	if(!(isPointInPoly(bigPolypoints, {x: marker.get_position().lat(), y: marker.get_position().lng()}) || isPointInPoly(smallPolypoints, {x: marker.get_position().lat(), y: marker.get_position().lng()})))
			{
				marker.set_position(prv_drag_point);
			}*/
			prv_drag_point=marker.getPosition();
		});
	
		google.maps.event.addListener(marker, 'position_changed', function() {
				document.getElementById('TentLongitude').value=	marker.getPosition().lng();
				document.getElementById('TentLatitude').value=	marker.getPosition().lat();
			//alert("Lat:"+marker.get_position().lat()+"<br>Lat:"+marker.get_position().lng());																
																		   });
		
		google.maps.event.addListener(marker, 'click', function() {
		if (infowindow) infowindow.close();
		var username=tentarray[i][11]+" "+tentarray[i][12];
		infowindow =createInfowindow(tentarray[i][1],tentarray[i][2],tentarray[i][3],username,tentarray[i][14]);
		infowindow.open(map,marker);	
	 });
}

function loginusermarker(map)
{
//	var lng=parseIdocument.getElementById('TentLongitude').value;
//	var lat=document.getElementById('TentLatitude').value;
 	
	var latlng = new google.maps.LatLng(lat,lng);
	var prv_drag_point = latlng;
	
	baseIcon= imgURL+'/mytent.png';
 	if(document.getElementById('TentDrag').value==1)
	{
		drag=true;
	}
	else
	{
		drag=false;
	}		
	var marker = new google.maps.Marker({
	position: latlng,
	map: map,
	icon:baseIcon,
	draggable: drag
	});

	 google.maps.event.addListener(marker, "dragstart", function() {
		  //map.closeInfoWindow();
		 // infowindow.close(map,marker);
		});
 
 	 google.maps.event.addListener(marker, "dragend", function() {
	
	/*	if(!(isPointInPoly(bigPolypoints, {x: marker.get_position().lat(), y: marker.get_position().lng()}) || isPointInPoly(smallPolypoints, {x: marker.get_position().lat(), y: marker.get_position().lng()})))
		{
			marker.set_position(prv_drag_point);
		}*/
		prv_drag_point=marker.getPosition();
	});

	google.maps.event.addListener(marker, 'position_changed', function() {
			document.getElementById('TentLongitude').value=	marker.getPosition().lng();
			document.getElementById('TentLatitude').value=	marker.getPosition().lat();
		//alert("Lat:"+marker.get_position().lat()+"<br>Lat:"+marker.get_position().lng());										  
																	   });
	
	google.maps.event.addListener(marker, 'click', function() {          	
	var contentString=map_errors.vars.map_owntent+" <br>"+map_errors.vars.map_lat+marker.getPosition().lat()+"<br>"+map_errors.vars.map_lng+marker.get_position().lng();
	if (infowindow) infowindow.close();
   	infowindow = new google.maps.InfoWindow({
        content:contentString,
		size: new google.maps.Size(200, 80)
    });
	
	infowindow.open(map,marker);	
 });

} 

function tentpagemarker(map,userid,i)
{ 
		var lng=tentarray[i][7];
		var lat=tentarray[i][8];

		if(tentarray[i][9]==userid)
		{
			baseIcon= imgURL+'/mytent.png';
		}
		else
		{
			baseIcon= imgURL+'/tent.png';
		}
		
		var latlng = new google.maps.LatLng(lat,lng);
		var prv_drag_point = latlng;
	 			
		var marker = new google.maps.Marker({
		position: latlng,
		map: map,
		icon:baseIcon,
		draggable: false
		});
		mapMarkers.push(marker);
	
		if(userid)
		{
			google.maps.event.addListener(marker, 'click', function() {
			if (infowindow) infowindow.close();
			var username=tentarray[i][11]+" "+tentarray[i][12];
			infowindow =createInfowindow(tentarray[i][1],tentarray[i][2],tentarray[i][3],username,tentarray[i][14]);
			infowindow.open(map,marker);	
		 });
		}
}



function singletentmap(userid)
{
	var myLatlng = new google.maps.LatLng(lat,lng);
	var prv_center=myLatlng;
	 
	var map = mapinitialize(myLatlng);
	mapoverlay(map,default_zoomLevel);
	treemarker(map);
	
	for(i=0;i<tentarray.length;i++)
	{ 
		tentpagemarker(map,userid,i);
	}
	
	google.maps.event.addListener(map, 'zoom_changed', function() {
		var current_zoomLevel = map.getZoom();
		
     //mapOverlays.clear();
		overlay.onRemove();
		mapoverlay(map,current_zoomLevel);
		if(default_zoomLevel>current_zoomLevel){
			map.setZoom(default_zoomLevel);
		}
	});

	google.maps.event.addListener(map, 'drag', function() {
		  var ri_distance=map.getZoom();
			if(getDistace(map.getCenter().lat(),map.getCenter().lng(),myLatlng.lat(),myLatlng.lng())>ri_distance)
			{
				map.setCenter(prv_center);
			}
		prv_center=map.getCenter();
	});
	
	google.maps.event.addListener(map, 'tilesloaded', function() {							
     document.getElementById("searchid").style.display = '';
    });

	google.maps.event.trigger(mapMarkers[0], 'click');
}

function positionMarker(id)
{
   google.maps.event.trigger(mapMarkers[id], 'click');
}
function treemarker(map)
{
	for(t=0;t<tree.length;t++)
	{
		var lng=tree[t].y;
		var lat=tree[t].x;
 	
		baseIcon= imgURL+'/tree.png';
	
		var latlng = new google.maps.LatLng(lat,lng);
		 			
		var marker = new google.maps.Marker({
		position: latlng,
		map: map,
		icon:baseIcon,
		draggable: false
		});
	}
	
	for(lt=0;lt<ltree.length;lt++)
	{
		var lng=ltree[lt].y;
		var lat=ltree[lt].x;
 	
		baseIcon= imgURL+'/treeLight.png';
	
		var latlng = new google.maps.LatLng(lat,lng);
		 			
		var marker = new google.maps.Marker({
		position: latlng,
		map: map,
		icon:baseIcon,
		draggable: false
		});
	}
	
	for(p=0;p<htp.length;p++)
	{
		var lng=htp[p].y;
		var lat=htp[p].x;
 	
		baseIcon= imgURL+'/potty.png';
	
		var latlng = new google.maps.LatLng(lat,lng);
		 			
		var marker = new google.maps.Marker({
		position: latlng,
		map: map,
		icon:baseIcon,
		draggable: false
		});
	}
}
 

/*function outerinfo(name)
{
	var contentString=name;
	return  new google.maps.InfoWindow({
			content:contentString,
			maxWidth:200
		});		
}*/

/*function sidewalk(map)
{
	
	for(w=0;w<walk.length;w++)
	{
		var lat1=walk[w].x1;
		var lat2=walk[w].x2;
		var lng1=walk[w].y1;
		var lng2=walk[w].y2;
		
		var linelatlng = [
        new google.maps.LatLng(lat1,lng1),
  		new google.maps.LatLng(lat2,lng2)
		];
		var line = new google.maps.Polyline({
		  path: linelatlng,
		  strokeColor: "#000000",
		  strokeOpacity: 1.0,
		  strokeWeight: 2
		});
		
		line.setMap(map);
	}
}*/

/*function walkpath(map)
{
	for(w=0;w<path.length;w++)
	{
		var smallarray=new Array();
		var outground 
		var lat1=path[w].x1;
		var lat2=path[w].x2;
		var lat3=path[w].x3;
		var lat4=path[w].x4;
		var lng1=path[w].y1;
		var lng2=path[w].y2;
		var lng3=path[w].y3;
		var lng4=path[w].y4;
		
	 smallarray.push(new google.maps.LatLng(lat1,lng1));
  	 smallarray.push(new google.maps.LatLng(lat2,lng2));
	 smallarray.push(new google.maps.LatLng(lat3,lng3));
	 smallarray.push(new google.maps.LatLng(lat4,lng4));
		
		outground = new google.maps.Polygon({
		paths: smallarray,
		strokeColor: "",
		strokeOpacity: 0,
		strokeWeight: 0,
		fillColor: "#FFFFFF",
		fillOpacity: 1
	  });

	outground.setMap(map);
	}
	
}*/
/*function emergencysidewalk(map)
{
	for(w=0;w<emergencywalk.length;w++)
	{
		var lat1=emergencywalk[w].x1;
		var lat2=emergencywalk[w].x2;
		var lng1=emergencywalk[w].y1;
		var lng2=emergencywalk[w].y2;
		
		var linelatlng = [
        new google.maps.LatLng(lat1,lng1),
  		new google.maps.LatLng(lat2,lng2)
		];
		var line = new google.maps.Polyline({
		  path: linelatlng,
		  strokeColor: "#FF0000",
		  strokeOpacity: .2,
		  strokeWeight: 4
		});
		
		line.setMap(map);
	}
}*/
/*function bigground(map)
{
	var bigarray= new Array();
	var outground;
	for(b=0;b<bigPolypoints.length;b++)
	{
		var ilat=bigPolypoints[b].x;
		var ilng=bigPolypoints[b].y;
		var glatlng =  new google.maps.LatLng(ilat,ilng);
		bigarray.push(glatlng);
	}
	
	outground = new google.maps.Polygon({
    paths: bigarray,
    strokeColor: "#000000",
    strokeOpacity: 0.8,
    strokeWeight: 1,
    fillColor: "",
    fillOpacity: 0
  });

	outground.setMap(map);
}

function smallground(map)
{
	var smallarray= new Array();
	var outground;
	for(b=0;b<smallPolypoints.length;b++)
	{
		var ilat=smallPolypoints[b].x;
		var ilng=smallPolypoints[b].y;
		var glatlng =  new google.maps.LatLng(ilat,ilng);
		smallarray.push(glatlng);
	}
	
	outground = new google.maps.Polygon({
    paths: smallarray,
    strokeColor: "#FFFFFF",
    strokeOpacity: 0.8,
    strokeWeight: 3,
    fillColor: "",
    fillOpacity: 0
  });

	outground.setMap(map);
}
*/
function CircleOverlay(map, point, radius)
{
 	var d2r = Math.PI / 180;
	circleLatLngs = new Array();
	var circleLat = radius * 0.014483;  // Convert statute miles into degrees latitude
	var circleLng = circleLat / Math.cos(point.lat() * d2r);
	var numPoints = 100;
	var innercircle;
	
	// 2PI = 360 degrees, +1 so that the end points meet
	for (var i = 0; i < numPoints + 1; i++) {
		var theta = Math.PI * (i / (numPoints / 2));
		var vertexLat = point.lat() + (circleLat * Math.sin(theta));
		var vertexLng = parseFloat(point.lng()) + parseFloat((circleLng * Math.cos(theta)));
		var vertextLatLng = new google.maps.LatLng(vertexLat, vertexLng);
		circleLatLngs.push(vertextLatLng);
	}
 
	innercircle = new google.maps.Polygon({
    paths: circleLatLngs,
    strokeColor: "#FFFFFF",
    strokeOpacity: 0.8,
    strokeWeight: 4.5,
    fillColor: "",
    fillOpacity: .5
  });

	innercircle.setMap(map);
}



function getDistace(lat1, lon1, lat2, lon2) { 

	var R = 6371; 
	var dLat = (lat2-lat1); 
	var dLon = (lon2-lon1); 
	var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
			Math.cos(lat1) * Math.cos(lat2) * 
			Math.sin(dLon/2) * Math.sin(dLon/2); 
	var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
	var d = R * c;
	return d;
}

function isPointInPoly(poly, pt){
	for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
		((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y))
		&& (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x)
		&& (c = !c);
	return c;
}

 
var bigPolypoints = [
{ x: 34.36530042560854, y: -89.53386966574556},
{ x: 34.365278285163704, y: -89.53383747923738},
{ x: 34.36526942898413, y: -89.53378383505708},
{ x: 34.36525171662215, y: -89.53369263995057},
{ x: 34.36524286043977, y: -89.53359608042604},
{ x: 34.3652251480722, y: -89.53347269881135},
{ x: 34.365211863794045, y: -89.53337077486879},
{ x: 34.3651985795138, y: -89.53321520674592},
{ x: 34.36518529523144, y: -89.53312937605745},
{ x: 34.36518086713686, y: -89.53294698584443},
{ x: 34.36513658617811, y: -89.53261439192659},
{ x: 34.365087877096485, y: -89.53210477221376},
{ x: 34.365025883678896, y: -89.53152005064851},
{ x: 34.36495946210917, y: -89.53106943953401},
{ x: 34.36495946210917, y: -89.53104261744386},
{ x: 34.364968318321516, y: -89.53101579535371},
{ x: 34.36500374316152, y: -89.53099433768159},
{ x: 34.365052452292055, y: -89.53096751559144},
{ x: 34.365087877096485, y: -89.53097288000947},
{ x: 34.36511001759165, y: -89.53096751559144},
{ x: 34.36515429856444, y: -89.53096751559144},
{ x: 34.3651897233258, y: -89.53096751559144},
{ x: 34.36526942898413, y: -89.53096751559144},
{ x: 34.365340278394534, y: -89.53096751559144},
{ x: 34.365362418823004, y: -89.53096751559144},
{ x: 34.36539341541301, y: -89.53096751559144},
{ x: 34.365437696236015, y: -89.53097288000947},
{ x: 34.36554839819115, y: -89.5309782444275},
{ x: 34.36557496663861, y: -89.53098897326356},
{ x: 34.36561039122211, y: -89.53100506651765},
{ x: 34.36567238420722, y: -89.53102652418977},
{ x: 34.36570338068258, y: -89.53105871069795},
{ x: 34.36567681227583, y: -89.53104261744386},
{ x: 34.36571223681628, y: -89.53106407511598},
{ x: 34.36576537359889, y: -89.53109626162416},
{ x: 34.36580079810189, y: -89.5311230837143},
{ x: 34.36585836288735, y: -89.5311767278946},
{ x: 34.365893787351034, y: -89.53120354998475},
{ x: 34.365938067909596, y: -89.53125182974702},
{ x: 34.36596906428666, y: -89.5312840162552},
{ x: 34.36598677649696, y: -89.53130547392732},
{ x: 34.36601334480542, y: -89.53134302485353},
{ x: 34.366026628956504, y: -89.53136448252565},
{ x: 34.3660576253008, y: -89.53139666903382},
{ x: 34.36608419358679, y: -89.531428855542},
{ x: 34.366124045999975, y: -89.53146104205018},
{ x: 34.36614175817753, y: -89.53148786414033},
{ x: 34.3661771825214, y: -89.5315361439026},
{ x: 34.366217034890354, y: -89.53163270342714},
{ x: 34.36625688724036, y: -89.53170780527955},
{ x: 34.3662701713528, y: -89.53179900038606},
{ x: 34.366314451712455, y: -89.5318794666565},
{ x: 34.36633659188348, y: -89.5319331108368},
{ x: 34.3663543040161, y: -89.53199211943513},
{ x: 34.36638972827012, y: -89.53210477221376},
{ x: 34.36642072448009, y: -89.53221206057435},
{ x: 34.36644286462305, y: -89.53227643359071},
{ x: 34.36646057673321, y: -89.53237299311525},
{ x: 34.36647828883962, y: -89.53243200171357},
{ x: 34.36650042896736, y: -89.53252319682008},
{ x: 34.36650485699221, y: -89.53256611216432},
{ x: 34.366518141065356, y: -89.5326358495987},
{ x: 34.36652699711293, y: -89.53267340052491},
{ x: 34.366540281182566, y: -89.53276996004945},
{ x: 34.3665491372278, y: -89.53286115515596},
{ x: 34.36655799327211, y: -89.5329416214264},
{ x: 34.3665491372278, y: -89.53296844351655},
{ x: 34.36656684931551, y: -89.53307573187715},
{ x: 34.36656684931551, y: -89.53312937605745},
{ x: 34.36656684931551, y: -89.53323666441804},
{ x: 34.36656684931551, y: -89.53329567301637},
{ x: 34.36656684931551, y: -89.5333385883606},
{ x: 34.36657127733684, y: -89.5334458767212},
{ x: 34.36657570535794, y: -89.53341369021302},
{ x: 34.36655799327211, y: -89.53349415648347},
{ x: 34.36656242129393, y: -89.53354243624574},
{ x: 34.366553565250065, y: -89.533590716008},
{ x: 34.36652699711293, y: -89.53363363135225},
{ x: 34.36647828883962, y: -89.53372482645875},
{ x: 34.366447292650925, y: -89.53376774180299},
{ x: 34.3664162964508, y: -89.53382138598329},
{ x: 34.36631887974712, y: -89.53399304736024},
{ x: 34.3662790274266, y: -89.53408960688478},
{ x: 34.36620817881001, y: -89.53421298849946},
{ x: 34.36615947035134, y: -89.53430418360597},
{ x: 34.366097477726626, y: -89.53441147196656},
{ x: 34.36601334480542, y: -89.53451339590913},
{ x: 34.36598234844474, y: -89.53455094683534},
{ x: 34.365951352072585, y: -89.53464214194184},
{ x: 34.365942495964156, y: -89.53463141310579},
{ x: 34.36591592763323, y: -89.5346153198517},
{ x: 34.36590264346461, y: -89.53457776892549},
{ x: 34.365871647062995, y: -89.53454558241731},
{ x: 34.365822938408684, y: -89.5345080314911},
{ x: 34.36579194197755, y: -89.53447584498292},
{ x: 34.36577422972605, y: -89.5344543873108},
{ x: 34.36573437714646, y: -89.53440610754853},
{ x: 34.36570338068258, y: -89.5343631922043},
{ x: 34.3656635280693, y: -89.53432564127809},
{ x: 34.365628103508264, y: -89.53428809035188},
{ x: 34.36559710700505, y: -89.53423444617158},
{ x: 34.36557053856461, y: -89.53420762408143},
{ x: 34.36554397011572, y: -89.53418080199128},
{ x: 34.36548640511428, y: -89.53410033572084},
{ x: 34.365442124317035, y: -89.53404669154054},
{ x: 34.36539341541301, y: -89.53398768294221},
{ x: 34.36535356265231, y: -89.533950132016},
{ x: 34.36533585030814, y: -89.53392867434388},
{ x: 34.36531813796021, y: -89.5338964878357}
];


var smallPolypoints = [
{ x: 34.36522957616444, y: -89.53400914061433},
{ x: 34.36524286043977, y: -89.53400914061433},
{ x: 34.36527385707403, y: -89.53401986945039},
{ x: 34.36529599752006, y: -89.53404669154054},
{ x: 34.365331422221495, y: -89.53407887804872},
{ x: 34.365450980478364, y: -89.53422908175355},
{ x: 34.36563695964993, y: -89.53444902289277},
{ x: 34.36574766134177, y: -89.53459386217958},
{ x: 34.36580522616372, y: -89.53468505728608},
{ x: 34.36583179452974, y: -89.53471724379426},
{ x: 34.365849506769074, y: -89.53475479472047},
{ x: 34.36588493123652, y: -89.53484598982698},
{ x: 34.36588935929388, y: -89.53489426958924},
{ x: 34.36589821540794, y: -89.53494254935151},
{ x: 34.36590264346461, y: -89.53499082911378},
{ x: 34.36588493123652, y: -89.5350659309662},
{ x: 34.36585836288735, y: -89.53516785490876},
{ x: 34.365827366469325, y: -89.53525368559724},
{ x: 34.36580079810189, y: -89.5353180586136},
{ x: 34.36573880521181, y: -89.53543071139222},
{ x: 34.36568124034421, y: -89.53551117766267},
{ x: 34.365641387720395, y: -89.53554336417085},
{ x: 34.36560153507765, y: -89.53558627951509},
{ x: 34.36549526127094, y: -89.53563992369538},
{ x: 34.36541998390963, y: -89.53567211020356},
{ x: 34.36537570307727, y: -89.53568283903962},
{ x: 34.36530485369681, y: -89.5356774746216},
{ x: 34.36524286043977, y: -89.53566674578553},
{ x: 34.36520743570085, y: -89.5356613813675},
{ x: 34.36515429856444, y: -89.53563992369538},
{ x: 34.36511887378807, y: -89.53561846602327},
{ x: 34.36506130849458, y: -89.53559164393312},
{ x: 34.36501259936919, y: -89.53554872858888},
{ x: 34.364977174532925, y: -89.5355165420807},
{ x: 34.36493732157423, y: -89.53546826231843},
{ x: 34.36490632481548, y: -89.53541998255616},
{ x: 34.36489746859659, y: -89.53538779604798},
{ x: 34.36487975615599, y: -89.5353556095398},
{ x: 34.36485318748808, y: -89.53530732977754},
{ x: 34.36483547503811, y: -89.53524295676118},
{ x: 34.36480890635618, y: -89.5351571260727},
{ x: 34.36477348143379, y: -89.53488354075319},
{ x: 34.36477790954989, y: -89.53483526099092},
{ x: 34.364795622012025, y: -89.53478161681062},
{ x: 34.36482661881175, y: -89.53471724379426},
{ x: 34.36485318748808, y: -89.53466359961396},
{ x: 34.36488418426648, y: -89.53458313334352},
{ x: 34.36490189670614, y: -89.53454558241731},
{ x: 34.364915181033425, y: -89.53454021799928},
{ x: 34.36493732157423, y: -89.53450266707307},
{ x: 34.364977174532925, y: -89.53441147196656},
{ x: 34.36500817126547, y: -89.5343631922043},
{ x: 34.365052452292055, y: -89.53428272593385},
{ x: 34.365087877096485, y: -89.5342022596634},
{ x: 34.365114445689976, y: -89.53414325106507},
{ x: 34.36513658617811, y: -89.5340949713028},
{ x: 34.36518086713686, y: -89.53404132712251},
{ x: 34.36520300760744, y: -89.53401986945039},
{ x: 34.3652251480722, y: -89.53400914061433}
];

var tree=[
{ x: 34.36557053856461, y: -89.53399572956926},
{ x: 34.3657166648828, y: -89.53408156025773},
{ x: 34.36603991310545, y: -89.53426663267976},
{ x: 34.365603749113845, y: -89.53376237738496},
{ x: 34.36564581579065, y: -89.53364972460633},
{ x: 34.365707808749555, y: -89.53364704239732},
{ x: 34.36586279094611, y: -89.53379456389314},
{ x: 34.3659668502601, y: -89.53382675040132},
{ x: 34.36528271325312, y: -89.53280482876664},
{ x: 34.36538677328755, y: -89.53279946434861},
{ x: 34.36525171662215, y: -89.53323398220903},
{ x: 34.36540448562098, y: -89.5331937490738},
{ x: 34.36546869279818, y: -89.53326348650819},
{ x: 34.36550633146541, y: -89.53322057116395},
{ x: 34.36551961569688, y: -89.53331713068849},
{ x: 34.36555504030379, y: -89.5332473932541},
{ x: 34.36558160874917, y: -89.5333734570778},
{ x: 34.36573880521181, y: -89.53305159199601},
{ x: 34.36576537359899, y: -89.53341369021302},
{ x: 34.365827366469425, y: -89.53315351593858},
{ x: 34.36582515243913, y: -89.533048909787},
{ x: 34.365997846626634, y: -89.53342441904908},
{ x: 34.366095263703585, y: -89.5333734570778},
{ x: 34.36613290208932, y: -89.53318033802873},
{ x: 34.36630780966009, y: -89.53331713068849},
{ x: 34.36612183197764, y: -89.53379992831117},
{ x: 34.36625910125936, y: -89.53372482645875},
{ x: 34.36633880590039, y: -89.53365508902436},
{ x: 34.36634766196692, y: -89.53357462275392},
{ x: 34.36645172067872, y: -89.5335182963646},
{ x: 34.36646057673331, y: -89.53372214424974},
{ x: 34.36585614885797, y: -89.53278873551255},
{ x: 34.36601998688132, y: -89.53264657843476},
{ x: 34.36609304968034, y: -89.53276459563142},
{ x: 34.36618382458432, y: -89.53276459563142},
{ x: 34.36626352929695, y: -89.53261170971757},
{ x: 34.36627681340834, y: -89.533048909787},
{ x: 34.366380872208126, y: -89.53291211712724},
{ x: 34.366372016145085, y: -89.53275654900438},
{ x: 34.366447292651024, y: -89.5326707183159},
{ x: 34.36649821495493, y: -89.5326170741356},
{ x: 34.3665447092054, y: -89.53278337109452},
{ x: 34.36648935890431, y: -89.53291479933625},
{ x: 34.366487144891515, y: -89.5331025539673},
{ x: 34.36655135123909, y: -89.53316424477464},
{ x: 34.366509285016924, y: -89.53331176627046},
{ x: 34.36559932104137, y: -89.53252856123811},
{ x: 34.36564138772052, y: -89.53232203114396},
{ x: 34.36555504030392, y: -89.53212354767686},
{ x: 34.3654244119917, y: -89.53202698815232},
{ x: 34.365302639652825, y: -89.5318794666565},
{ x: 34.3652251480723, y: -89.53171316969758},
{ x: 34.36510780354253, y: -89.53195456850892},
{ x: 34.36517865308959, y: -89.53185264456636},
{ x: 34.36508787709661, y: -89.53164611447221},
{ x: 34.36504581013967, y: -89.53146640646821},
{ x: 34.36501481342106, y: -89.5311391769684},
{ x: 34.365123301886065, y: -89.5313027917183},
{ x: 34.36508787709661, y: -89.53112576592332},
{ x: 34.36511223164098, y: -89.53095142233735},
{ x: 34.365240646394135, y: -89.53100238430864},
{ x: 34.36534027839463, y: -89.53093801129228},
{ x: 34.36543548219554, y: -89.53103725302583},
{ x: 34.36552847185012, y: -89.53094337571031},
{ x: 34.365605963150124, y: -89.53101847756272},
{ x: 34.365710022783055, y: -89.53101043093568},
{ x: 34.36581186825614, y: -89.53111235487825},
{ x: 34.3656989526155, y: -89.53138862240678},
{ x: 34.36580965422541, y: -89.53153346169358},
{ x: 34.365940281937014, y: -89.53140739786988},
{ x: 34.3660199868814, y: -89.53157101261979},
{ x: 34.3660996917499, y: -89.53146104205018},
{ x: 34.3661860386052, y: -89.53158174145585},
{ x: 34.366163898394376, y: -89.5316622077263},
{ x: 34.36624581714522, y: -89.53172121632463},
{ x: 34.366228104989645, y: -89.53179095375901},
{ x: 34.36624138910669, y: -89.5319143353737},
{ x: 34.366294525553684, y: -89.53182582247621},
{ x: 34.366294525553684, y: -89.53192774641877},
{ x: 34.36629895358942, y: -89.531967979554},
{ x: 34.36629231153573, y: -89.53203235257035},
{ x: 34.36633659188366, y: -89.5320940433777},
{ x: 34.366345447950444, y: -89.53203235257035},
{ x: 34.36638751425487, y: -89.53215036976701},
{ x: 34.36635873204888, y: -89.53219060290223},
{ x: 34.366391942285716, y: -89.53225229370958},
{ x: 34.36640965440663, y: -89.53231398451692},
{ x: 34.36644286462326, y: -89.53237835753328},
{ x: 34.36645172067882, y: -89.53244004834062},
{ x: 34.36638751425489, y: -89.53246150601274},
{ x: 34.36627017135303, y: -89.53247491705781},
{ x: 34.36609747772683, y: -89.532509785775},
{ x: 34.366197108708455, y: -89.53228984463578},
{ x: 34.366236961067955, y: -89.53215573418504},
{ x: 34.36619046664671, y: -89.53200284827119}
];

var ltree=[
{x: 34.36590707152106, y: -89.53146104205018}
		   ];

var htp=[
{ x: 34.36660670149914, y: -89.53256611216432},
{ x: 34.365110017591704, y: -89.53315083372956}		 
		 ];


var walk=[
				{ x1: 34.366535853160066, y1: -89.53255001891023,  x2: 34.365601535078130, y2: -89.53269485819703},	  
				{ x1: 34.36652256908974, y1: -89.53250173914796 ,  x2: 34.36558825085918, y2: -89.5326519428528},
				{ x1: 34.36654470920529, y1: -89.53362826693422 , x2: 34.365601535078135, y2: -89.53269485819703},
				{ x1: 34.366522569089256, y1: -89.5336604534424 , x2: 34.36555725434123, y2: -89.53270558703309},
				{ x1: 34.36555725434123, y1: -89.53270558703309 , x2: 34.365143228323426, y2: -89.53276996004945},
				{ x1: 34.36558825085918, y1: -89.5326519428528 , x2: 34.36505909444403, y2: -89.53204308140641},
				{ x1: 34.36513658617814, y1: -89.53272168028718 , x2: 34.365541756077974, y2: -89.5326519428528},
				{ x1: 34.365541756077974, y1: -89.5326519428528 , x2: 34.365065736595476, y2: -89.5320940433777},	 
				{ x1: 34.36626131527808, y1: -89.5340949713028 , x2: 34.366199322728704, y2: -89.53404669154054},
				{ x1: 34.366199322728704, y1: -89.53404669154054,  x2: 34.365340278394534, y2: -89.53386966574556},
				{ x1: 34.36608862163364, y1: -89.53398768294221, x2:34.36531813796021, y2: -89.53382675040132},
				{ x1: 34.366274599389854, y1: -89.53406814921266, x2: 34.3662126068503, y2: -89.53400914061433},
				{ x1: 34.3662126068503, y1: -89.53400914061433,  x2: 34.366137330133476, y2: -89.53398231852418 },
				{ x1: 34.366137330133476, y1: -89.53398231852418, x2: 34.3653845592456, y2: -89.53338686812288},
				{ x1: 34.3653845592456, y1: -89.53338686812288 , x2: 34.36525171662215, y2: -89.53334931719667},
				{ x1: 34.36608862163364, y1: -89.53398768294221,  x2: 34.3653845592456, y2: -89.5334458767212},
				{ x1: 34.3653845592456, y1: -89.5334458767212,	x2: 34.365256144712994, y2: -89.53338686812288}

			  ];

var path=[
		   { x1: 34.366535853160066, y1: -89.53255001891023,
			x2: 34.36652256908974, y2:  -89.53250173914796,
			x3: 34.36558825085918, y3: -89.5326519428528,
			x4: 34.36555725434123, y4: -89.53270558703309 
		  }  ,
		  {
			x1: 34.36555725434123, y1: -89.53270558703309,
		  	x2: 34.365143228323426,  y2: -89.53276996004945,	
			x3: 34.36513658617814, y3:  -89.53272168028718,
			x4: 34.36558825085918, y4: -89.5326519428528 
		  },
		  { 
		  	x1: 34.365601535078135, y1: -89.53269485819703,
		  	x2: 34.36654470920529,  y2: -89.53362826693422,
			x3: 34.366522569089256, y3: -89.5336604534424,	
			x4: 34.36555725434123, y4: -89.53270558703309	
		  },
		  {
			x1: 34.36558825085918, y1: -89.5326519428528,
		  	x2: 34.36505909444403,  y2: -89.53204308140641,
			x3: 34.365065736595476, y3: -89.5320940433777,	
			x4: 34.365541756077974, y4: -89.5326519428528	
		  }  
		  
		 ];

 function mapoverlay(map,zlevel)
 {
	
	 if(zlevel<=17)
	 {
		var swBound = new google.maps.LatLng(34.3647823376658,-89.5356238304413);
    	var neBound = new google.maps.LatLng(34.36656242129393,-89.5309246002472);
		var srcImage = imgURL+'/map1.png';
	 }
	 else if(zlevel==18)
	 {
		var swBound = new google.maps.LatLng(34.36475576896703,-89.53565601694947);
    	var neBound = new google.maps.LatLng(34.366588989419846,-89.53087632048494);
		var srcImage = imgURL+'/map2.png';
	 }
	 else 
	 {
		var swBound = new google.maps.LatLng(34.364742484614474,-89.53566406357652);
    	var neBound = new google.maps.LatLng(34.36660670149924,-89.53086559164888);
		var srcImage = imgURL+'/map3.png';
	 }
	//alert(srcImage);
	var bounds = new google.maps.LatLngBounds(swBound, neBound);
    overlay = new USGSOverlay(bounds, srcImage, map);
 }
 
 function USGSOverlay(bounds, image, map) {
    // Now initialize all properties.

	this.bounds_ = bounds;
    this.image_ = image;
    this.map_ = map;

    // We define a property to hold the image's div. We'll 
    // actually create this div upon receipt of the onAdd() 
    // method so we'll leave it null for now.
	 
   	this.div_ = null;
 
    // Explicitly call setMap on this overlay
    this.setMap(map);
  }

  USGSOverlay.prototype.onAdd = function() {

    // Note: an overlay's receipt of onAdd() indicates that
    // the map's panes are now available for attaching
    // the overlay to the map via the DOM.

    // Create the DIV and set some basic attributes.
    var div = document.createElement('DIV');
    div.style.border = "0";
    div.style.position = "absolute";

    // Create an IMG element and attach it to the DIV.
    var img = document.createElement("img");
    img.src = this.image_;
    img.style.width = "100%";
    img.style.height = "100%";
    div.appendChild(img);

    // Set the overlay's div_ property to this DIV
    this.div_ = div;

    // We add an overlay to a map via one of the map's panes.
    // We'll add this overlay to the overlayImage pane.
    var panes = this.getPanes();
    panes.overlayImage.appendChild(div);
  }

  USGSOverlay.prototype.draw = function() {

    // Size and position the overlay. We use a southwest and northeast
    // position of the overlay to peg it to the correct position and size.
    // We need to retrieve the projection from this overlay to do this.
    var overlayProjection = this.getProjection();

    // Retrieve the southwest and northeast coordinates of this overlay
    // in latlngs and convert them to pixels coordinates.
    // We'll use these coordinates to resize the DIV.
    var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
    var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast());

    // Resize the image's DIV to fit the indicated dimensions.
    var div = this.div_;
	try
	{
		div.style.left = sw.x + 'px';
		div.style.top = ne.y + 'px';
		div.style.width = (ne.x - sw.x) + 'px';
		div.style.height = (sw.y - ne.y) + 'px';
	}
	catch(exe)
	{
	}
}

  USGSOverlay.prototype.onRemove = function() {
	this.setMap(null);
	if(this.div_!=null)
	  this.div_.parentNode.removeChild(this.div_);
	try{	  
		this.div_ = null;
	}
	catch(exe)
	{
		this.div_ ="";
	}
  }