//<![CDATA[

var GoogleKey = "ABQIAAAAk2Ws3PeqUavgNsIZWg14ghSJ9RViAfv5Fff565pqM5m0PGFQ3RTla5dTF5CTrR3ZjQ_JlCouDfHlYg";
var ZoomFactor = 14;    // ZoomFactor 1=Far-Away (World View), 17=Close-Up (Street View)
var MapCenterCoordLat = 41.60125949095937;
var MapCenterCoordLng = -93.70908737182617;

var siteLocFields = [
	// uniqueID, Title, Text, URLLink, Latitude, Longitude, AllowDirections
	// to help locate Lat/Long, open the tool at /googleMapLatLongFinder.html or go to http://terraserver.microsoft.com/
	// to register for a new Google Key, go to "http://www.google.com/apis/maps/"

 	[1,  "Windsor Heights Lutheran Church","1240 66th Street<br>Des Moines, IA &nbsp; 50311<br>(515) 277-6277","#","41.60125949095937","-93.70908737182617","y"],
 	//[2,  "Council Bluffs Energy Center","7215 Navajo Street<br>Council Bluffs,IA","#","41.110978","-95.502953","y"],
 	//[3,  "Neal Energy Center South","2761 Port Neal Circle<br>Salix,IA","#","42.192345","-96.212776","y"],
 	//[4,  "Neal Energy Center North","1151 260th Street<br>P.O. Box 666<br>Sergeant Bluff,IA","#","42.084662","-96.393958","y"],

	
 
	["", "", "", "#", ""]
 ]








////NO NEED TO EDIT BELOW THIS LINE////////////








    var specLoc = "";
    var is_input = document.URL.indexOf('?');
    if (is_input != -1) {
        var URL = unescape(window.document.location);
        var list1 = URL.split("?");
        var list2 = list1[1].split ("&");

        for (count = 0; count < list2.length; count++) {
            var docUrl = list2[count].toLowerCase();
            if (docUrl.indexOf('mapid=') != -1) {
                docUrl = docUrl.replace("mapid=","")
                specLoc = docUrl;
            }
        }
    }

    if (specLoc != "") {
        var LocID = 0;
        for (count = 0; count < siteLocFields.length; count++) {
            var list3 = specLoc.split ("#");
            specLoc = list3[0]
            if (siteLocFields[count][0] == specLoc) {
                LocID = count;
                break;
            }
        }
        ZoomFactor = 14
        MapCenterCoordLat = siteLocFields[LocID][4];
        MapCenterCoordLng = siteLocFields[LocID][5];
    }

	document.write ("<script src='http://maps.google.com/maps?file=api&v=2&key=" + GoogleKey + "' type='text/javascript'></script>");
	
	function loadGoogleMap() {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(MapCenterCoordLat,MapCenterCoordLng), ZoomFactor);

			// Creates a marker at the given point with the given number label
			function createMarker(point, location) {
				var marker = new GMarker(point);
				GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml("<span style='font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 11px; color:#666;'>" + location + "</span>");
				});
				return marker;
			}

			// Begin Adding Defined Markers
			for (var i=0; i < siteLocFields.length-1; i++) {
				var point = new GLatLng(siteLocFields[i][4],siteLocFields[i][5]);
                var strLocTitle = siteLocFields[i][1]
                if (siteLocFields[i][3] != "" && siteLocFields[i][3] != "#") {
                    strLocTitle = "<a href='" + siteLocFields[i][3] + "' target='_blank'>" + strLocTitle + "</a>"
                }

				if (siteLocFields[i][6] == "y") {
				    var mappedLocation = siteLocFields[i][1];
				    mappedLocation = mappedLocation.replace("(", " ")
				    mappedLocation = mappedLocation.replace(")", " ")
				    
					map.addOverlay(createMarker(point, '' + strLocTitle + '<br>' + siteLocFields[i][2] + '<br><br><span style="color:#666;">Get directions to ' + siteLocFields[i][1] + ' from:</span><form action="http://maps.google.com/maps" method="get" target="_blank"><input type="hidden" name="daddr" value="' + siteLocFields[i][4] + ',' + siteLocFields[i][5] + ' (' + mappedLocation + ')"><input type="text" SIZE=35 MAXLENGTH=40 name="saddr" id="saddr" class="content" value="">&nbsp;<INPUT value="Directions" TYPE="SUBMIT" class="content"></form>'));
				} else {
					map.addOverlay(createMarker(point, '' + strLocTitle + '<br>' + siteLocFields[i][2] + '<br><br>'));			
				}
			}

		}
	}

	WindowOnload( loadGoogleMap );
	
	//]]>

