//<![CDATA[
var clicked = new Array();
var map_items = new Array();
map_items['schools'] = new Array();
map_items['arts'] = new Array();
map_items['service'] = new Array();
map_items['entertainment'] = new Array();
map_items['government'] = new Array();

map_items['schools']['District Office'] = '735 S. Main St, West Bend, WI';
map_items['schools']['Barton Elementary'] = '614 School Place, West Bend, WI';
map_items['schools']['Decorah Elementary'] = '1225 Sylvan Way, West Bend, WI';
map_items['schools']['Fair Park Elementary'] = '519 N. Indiana Avenue, West Bend, WI';
map_items['schools']['Green Tree Elementary'] = '1330 Green Tree Road, West Bend, WI';
map_items['schools']['Jackson Elementary'] = 'W204 N16850 Jackson Drive, Jackson, WI';
map_items['schools']['Badger Middle School'] = '710 S. Main St, West Bend, WI';
map_items['schools']['Silverbrook Middle School'] = '120 N. Silverbrook Dr, West Bend, WI';
map_items['schools']['East & West High Schools'] = '1305 E. Decorah Rd, West Bend, WI';
map_items['schools']['Moraine Park Technical College'] = '2151 N. Main St, West Bend, WI';
map_items['arts']['Old Courthouse Square Museum'] = '320 S. 5th Ave, West Bend, WI|http://www.historyisfun.com/';
map_items['arts']['Museum of Wisconsin Art'] = '300 S. 6th Ave, West Bend, WI|http://www.wisconsinart.org/';
map_items['arts']['Wisconsin Automotive Museum'] = '147 N Rural St, Hartford, WI|http://wisconsinautomuseum.com/';
map_items['arts']['Germantown Historical Society'] = 'N128 W18780 Holy Hill Road, Germantown, WI 53022|http://www.bastbellmuseum.com/';
map_items['arts']['Richfield Historical Society'] = '4399 Pleasant Hill Rd, Richfield, WI 53076|http://www.richfieldhistoricalsociety.org/';
map_items['arts']['West Bend Community Memorial Library'] = '630 Poplar Street, West Bend, WI 53095|http://www.west-bendlibrary.org/';
map_items['arts']['Germantown Community Library'] = 'N112W16957 Mequon Road, Germantown, WI 53022|http://germantownlibrarywi.org/';
map_items['arts']['Kewaskum Public Library'] = '206 First St, Kewaskum, WI 53040|http://www.kewaskum.lib.wi.us/';
map_items['arts']['Slinger Community Library'] = '220 Slinger Road, Slinger, WI 53086|http://www.slinger.lib.wi.us/';
map_items['arts']['Hartford Public Library'] = '115 North Main Street, Hartford, WI 53027-1596|http://hartfordlibrary.org/';
map_items['service']['Chamber of Commerce'] = '548 S. Main St, West Bend, WI';
map_items['service']['Hartford Food Pantry'] = '24 N Johnson St, Hartford, WI';
map_items['service']['Slinger Community Food Pantry'] = '119 Kettle Moraine Dr S, Slinger, WI';
map_items['service']['St. Boniface\'s Food Pantry'] = 'W204 N11940 Goldendale Road, Germantown, Wisconsin, 53022|http://www.stbonifacewi.org/about-us/food-pantry/';
map_items['service']['SHARE Wisconsin'] = '|http://www.sharewi.org/';

// SPORTS/ENTERTAINMENT
map_items['entertainment']['Lake Park Golf Course'] = 'N112 W17300 Mequon Rd, Germantown, WI 53022||262.255.4200';
map_items['entertainment']['Hartford Golf Club'] = '7072 Lee Road, Hartford, WI 53027|http://www.hartfordgolfclubwi.com';
map_items['entertainment']['Hon-E-Kor Golf &amp; Country Club'] = '1141 Riverview Drive, Kewaskum, WI 53040|http://www.hon-e-kor.com/';
map_items['entertainment']['Kettle Hills Golf Course'] = '3375 Highway 167 West, Richfield, WI 53076|http://www.kettlehills.com';
map_items['entertainment']['Arrowhead Springs Golf Course'] = '3468 Highway 167, Richfield, WI 53076|http://www.wisconsingolfonline.com/directory/coursedetail.cfm?recordid=128';
map_items['entertainment']['Scenic View Golf Course'] = '4415 Club Dr, Slinger, WI 53086|http://www.scenicviewcc.com';
map_items['entertainment']['Washington County Golf Course'] = '6439 Clover Road . Hartford, WI 53027|http://www.golfwcgc.com';
map_items['entertainment']['West Bend Lakes Golf Course'] = '1241 Highway 33 E . West Bend, WI|http://www.westbendlakesgolf.com/';
map_items['entertainment']['Blue Dog Golf &amp; Recreation'] = '601 E Paradise Dr West Bend, WI 53095||262-338-6655';
map_items['entertainment']['Logger\'s Park Sports Complex'] = '3208 HWY 167, Richfield WI|http://www.loggerspark.com/';
map_items['government']['Washington County'] = '432 East Washington St, West Bend, WI 53095|http://www.co.washington.wi.us/|262-335-4400';
map_items['government']['City of West Bend'] = '1115 S. Main Street, West Bend WI 53095|http://www.ci.west-bend.wi.us/';
map_items['government']['Town of West Bend'] = '6355 County Trunk Z, West Bend WI|http://www.town.west-bend.wi.us/';
map_items['government']['City of Hartford'] = '109 North Main Street, Hartford WI 53027|http://ci.hartford.wi.us/|(262) 673-8298';
map_items['government']['Village of Slinger'] = '300 Slinger Road, Slinger WI 53086-0227|http://www.slinger-wi-usa.org/|(262) 644-5265';
map_items['government']['Village of Kewaskum'] = '|http://www.village.kewaskum.wi.us/|262-626-8484';
map_items['government']['Village of Richfield'] = '4128 Hubertus Road Hubertus, WI 53033|http://www.richfieldwi.gov/|262-628-2260';
map_items['government']['Village of Germantown'] = 'N112 W17001 Mequon Road, Germantown, WI 53022|http://www.village.germantown.wi.us/|(262) 250-4785';
map_items['government']['Hubertus'] = 'Hubertus, WI|'
map_items['government']['Village of Newburg'] = '614 Main St, Newburg WI 53060|http://www.village.newburg.wi.us/|(262) 675-2160';

var map;
var geocoder = new GClientGeocoder();
var current = 'none';
var gmarkers = new Array();
var res = new Array();

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("community_info_map"));
		showAddress("West Bend, WI", false, false, true);

		// add zoom/type controls
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
	}
}

function showAddress(address, item, add_to_map, center, marker_type) {
  var customIcon = new GIcon(G_DEFAULT_ICON);
	customIcon.iconSize = new GSize(32, 32);
  if (marker_type == 'government') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon8.png";
  } else if (marker_type == 'schools') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon10.png";
  } else if (marker_type == 'service') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal3/icon44.png";
  } else if (marker_type == 'arts') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal4/icon13.png";
  } else if (marker_type == 'entertainment') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal5/icon52.png";
  } else if (marker_type == 'dining') {
    customIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon40.png";
  }

	geocoder.getLatLng(address,
		function(point) {
			if (!point) {
				// alert(item+':'+address + " not found");
			} else {
				if (center) {
					map.setCenter(point, 13);
				}
				
				if (add_to_map) {
					var marker = new GMarker(point , { icon:customIcon });
					gmarkers[item] = marker;
					map.addOverlay(marker);
					GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml('<strong>' + item + '</strong><br />' + address);
					});
				}
			}
		}
	);
}

var populate_map = function(items) {
	var parent = items;
	var items = map_items[items];
	if (current != items) {
		document.getElementById('community_info_text').innerHTML = '';

		for(i in items) {
			res[i] = items[i].split('|');
			
			if (!clicked[parent]) {
				// add markers to map	
				showAddress(res[i][0], i, true, false, parent);
			}

			if (res[i][1] == undefined) { res[i][1] = ''; } else { res[i][1] = '<br /><a href="'+res[i][1]+'" target="_blank">'+res[i][1]+'</a>'; }
			if (res[i][2] == undefined) { res[i][2] = ''; } else { res[i][2] = '<br />' + res[i][2]; }
			
			// add items to text list
			document.getElementById('community_info_text').innerHTML += '<p><strong><a href="#" onClick="openInfo(\''+i+'\');">' + i + '</a></strong><br />' + res[i][0] + res[i][1] + res[i][2] + '</p>';
		}
		clicked[parent] = 'TRUE';
		current = items;
	}
}


var openInfo = function(item) {
	gmarkers[item].openInfoWindowHtml('<strong>' + item + '</strong><br />' + res[item][0] + res[item][1] + res[item][2]);
}

window.onload = load;
window.onunload = GUnload;

//]]>

