//--------------------------------------------------------------------------------------------------
//-- Copyright 2005 Woodlawn Christian Church. All rights reserved.
//-- Designed by R. E. Woods 2/7/2007.
//
//	GOOGLE KEYs
//	.COM key=ABQIAAAAvVOZwrw5F95HVlSVDfv8hxQkva87l_DnmzWLLBsSyzaKArGAmRTcc2Yqdi_vPe28vzdvMlxhfJcgHA"
//	.NET key=ABQIAAAAvVOZwrw5F95HVlSVDfv8hxRNEK8A1mBCyPT5Th8uzyMrLxsqDhQN28PIiWTgDu1N0EktukExkm2EZA"
//---------------------------------------------------------------------------------------------------
var locs = [	{"pos":[35.936784, -83.746050], "tabs":[	new GInfoWindowTab("Info",
														"A book study of Dallas Willard's" + "<br>" + 
														"<i>The Great Omission</i>. Intended for" + "<br>" + 
														"college students. No children's program." + "<br><br>" + 
														"Leader: Ron Wheeler, 579-0491"),
														new GInfoWindowTab("Time/Place", 
														"2338 Gateway Court" + "<br>" + 
														"Johnson Bible College, 37998" + "<br><br>" + 
														"Wed 6 - 7:30 pm")]},
				{"pos":[35.93760, -83.90105], "tabs":[	new GInfoWindowTab("Info",
														"Family oriented fellowship and" + "<br>" + 
														"worship, with biblical teaching and" + "<br>" + 
														"outreach to the community. Children welcome." + "<br><br>" + 
														"Leader: David Reid"),
													  	new GInfoWindowTab("Time/Place", 
														"Woodlawn Christian Church" + "<br>" + 
														"4339 Woodlawn Pike" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Wed 6 - 7:30 pm")]},
				{"pos":[35.886658, -83.755576], "tabs":[	new GInfoWindowTab("Info",
														"<i>Bible Couples</i> study from Box" + "<br>" + 
														"Office Bible Studies. Children welcome." + "<br><br>" + 
														"Leader: Tony Krug, 548-5450"),
													  	new GInfoWindowTab("Time/Place", 
														"626 Hills Gate Circle" + "<br>" + 
														"Seymour, TN 37865" + "<br><br>" + 
														"Begins Tue Feb. 13")]},
				{"pos":[35.937884, -83.902148], "tabs":[	new GInfoWindowTab("Info",
														"High School small groups." + "<br>" + 
														"Leader: Dwayne Curry"),
													  	new GInfoWindowTab("Time/Place", 
														"Youth House (by the church)" + "<br>" + 
														"306 Greenwoods Avenue" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Wed 7:30 - 9 pm")]},
				{"pos":[35.936555, -83.730899], "tabs":[	new GInfoWindowTab("Info",
														"A group for Internationals students," + "<br>" + 
														"researchers, and their families" + "<br>" + 
														"that provides help with English while" + "<br>" + 
														"learning about the Gospel." + "<br><br>" + 
														"Leader: Georgia Panya, 609-0555"),
													  	new GInfoWindowTab("Time/Place", 
														"3009 Kimberlin Heights Road" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Tue/Thu, 7:30 - 9:30 pm")]},
				{"pos":[35.907048, -83.842648], "tabs":[	new GInfoWindowTab("Info",
														"A group for mature adults in" + "<br>" + 
														"South Knoxville. No children's program." + "<br><br>" + 
														"Leader: Dean Davis, 573-2060"),
													  	new GInfoWindowTab("Time/Place", 
														"215 Norton Road" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Wed 6:30 - 8 pm")]},
				{"pos":[35.937632, -83.901794], "tabs":[	new GInfoWindowTab("Info",
														"Middle School small groups." + "<br>" + 
														"Leader: Dwayne Curry"),
													  	new GInfoWindowTab("Time/Place", 
														"Youth House (by the church)" + "<br>" + 
														"306 Greenwoods Avenue" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Wed 6 - 7:30 pm")]},
				{"pos":[35.928467, -83.742042], "tabs":[	new GInfoWindowTab("Info",
														"A focus on current events and" + "<br>" + 
														"life lessons for college age adults." + "<br>" + 
														"A meal is provided; no formal children's" + "<br>" + 
														"program but children are welcome." + "<br>" + 
														"Leader: Paul Beam"),
													  	new GInfoWindowTab("Time/Place", 
														"2700 Kimberlin Heights Road" + "<br>" + 
														"Knoxville, TN 37920" + "<br><br>" + 
														"Wed 6 pm")]}];

var layers = [{"zoom":[0, 7], "links":[0, 1, 2, 3, 4, 5, 6, 7], "icons":[-1, -1, -1, -1, -1, -1, -1, -1]},
			  {"zoom":[8, 13], "links":[0, 1, 2, 3, 4, 5, 6, 7], "icons":[0, -1, 2, -1, 4, 5, -1, 7]},
			  {"zoom":[14, 17], "links":[0, 1, 2, 3, 4, 5, 6, 7], "icons":[0, 1, 2, 3, 4, 5, 6, 7]}];

var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

var searchIcon = new GIcon();
searchIcon.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
searchIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
searchIcon.iconSize = new GSize(12, 20);
searchIcon.shadowSize = new GSize(22, 20);
searchIcon.iconAnchor = new GPoint(6, 20);
searchIcon.infoWindowAnchor = new GPoint(5, 1);

var mgr;
var map;
    			var geocoder = null;

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));

				GEvent.addListener(map, "moveend", function() {
				var center = map.getCenter();
				document.getElementById("message").innerHTML = "The map center (&deg;latitude, &deg;longitude) is: " + center.toString();
				});

		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(35.934097, -83.825684), 11);
        map.enableDoubleClickZoom();
		
		        geocoder = new GClientGeocoder();

		window.setTimeout(marker_setup, 0);
      }
    }

function marker_setup() {
	mgr = new GMarkerManager(map);
	for (var i in layers) {
		var layer = layers[i];
		var markers = [];
		for (var j in layer["links"]) {
			var index = layer["links"][j];
			var point = new GLatLng(locs[index]["pos"][0], locs[index]["pos"][1]);
			var tab = locs[index]["tabs"];
			markers.push(new_marker(point, layer["icons"][j], tab)); 
		}
		mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
	}
	mgr.refresh();
}

function new_marker(point, index, info) {
	var marker;
	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	var icon = new GIcon(baseIcon);
	icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
	if (index < 0) {marker = new GMarker(point);}
	else {marker = new GMarker(point, icon);}
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowTabsHtml(info);});
	return marker;
}

function showAddress(address) {
	if (geocoder) {
	geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
				alert(address + " not found");
			} else {
				map.setCenter(point, 13);
				var center = map.getCenter();
				document.getElementById("message").innerHTML = center.toString();
				var marker = new GMarker(point, searchIcon);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}
