var map;

// FUNCTION RUN AT BODY ONLOAD TO INITIALIZE THE MAP
function load() {
	if (google.maps.BrowserIsCompatible()) {
	
		// CREATE A MAP AND ADD THE CONTROL INTERFACE
		map = new google.maps.Map2(document.getElementById("map"));
		var bottomRight = new google.maps.ControlPosition(G_ANCHOR_BOTTOM_RIGHT, new google.maps.Size(20,30));
		map.addControl(new google.maps.LargeMapControl3D(),bottomRight);
		map.setCenter(new google.maps.LatLng(41.248694,-95.988201), 4);
		
		// AN ARRAY TO HOLD LOCATION INFORMATION
		var MyLocs = new Array();
		
		// JQUERY SCRIPT FOR CREATINgoogle.maps. LOCATION LIST and MAP MARKERS
		$('#main-loc-inside').ready(function() {
											 
			// COLLECT ALL THE DEFINED PLACES
			var places = $('.loc');

			// FOR EACH PLACE, ASSIgoogle.maps.N AN ID AND CREATE A LIST ITEM
			places.each(function(i) {
				$(this).attr("id","place"+i)
							
				// DEFINE A NEW MAP POINT
				MyLocs[i] = new Object();
				MyLocs[i].id = i;
				MyLocs[i].position = eval("new google.maps.LatLng(" + $(this).find('.geocode').eq(0).text() + ")");
				MyLocs[i].marker = new google.maps.Marker(MyLocs[i].position);
				MyLocs[i].content = $(this).html();
								
				map.addOverlay(MyLocs[i].marker);
				google.maps.Event.addListener(MyLocs[i].marker, "click", function (loc) {
					map.setCenter(MyLocs[i].position);
					map.openInfoWindowHtml(MyLocs[i].position, MyLocs[i].content);
				});

				$(this).find('h4').eq(0).click(function() {
					map.setCenter(MyLocs[i].position);
					map.setZoom(8);
					map.openInfoWindowHtml(MyLocs[i].position, MyLocs[i].content);
					document.location.href="#top";
				});
				
				$(this).find('h4').eq(0).css({ cursor: 'pointer', textDecoration: 'underline' });


			});
		});
	}
}			

function IsolateState(code) {
	if (google.maps.BrowserIsCompatible()) {
		var position = eval("new google.maps.LatLng(" + code + ")");
		map.setCenter(position);
		map.setZoom(6);
	}
}

