$(document).ready(function(){
	
	

var marker = new Array();
$mapArea = $("#map");
pointLocation = "";
if($mapArea.attr("class") == "east_hartford"){
	pointLocation = new Array(	new GPoint(-72.6623, 41.7676) 	);
}
else if($mapArea.attr("class") == "worcester"){
	pointLocation = new Array(new GPoint(-71.798015, 42.256693));
}

startLocation = pointLocation[0];
if($mapArea.attr("class") == "east_hartford"){
	location_description = new Array(
		'<h1>ForeSite Technologies</h1><h3>East Hartford, CT</h3>' // East Hartford
		);
}
else if($mapArea.attr("class") == "worcester"){
	location_description = new Array(
	'<h1>ForeSite Technologies</h1><h3>Worcester, MA</h3>' // East Hartford
	);
}
if($mapArea.attr("class") == "east_hartford"){
directions = new Array(
	'99 East River Drive, East Hartford, CT 06108' // East Hartford
	);

}
else if($mapArea.attr("class") == "worcester"){
directions = new Array(
	'4 Ash Street, Worcester, MA 01610' // Worcester
	);
	
}

var popupDirections = ''+
	'<form action="http://maps.google.com/maps" method="get" style="width:300px;margin:0;margin-top:.5em;margin-bottom:.5em;" target="_blank">'+
		'<fieldset style="padding:4px;border:1px solid #91A6CB;text-align:center;">'+
			'<input type="hidden" name="daddr" id="daddr" value="*daddr*" />'+
			'<input type="hidden" name="hl" value="en" />'+
			'<legend>Get directions from</legend>'+
			'<input type="text" name="saddr" style="width:240px;margin:0;" value="Starting Location" /> '+
			'<input type="submit" value="Go" />'+
		'</fieldset>'+
	'</form>';


function zoomTo(item){
	map.centerAndZoom(pointLocation[item],2);
	showInfo(item);
}

var map = new Object();
function buildMap(){
	map = new GMap(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.centerAndZoom(startLocation, 2);
	
	for (i=0;i<pointLocation.length;i++){
			marker[i] = new GMarker(pointLocation[i]);
			eval("GEvent.addListener(marker[i], \"click\", function(){showInfo("+i+");})");
			map.addOverlay(marker[i]);	
	}
	
	showInfo(0);
}

$(document).ready(function(){
						   
	buildMap();
});
function showInfo(id){
	marker[id].openInfoWindowHtml('<div class="map_popup_message" style="width: 300px; height: 150px">'+location_description[id]+(popupDirections.replace('*daddr*',directions[id]))+'</div>');
}
});