var locations = {};
var map = null;

function loadmap(key, def_location) {
	if ('company'==key) {
		locations = {
			'spokane':    [47.78982, -117.35315],
			'tacoma':     [47.239664,-122.360662],
			'kennewick':  [46.191818,-119.168387],
			'moses_lake': [47.113416,-119.298768],
			'yakima':     [46.623184,-120.511869],
			'portland':   [45.445872,-122.743968]
		};
	} else {
		locations = {
			"horse_whisper": [47.960127,-117.271671],
			"harrison":      [47.475299,-117.811525],
			"lacrosse":      [47.695577,-117.271135],
			"montgomery":    [47.988627,-117.436466],
			"moses_lake":    [47.157995,-119.305915],
			"bernath":       [46.190782,-119.075451],
			"pasco":         [46.233865,-119.074582],
			"prosser":       [46.203922,-119.767306]
		};
	};

	google.load('maps', '2.x');
	google.setOnLoadCallback(function() {
		map = new google.maps.Map2($('#location-map').get(0));
		var center = new GLatLng(locations[def_location][0], locations[def_location][1]);
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		$.each(locations, function(k, v) {
			var point = new GLatLng(v[0], v[1]);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			GEvent.addListener(marker, 'click', function() {
				map.openInfoWindowHtml(point, $('#'+k).html());
			});
		});
		map.setCenter(center, 13);
	});
}

function setLocation(location) {
	map.setCenter(new GLatLng(locations[location][0], locations[location][1]), 13);
}
