
Event.observe(window,'load',function(){
	if(GBrowserIsCompatible()) {
		
		var map			=	new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		
		var sandylickPT	=	new GLatLng(41.151346, -79.080905);
		var maplevalePT	=	new GLatLng(41.173518, -79.099803);
		var centermapPT	=	new GLatLng(41.173518 + (41.151346 - 41.173518)/2,
										-79.080905 + (-79.099803 + 79.080905)/2);
		
		var sandylickMK	=	new GMarker(sandylickPT,null,false);
		var maplevaleMK	=	new GMarker(maplevalePT,null,false);
		
		GEvent.addListener(sandylickMK, "click", function() { sandylickMK.openInfoWindowHtml(buildDirectionContent("Sandy Lick Plant", "111 2nd ST, Brookville, PA 15825","41.151346,-79.080905")); } );
		GEvent.addListener(maplevaleMK, "click", function() { maplevaleMK.openInfoWindowHtml(buildDirectionContent("Maplevale Plant", "1000 Miller DR, Brookville, PA 15825","41.173518,-79.099803")); } );
		
		map.setCenter(centermapPT,13);
		map.addOverlay(sandylickMK);
		map.addOverlay(maplevaleMK);
	}
});



function buildDirectionContent(title, string,latlon) {
	ret_str	=	"<h5>" + title + "</h5>";
	ret_str	+=	"<p>" + string + "</p>";
	ret_str	+=	"<p style=\"padding-bottom:0px\">Get Directions to here:</p>";
	ret_str	+=	"<input type=\"text\" id=\"address\" width=\"30\" />";
	ret_str +=	"<input type=\"button\" onclick=\"Javascript:getDirections('" + latlon + "')\" value=\"Go &raquo;\" />";
	
	return ret_str;
}

function getDirections(to) {
	var from	=	document.getElementById("address").value;
	from = from.split(" ").join("+").split("#").join("");
	to = to.split(" ").join("+").split("#").join("");
	var uri	=	"http://maps.google.com/maps?f=d&hl=en&saddr=" + from + "&daddr=" + to;
	window.open( uri, "mapwindow");
}
