//<![CDATA[

    if (GBrowserIsCompatible()) {
		var i = 0;

// Create a Custom Control Item List===
		var labelContainer;
		function LabelControl() {  }
		LabelControl.prototype = new GControl();
		LabelControl.prototype.initialize = function(map) {
			labelContainer = document.createElement("div");
			labelContainer.style.overflow="auto";
			labelContainer.style.backgroundColor = "#ffffcc";
			labelContainer.style.border = "2px solid black";
			labelContainer.style.height="250px";
			labelContainer.style.width="200px";
			labelContainer.style.paddingLeft="2px";
			map.getContainer().appendChild(labelContainer);
			return labelContainer;
		}
// set location of the Item list
		LabelControl.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(7, 33));
		}

// === This function picks up the click and opens the corresponding info window ===
		function myclick(i) {
			GEvent.trigger(gmarkers[i], "click");
		}

// Special icon
		ArtIcon = new GIcon();
		ArtIcon.image = "images/red.png";
		ArtIcon.shadow ="images/shadow.png";
		ArtIcon.iconSize = new GSize(26,26);
		ArtIcon.shadowSize = new GSize(34,26);
		ArtIcon.iconAnchor = new GPoint(13,26);
		ArtIcon.infoWindowAnchor = new GPoint(13,2);
		ArtIcon.inforShadowAnchor = new GPoint(13,26);
		
		FarmIcon = new GIcon();
		FarmIcon.image = "images/red.png";
		FarmIcon.shadow ="images/shadow.png";
		FarmIcon.iconSize = new GSize(26,26);
		FarmIcon.shadowSize = new GSize(34,26);
		FarmIcon.iconAnchor = new GPoint(13,26);
		FarmIcon.infoWindowAnchor = new GPoint(13,2);
		FarmIcon.inforShadowAnchor = new GPoint(13,26);
		
		HistoryIcon = new GIcon();
		HistoryIcon.image = "images/red.png";
		HistoryIcon.shadow ="images/shadow.png";
		HistoryIcon.iconSize = new GSize(26,26);
		HistoryIcon.shadowSize = new GSize(34,26);
		HistoryIcon.iconAnchor = new GPoint(13,26);
		HistoryIcon.infoWindowAnchor = new GPoint(13,2);
		HistoryIcon.inforShadowAnchor = new GPoint(13,26);
		
		KidIcon = new GIcon();
		KidIcon.image = "images/red.png";
		KidIcon.shadow ="images/shadow.png";
		KidIcon.iconSize = new GSize(26,26);
		KidIcon.shadowSize = new GSize(34,26);
		KidIcon.iconAnchor = new GPoint(13,26);
		KidIcon.infoWindowAnchor = new GPoint(13,2);
		KidIcon.inforShadowAnchor = new GPoint(13,26);
		
		NatureIcon = new GIcon();
		NatureIcon.image = "images/red.png";
		NatureIcon.shadow ="images/shadow.png";
		NatureIcon.iconSize = new GSize(26,26);
		NatureIcon.shadowSize = new GSize(34,26);
		NatureIcon.iconAnchor = new GPoint(13,26);
		NatureIcon.infoWindowAnchor = new GPoint(13,2);
		NatureIcon.inforShadowAnchor = new GPoint(13,26);
		
		SpecialIcon = new GIcon();
		SpecialIcon.image = "images/red.png";
		SpecialIcon.shadow ="images/shadow.png";
		SpecialIcon.iconSize = new GSize(26,26);
		SpecialIcon.shadowSize = new GSize(34,26);
		SpecialIcon.iconAnchor = new GPoint(13,26);
		SpecialIcon.infoWindowAnchor = new GPoint(13,2);
		SpecialIcon.inforShadowAnchor = new GPoint(13,26);
		
		SportIcon = new GIcon();
		SportIcon.image = "images/red.png";
		SportIcon.shadow ="images/shadow.png";
		SportIcon.iconSize = new GSize(26,26);
		SportIcon.shadowSize = new GSize(34,26);
		SportIcon.iconAnchor = new GPoint(13,26);
		SportIcon.infoWindowAnchor = new GPoint(13,2);
		SportIcon.inforShadowAnchor = new GPoint(13,26);
		
		ParkIcon = new GIcon();
		ParkIcon.image = "images/red.png";
		ParkIcon.shadow ="images/shadow.png";
		ParkIcon.iconSize = new GSize(26,26);
		ParkIcon.shadowSize = new GSize(34,26);
		ParkIcon.iconAnchor = new GPoint(13,26);
		ParkIcon.infoWindowAnchor = new GPoint(13,2);
		ParkIcon.inforShadowAnchor = new GPoint(13,26);	
			
		UniqueIcon = new GIcon();
		UniqueIcon.image = "images/red.png";
		UniqueIcon.shadow ="images/shadow.png";
		UniqueIcon.iconSize = new GSize(26,26);
		UniqueIcon.shadowSize = new GSize(34,26);
		UniqueIcon.iconAnchor = new GPoint(13,26);
		UniqueIcon.infoWindowAnchor = new GPoint(13,2);
		UniqueIcon.inforShadowAnchor = new GPoint(13,26);
		
		WineIcon = new GIcon();
		WineIcon.image = "images/red.png";
		WineIcon.shadow ="images/shadow.png";
		WineIcon.iconSize = new GSize(26,26);
		WineIcon.shadowSize = new GSize(34,26);
		WineIcon.iconAnchor = new GPoint(13,26);
		WineIcon.infoWindowAnchor = new GPoint(13,2);
		WineIcon.inforShadowAnchor = new GPoint(13,26);
		
		BirdIcon = new GIcon();
		BirdIcon.image = "images/green.png";
		BirdIcon.shadow ="images/shadow.png";
		BirdIcon.iconSize = new GSize(26,26);
		BirdIcon.shadowSize = new GSize(34,26);
		BirdIcon.iconAnchor = new GPoint(13,26);
		BirdIcon.infoWindowAnchor = new GPoint(13,2);
		BirdIcon.inforShadowAnchor = new GPoint(13,26);
		
		LakeIcon = new GIcon();
		LakeIcon.image = "images/green.png";
		LakeIcon.shadow ="images/shadow.png";
		LakeIcon.iconSize = new GSize(26,26);
		LakeIcon.shadowSize = new GSize(34,26);
		LakeIcon.iconAnchor = new GPoint(13,26);
		LakeIcon.infoWindowAnchor = new GPoint(13,2);
		LakeIcon.inforShadowAnchor = new GPoint(13,26);
		
		GolfIcon = new GIcon();
		GolfIcon.image = "images/green.png";
		GolfIcon.shadow ="images/shadow.png";
		GolfIcon.iconSize = new GSize(26,26);
		GolfIcon.shadowSize = new GSize(34,26);
		GolfIcon.iconAnchor = new GPoint(13,26);
		GolfIcon.infoWindowAnchor = new GPoint(13,2);
		GolfIcon.inforShadowAnchor = new GPoint(13,26);
		
		FishIcon = new GIcon();
		FishIcon.image = "images/green.png";
		FishIcon.shadow ="images/shadow.png";
		FishIcon.iconSize = new GSize(26,26);
		FishIcon.shadowSize = new GSize(34,26);
		FishIcon.iconAnchor = new GPoint(13,26);
		FishIcon.infoWindowAnchor = new GPoint(13,2);
		FishIcon.inforShadowAnchor = new GPoint(13,26);
		
		HikeIcon = new GIcon();
		HikeIcon.image = "images/green.png";
		HikeIcon.shadow ="images/shadow.png";
		HikeIcon.iconSize = new GSize(26,26);
		HikeIcon.shadowSize = new GSize(34,26);
		HikeIcon.iconAnchor = new GPoint(13,26);
		HikeIcon.infoWindowAnchor = new GPoint(13,2);
		HikeIcon.inforShadowAnchor = new GPoint(13,26);
		
		HotelIcon = new GIcon();
		HotelIcon.image = "images/purple.png";
		HotelIcon.shadow ="images/shadow.png";
		HotelIcon.iconSize = new GSize(26,26);
		HotelIcon.shadowSize = new GSize(34,26);
		HotelIcon.iconAnchor = new GPoint(13,26);
		HotelIcon.infoWindowAnchor = new GPoint(13,2);
		HotelIcon.inforShadowAnchor = new GPoint(13,26);
		
		RanchIcon = new GIcon();
		RanchIcon.image = "images/purple.png";
		RanchIcon.shadow ="images/shadow.png";
		RanchIcon.iconSize = new GSize(26,26);
		RanchIcon.shadowSize = new GSize(34,26);
		RanchIcon.iconAnchor = new GPoint(13,26);
		RanchIcon.infoWindowAnchor = new GPoint(13,2);
		RanchIcon.inforShadowAnchor = new GPoint(13,26);
		
		BBIcon = new GIcon();
		BBIcon.image = "images/purple.png";
		BBIcon.shadow ="images/shadow.png";
		BBIcon.iconSize = new GSize(26,26);
		BBIcon.shadowSize = new GSize(34,26);
		BBIcon.iconAnchor = new GPoint(13,26);
		BBIcon.infoWindowAnchor = new GPoint(13,2);
		BBIcon.inforShadowAnchor = new GPoint(13,26);
		
		CampIcon = new GIcon();
		CampIcon.image = "images/purple.png";
		CampIcon.shadow ="images/shadow.png";
		CampIcon.iconSize = new GSize(26,26);
		CampIcon.shadowSize = new GSize(34,26);
		CampIcon.iconAnchor = new GPoint(13,26);
		CampIcon.infoWindowAnchor = new GPoint(13,2);
		CampIcon.inforShadowAnchor = new GPoint(13,26);		
		
//Set array of Icon
		var icons = [];
		icons[0] = ArtIcon;
		icons[1] = FarmIcon;
		icons[2] = HistoryIcon;
		icons[3] = KidIcon;
		icons[4] = NatureIcon;
		icons[5] = SpecialIcon;
		icons[6] = SportIcon;
		icons[7] = ParkIcon;
		icons[8] = UniqueIcon;
		icons[9] = WineIcon;
		icons[10] = BirdIcon;
		icons[11] = LakeIcon;
		icons[12] = GolfIcon;
		icons[13] = FishIcon;
		icons[14] = HikeIcon;
		icons[15] = HotelIcon;
		icons[16] = RanchIcon;
		icons[17] = BBIcon;
		icons[18] = CampIcon;
		
// A function to create the marker and set up the event window 
		var gmarkers = [];
		var arrName = [];
		var arrStreet = [];
		var arrCity = [];
		var arrState = [];
		var arrZip = [];
		var arrPhone = [];
		var arrEmail = [];
		var arrWeb = [];
		var arrDesc = [];
		var side_bar_html = "";
		
		function createMarker(point,name,street,city,state,zip,iconnum,phone,email,web,photo,descrip) {
			//var marker = new GMarker(point, {title:name})
			var marker = new GMarker(point,icons[iconnum])
			GEvent.addListener(marker, "click", function() {
				var _address ="<div style='font-family:arial,helvetica;font-size:8pt;'>"
				if(name !=""){_address +="<b>" + name + "</b>"}
				if((street =="")||(street =="")){}else{_address +="<br />" + street}
				if(city !=""){_address +="<br />" + city + ", " + state }
				if((zip =="")||(zip ==null)){}else{_address += " " + zip}
				if((phone =="")||(phone ==null)){}else{_address +="<br />" + phone}
				if((email =="")||(email ==null)){}else{_address +="<br /><b>E-mail:</b> <a href='mailto:" + email + "'><img src='images/email.gif' border='0'/></a>"}
				if((web =="")||(web ==null)){}else{_address +="<br /> <b>Website:</b> <a href='http://" + web + "' target='_blank'><img src='images/world.gif' border='0' /></a>"}
				if((descrip =="")||(descrip ==null)){}else{_address +="<br />" + descrip}
				_address +="</div>";
				marker.openInfoWindowHtml(_address,{pixelOffset:new GSize(32,5), maxWidth:280} );
			});
			
			gmarkers[i] = marker;
			arrName[i] = name;
			arrStreet[i] = street;
			arrCity[i] = city;
			arrState[i] = state;
			arrZip[i] = zip;
			arrPhone[i] = phone;
			arrEmail[i] = email;
			arrWeb[i] = web;
			arrDesc[i] = descrip;
			side_bar_html += '&bull; <a href="javascript:myclick(' + i + ')" style="font-family:arial,helvetica;font-size:8pt;">'+ name + '</a><br />';
			i++;
			return marker;
		}
		
// This function get click and opens the corresponding info window
		function myclick(i) {
			var address = "<div style='font-family:arial,helvetica;font-size:8pt;'>";
			if (arrName[i] !="") {address +="<b>" + arrName[i] + "</b>"}
			if ((arrStreet[i] =="")||(arrStreet[i] ==null)){}else{address +="<br />" + arrStreet[i]}
			if(arrCity[i] !=""){address +="<br />" + arrCity[i] + ", " + arrState[i] }
			if((arrZip[i] =="")||(arrZip[i] ==null)){}else{address += " " + arrZip[i]}
			if((arrPhone[i] =="")||(arrPhone[i] ==null)){}else{address +="<br />" + arrPhone[i] }
			if((arrEmail[i] =="")||(arrEmail[i] ==null)){}else{address +="<br /><b>E-mail:</b> <a href='mailto:" + arrEmail[i] +"'><img src='images/email.gif' border='0'/></a>"}
			if((arrWeb[i] =="")||(arrWeb[i] ==null)){}else{address +="<br /><b>Website:</b><a href='http://" + arrWeb[i] + "' target='_blank'><img src='images/world.gif' border='0'/></a>"}
			if((arrDesc[i]=="")||(arrDesc[i]==null)){}else{ address +="<br />"+ arrDesc[i]}
			address +="</div>";
			gmarkers[i].openInfoWindowHtml(address, {pixelOffset:new GSize(32,5), maxWidth:280} );
		}

// create the map with controls and set center location and zoom
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new LabelControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		map.setCenter(new GLatLng(41.02964338716638, -100.4150390625), 7);
		var cnt = new GLatLng(41.02964338716638, -100.4150390625);
// instruction ballon		
		var instr="<p style='font-family:arial,helvetica;font-size:10pt;'><b>Start by:</b><br />Selecting Attractions, Recreation <br />or Lodging from the pull down <br />menus located above left of the map.";
		map.openInfoWindowHtml(cnt,instr);
		
// A function to read the xml file
		function readMap(url) {
			var request = GXmlHttp.create();
			request.open("GET", url, true);
			request.onreadystatechange = function() {
				if (request.readyState == 4) {
					var xmlDoc = GXml.parse(request.responseText);
					// obtain the array of markers and loop through it
					var markers = xmlDoc.documentElement.getElementsByTagName("marker");

					// hide the info window, otherwise it still stays open where the removed marker used to be
					map.getInfoWindow().hide();
					map.clearOverlays();
					// empty the array
					gmarkers = [];
					// reset the side_bar
					side_bar_html="";
					
					for (var i = 0; i < markers.length; i++) {
						// obtain the attribues of each marker from XML file
						var lat = parseFloat(markers[i].getAttribute("lat"));
						var lng = parseFloat(markers[i].getAttribute("lng"));
						var point = new GLatLng(lat,lng);
						var idnum = markers[i].getAttribute("id");
						var name = markers[i].getAttribute("name");
						var street = markers[i].getAttribute("street");
						var city = markers[i].getAttribute("city");
						var state = markers[i].getAttribute("state");
						var zip = markers[i].getAttribute("zip");
						var iconnum = markers[i].getAttribute("icon");
						var phone = markers[i].getAttribute("phone");
						var email = markers[i].getAttribute("email");
						var web = markers[i].getAttribute("web");
						var photo = markers[i].getAttribute("photo");
						var descrip = markers[i].getAttribute("descrip");
						// create the marker
						var marker = createMarker(point,name,street,city,state,zip,iconnum,phone,email,web,photo,descrip);
						map.addOverlay(marker);
					}
					
					// === put the assembled side_bar_html contents into the custom control ===
					labelContainer.innerHTML = side_bar_html;
					// === put the assembled side_bar_html contents into the side_bar div
					// document.getElementById("side_bar").innerHTML = side_bar_html;
				}
			}
			request.send(null);
		}
    }else {
		alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    //]]>