/* ******************* */
/* iMap JavaScript    */
/* ****************** */

		var map ="";
		
		var myCount = -1;
		
		var isLoaded = false;
		
		var myPoints = new Array();
		var myInfo = new Array();
		var myType = new Array();
		
		var generalIcon ="";
		
		var myCenterX = 0;
		var myCenterY = 0;
		var myZoom = 2;
		var myFocusZoom = 10;
		
		function resetMyMap(){
			map.closeInfoWindow();			
			map.setCenter(new GLatLng(myCenterY, myCenterX), myZoom);
			showAll();
		}
		
		function zoomOutMAX(){
			map.setZoom(1);
		}
		
		function zoomInMAX(){
			map.setZoom(17);
		}
		
		function showAll(){
			for (i = 0; i < myCount; i++) {
				myPoints[i].show()
			}
		}
		
		function hideAll(){
			map.closeInfoWindow();	
			for (i = 0; i < myCount; i++) {
				myPoints[i].hide()
			}
		}
		
		function setIcons(){
			generalIcon = new GIcon();
			generalIcon.iconSize = new GSize(32,32);
			generalIcon.image = "http://piedmontland.org/images/map/icon.png";
			generalIcon.shadow = "http://piedmontland.org/images/map/shadow-icon.png";
			generalIcon.shadowSize =  new GSize(49, 32);
			generalIcon.iconAnchor = new GPoint(12, 24);
			generalIcon.infoWindowAnchor = new GPoint(16,0);

		}
			
		function createMarker(point,info,type) {
		  var thisIcon = new GIcon();
		  if(type=="general"){thisIcon=generalIcon;}
		  
		  var marker = new GMarker(point, thisIcon);
		  GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(info);
		  });
		  return marker;}
		
		function activateMyPoint(num){
			showAll();
			map.setZoom(myFocusZoom);
			myPoints[num].openInfoWindowHtml(myInfo[num]);
		}
		
		function showOneType(showType){
			map.closeInfoWindow();			
			for (i = 0; i < myCount; i++) {
				if(myType[i] == showType)
					{ myPoints[i].show(); }
				else
					{ myPoints[i].hide(); }
			}
		}
		
		function createMap(){
			map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(myCenterY, myCenterX), myZoom); 
    		map.addMapType(G_PHYSICAL_MAP);
			map.removeMapType(G_HYBRID_MAP);
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			setIcons();
		}
		
		function createMapPoint(pointy, pointx, winW, winH){
			myCount = myCount +1;
			
			if(myCount < 10){
				myNumx = "00" + myCount.toString();
			}
			
			else if(myCount < 100 && myCount > 9){
				myNumx = "0" + myCount.toString();
			}
			
			else if(myCount > 99){
				myNumx= myCount.toString();
			}
			point=new GLatLng(pointx, pointy);
			myInfo[myCount] = "<iframe src='http://piedmontland.org/map/mapInfo.php?x" + myNumx + "' width=" + 350 + " height=" + 70 +" frameborder='0' scrolling='none'>";
			myPoints[myCount]=createMarker(point,myInfo[myCount],"general");
			myType[myCount]="general";
			map.addOverlay(myPoints[myCount]);
		}
		
		function setMyCenter(init){
		tempPoint =myPoints[0].getPoint();
		var MinX = tempPoint.x;
		var MinY = tempPoint.y;
		var MaxX = tempPoint.x;
		var MaxY = tempPoint.y;
		for (i = 0; i < myCount; i++) {
			
			tempPoint =myPoints[i].getPoint();
			
			if(tempPoint.x > MaxX){
				MaxX = tempPoint.x;
			}
			
			if(tempPoint.x < MinX){
				MinX = tempPoint.x;
			}
			
			if(tempPoint.y > MaxY){
				MaxY = tempPoint.y;
			}
			
			if(tempPoint.y < MinY){
				MinY = tempPoint.y;
			}
			
		}
			myCenterX = (MinX + MaxX)/2;
			myCenterY = (MinY + MaxY) / 2;
			if(init==1)
				map.setCenter(new GLatLng(myCenterY, myCenterX), myZoom, G_PHYSICAL_MAP);
			else
				map.setCenter(new GLatLng(myCenterY, myCenterX), myZoom);	
		}
		
		function setMyCenterManual(manualX, manualY){
			myCenterX=manualX;
			myCenterY=manualY;
			map.setCenter(new GLatLng(manualY, manualX), myZoom);
		}
		
		function setMyZoom(myNewZoom){
			myZoom= myNewZoom;
		}
		
		function setMyZoomFocus(myNewZoomFocus){
			myFocusZoom = myNewZoomFocus;
		}
		
		
		function loadMap(){
			if(isLoaded == false){
			createMap();
			
			//*** Edit Here **
			
			//setMyZoom = Zoom When map is set
			setMyZoom(9);
			
			//setMyZoomFocus = Zoom When point is activated
			setMyZoomFocus(16);
			
			//createMapPoint(Coord1ong,Coord1at);
			createMapPoint(-79.85777222,36.157014);		// x000 Lake Brandt Greenway
			createMapPoint(-79.84217500,36.032381);  	// x001 Pinecroft Lake Park
			createMapPoint(-79.78726111,36.117008);	 	// x002 Provincetown Forest
			createMapPoint(-79.97003611,35.996403);		// x003 Lindale Farm
			createMapPoint(-79.33615278,35.850189);		// x004 Patterson Farm
			createMapPoint(-79.71530556,35.958019);		// x005 Old Hackett Farm
			createMapPoint(-79.32160278,35.839558);		// x006 Crider-Phillips Farm
			createMapPoint(-79.32318611,35.843244);		// x007 Jean Handy Farm
			createMapPoint(-80.27430000,36.178192);   	// x008 Friedburg Marsh
			createMapPoint(-79.37577500,35.899056);   	// x009 Cane Creek
			
			createMapPoint(-80.33889167,36.172294);   	// x010 Bethania - Walnut Bluffs
			createMapPoint(-80.33916667,36.132800);   	// x011 Camerille Farm
			createMapPoint(-79.59654722,36.059178);   	// x012 Little Alamance Creek
			createMapPoint(-80.33856944,36.175153);   	// x013 Bethania - Walnut Bottoms
			createMapPoint(-79.84896389,36.130283);   	// x014 Guilford Courthouse -- Lochra
			createMapPoint(-80.28845833,36.436108);   	// x015 Historic Dan River Ford
			createMapPoint(-79.84610833,36.214731);   	// x016 Mears Fork Corridor
			createMapPoint(-80.97588889,36.390375);   	// x017 Chatham Forest
			createMapPoint(-79.87878056,36.106103);   	// x018 Julian & Ethel Clay Price Park 
			createMapPoint(-80.87175000,36.367822);   	// x019 Brushy Fork Riparian Easement
			
			createMapPoint(-80.84018333,36.375994);   	// x020 Old Williams Farm
			createMapPoint(-79.34380556,35.844553);   	// x021 Hickory Grove Dairy
			createMapPoint(-80.94234167,36.489869);   	// x022 Saddle Mountain
			createMapPoint(-80.04091111,36.149042);   	// x023 Haw River Headwaters
			createMapPoint(-79.94685000,35.714925);   	// x024 Ridges Mountain. -- Kenan 
			createMapPoint(-79.55411389,35.836081);  	// x025 Ferguson Farm 
			createMapPoint(-79.24381389,36.520742);	  	// x026 Bennett-Pelissier
			createMapPoint(-80.97583889,36.418003);	 	// x027 Stevenson Forest
			createMapPoint(-80.04064444,36.056386);   	// x028 Fernhill Farm
			createMapPoint(-80.36360556,36.083422);   	// x029 Emily Allen Wildflower Preserve
			
			createMapPoint(-80.29372222,36.424853);   	// x030 Dan River Bends
			createMapPoint(-80.22445833,36.375036);   	// x031 Hanging Rock State Park - Flat Shoals Mtn.
			createMapPoint(-79.95459444,35.71964444);   // x032 Ridges Mountain - Morris
			createMapPoint(-80.93690556,36.499639);   	// x033 Wolfe Creek Preserve--Saddle Mountain II
			createMapPoint(-79.35135556,35.846950);   	// x034 Hadley Brothers Farm I
			createMapPoint(-80.25593611,36.385933);   	// x035 Hanging Rock State Park -- Tuttle
			createMapPoint(-79.58675000,35.838222);   	// x036 Troy Farms
			createMapPoint(-79.85012500,36.124975);   	// x037 Guilford Courthouse -- Kotis 
			createMapPoint(-79.35415833,35.846839);   	// x038 Hadley Brothers Farm II 
			createMapPoint(-79.34487500,35.852314);   	// x039 Hadley Brothers Farm III
			
			createMapPoint(-79.84731389,36.133572);   	// x040 Guilford Courthouse -- Andrews 
			createMapPoint(-80.91745278,36.502714);   	// x041 Hanes Forest
			createMapPoint(-80.95893889,36.422081);   	// x042 Wilson-Davis
			createMapPoint(-79.89763889,35.751689);   	// x043 Caraway Prairie
			createMapPoint(-80.36063333,36.042656);   	// x044 Spach Family Farm
			createMapPoint(-80.90671389,36.432625);   	// x045 River Bend Farm
			createMapPoint(-80.81370556,36.318800);   	// x046 Quail Hill Riparian Easement
			createMapPoint(-79.86598056,36.127081);   	// x047 Guilford Courthouse -- Hood 
			createMapPoint(-79.84557778,36.221889);   	// x048 Mears Fork Corridor -- Bates
			createMapPoint(-79.86625000,36.209592);   	// x049 Mears Fork Corridor -- Payne-Smith
			
			createMapPoint(-79.83729167,36.215869);   	// x050 Mears Fork Corridor -- Voytek Parks 
			createMapPoint(-80.33989444,36.177267);   	// x051 Bethania Muddy Creek Floodplain 
			createMapPoint(-80.36366667,36.083528);   	// x052 Martin-Muddy Creek Floodplain */
			createMapPoint(-79.65395278,35.818239);   	// x053 Williams Dairy I 
			createMapPoint(-80.33367500,36.183958);   	// x054 Bethania -- Old Apple Orchard
			createMapPoint(-80.23565278,36.379883);   	// x055 Hanging Rock State Park - Joyce 
			createMapPoint(-80.34365833,36.179542);   	// x056 Bethania--  Muddy Creek Bluffs 
			createMapPoint(-80.91048611,36.472856);   	// x057 Broadhead
			createMapPoint(-79.85044444,36.129650);   	// x058 Guilford Courthouse -- Neiman
			
			createMapPoint(-79.65531111,35.82458611);   // x059 Williams Dairy II
			
			createMapPoint(-80.23470833,36.434225);   	// x060 Hartman-Richey
			createMapPoint(-79.87828056,36.203919);   	// x061 Mears Fork Corridor -- Pegram
			createMapPoint(-80.88865278,36.483478);   	// x062 Low Gap Wildlife Club
			
			createMapPoint(-79.68516359,35.83078056);   	// x063 Goat Lady Dairy
		
			createMapPoint(-80.52382500,36.099108);   	// x064 Harding Wetlands
			createMapPoint(-80.80688056,36.438711);   	// x065 Ring Wetlands
			createMapPoint(-79.76311944,36.247950);   	// x066 Haw River State Park - Phillips
			createMapPoint(-80.87526667,36.432192);   	// x067 Schumak Farm
			createMapPoint(-79.84982778,36.129803);   	// x068 Guilford Courthouse -- Wakefield
			createMapPoint(-79.63520833,35.855031);   	// x069 Meredell Farms, Inc
			
			createMapPoint(-80.92315000,36.456625);   	// x070 Lens Knob
			createMapPoint(-80.89098611,36.426231);   	// x071 Little Mountain
			createMapPoint(-80.82826667,36.345708);   	// x072 Long Point Preserve
			createMapPoint(-79.95202500,36.444161);   	// x073 Mayo River State Park - Compass Avalon
			createMapPoint(-79.84748889,36.126781);   	// x074 Guilford Courthouse -- McLamb
			createMapPoint(-79.78135833,36.246500);   	// x075 Haw River State Park - Spivey
			createMapPoint(-79.62642222,36.032872);   	// x076 Carpenter Farm
			createMapPoint(-79.95295556,36.434022);   	// x077 Mayo River State Park - Old Mayo Park/Evans
			createMapPoint(-79.39020833,35.939114);   	// x078 Murray Farm
			createMapPoint(-79.14423333,36.485489);   	// x079 Bessemer Group Farm
			
			createMapPoint(-79.78085556,36.240586);   	// x080 Haw River State Park - Myers
			createMapPoint(-79.95971944,36.441792);   	// x081 Mayo River State Park - John Skaggs
			
			
			createMapPoint(-79.6873,35.82968611);   	// x082 Goat Lady Dairy II
			
			createMapPoint(-80.33167778,36.184142);   	// x083 Bethania -- Cedar Grove School Site
			createMapPoint(-79.98812500,36.534864);   	// x084 Mayo River State Park - Sherry Thompson
			createMapPoint(-79.98411111,36.540078);   	// x085 Mayo River State Park - Ferguson Lumber
			createMapPoint(-79.96478333,36.405986);   	// x086 Mayo River State Park - Janet Roberts
			createMapPoint(-80.28908056,36.401358);   	// x087 Hanging Rock State Park - Ellison 
			createMapPoint(-79.97181944,36.500861);   	// x088 Mayo River State Park - Lincoln Grogan
			createMapPoint(-80.33591667,36.183031);   	// x089 Bethania -- Old Apple Orchard II
			
			createMapPoint(-79.31970278,35.836814);   	// x090 Crider Farm II
			createMapPoint(-79.76025000,36.252672);   	// x091 Haw River State Park - Long
			createMapPoint(-80.00117500,36.506319);   	// x092 Mayo River State Park - Rhonda  Walker
			createMapPoint(-79.95816667,36.471692);   	// x093 Mayo River State Park - Hodge/Brady
			createMapPoint(-79.75819167,35.817231);   	// x094 Capps Family Farm I
			createMapPoint(-79.75495833,35.822797);   	// x095 Capps Family Farm II
			createMapPoint(-79.15015556,36.484842);   	// x096 Bessemer Group Farm II
			createMapPoint(-79.15042222,36.485311);   	// x097 Bessemer Group Farm III
			createMapPoint(-79.75362778,35.802658);   	// x098 Coward Farm I
			createMapPoint(-79.75948056,35.800292);   	// x099 Coward Farm II
			
			createMapPoint(-79.75723333,35.814408);   	// x100 Coward Farm III
			createMapPoint(-79.82479167,36.251289);   	// x101 Haw River State Park - Young
			createMapPoint(-79.95471389,36.466761);   	// x102 Mayo River State Park - Arledge/Tindall
			createMapPoint(-79.99376111,36.523633);   	// x103 Mayo River State Park - Smith-Gorrell
			createMapPoint(-79.98963056,36.509608);   	// x104 Mayo River State Park - Betty Robertson
			createMapPoint(-80.88409444,36.412142);   	// x105 Ellis Preserve
			createMapPoint(-79.84707222,36.126850);   	// x106 Guilford Courthouse -- Shirley Henley 
			createMapPoint(-79.84946111,36.129914);   	// x107 Guilford Courthouse -- Gilbert-Rowlett 
			createMapPoint(-80.83278611,36.345325);   	// x108 Long Point Preserve II
			createMapPoint(-79.93531111,36.438433);   	// x109 Mayo River State Park - Piedmont Stone
			
			createMapPoint(-79.94907778,36.450661);   	// x110 Mayo River State Park - Hawks I
			createMapPoint(-79.95647500,36.439950);   	// x111 Mayo River State Park - Hawks II
			createMapPoint(-79.73496667,35.601475);   	// x112 Bain Farm
			createMapPoint(-80.81072778,36.315483);   	// x113 Quail Hill II 
			createMapPoint(-79.96419722,36.398544);   	// x114 Mayo River State Park - New Market Madison
			createMapPoint(-79.78861667,36.064325);   	// x115 Heyge Park
			createMapPoint(-80.50794722,36.076308);   	// x116 Lindheimer Riparian Easement
			createMapPoint(-80.85422222,36.550822);   	// x117 Fisher's Peak I
			createMapPoint(-79.96783056,36.479867);   	// x118 Mayo River State Park - Earl Mooring
			createMapPoint(-80.83168333,36.358369);   	// x119 McNeill Riparian Easement
			
			createMapPoint(-80.83205278,36.354803);   	// x120 Swift Riparian Easement
			createMapPoint(-80.95026667,36.468969);   	// x121 Steele Riparian Easement
			createMapPoint(-79.90188333,35.754236);   	// x122 Caraway Prairie II
			createMapPoint(-80.96642778,36.462772);   	// x123 Harris-Mill Creek Preserve
			createMapPoint(-80.82787222,36.351306);   	// x124 Tayloe  Riparian Easement 
			createMapPoint(-80.00921111,36.504511);   	// x125 Mayo River State Park - Arey O'Neal I
			createMapPoint(-80.00450833,36.508325);   	// x126 Mayo River State Park - Arey O'Neal II
			createMapPoint(-79.54126389,35.841383);   	// x127 Pacers Rest Farm
			createMapPoint(-79.95485833,36.422919);   	// x128 Mayo River State Park - Henry Briley
			createMapPoint(-80.92938611,36.502742);   	// x129 Saddle Mountain III-Horn of Saddle
			
			createMapPoint(-79.87470833,36.173753);   	// x130 Piedmont Greenway - Bur-Mil Park to Summerfield
			createMapPoint(-79.75721111,35.821081);   	// x131 Capps Family Farm III
			createMapPoint(-79.75370556,35.816722);   	// x132 Capps Family Farm IV
			createMapPoint(-80.01788611,36.172875);   	// x133 Stevens Property
			createMapPoint(-80.69991111,36.095522);   	// x134 Chamberlain Farm
			createMapPoint(-80.03589444,36.504172);   	// x135 Ayersville Tree Farm
			createMapPoint(-80.00750000,36.316111);   	// x136 Knightbrown Stream
			createMapPoint(-79.87911100,36.233708);   	// x137 Haw River Property
			//*** End Edit Here **

			setMyCenter(1);
			isLoaded = true;
			}
			
		}
		
		
