
Event.observe(window,'load',function(){
	if(GBrowserIsCompatible()) {
		
		var map			=	new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		
		var cmuPT	=	new GLatLng(-34.928102, 138.601842);
		
		var cmuMK	=	new GMarker(cmuPT,null,false);
		
		GEvent.addListener(cmuMK, "click", function() { cmuMK.openInfoWindowHtml(buildDirectionContent("Carnegie Mellon", "220 Victoria Square, Adelaide, Australia")); } );
		
		map.setCenter(cmuPT,13);
		map.addOverlay(cmuMK);
	}
});



function buildDirectionContent(title, string) {
	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('" + string + "')\" 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");
}