// Get window dims before everything loads
FastInit.addOnLoad(loadGMap);

// When browser is resized center layout
window.onresize=function(){
	//alertSize();
}


// if the map div exists on unload call GMap unload function
if (document.getElementById("map")) {	
	window.onunload=function(){
		GUnload();
	}
}


function alertSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if(myWidth > 1022) {
		document.getElementById('container').style.left = ((myWidth/2)-511)+'px';
	} else {
		document.getElementById('container').style.left = '0px';
	}
	if(myHeight > 620) {
		document.getElementById('container').style.top = ((myHeight/2)-310)+'px'; 
	} else {
		document.getElementById('container').style.top = '0px';
	}
}

/* 

	Google Map notes:

	- GMap requires a unique key per domain for their API
	- The key gets added to the javascript API reference in the location file
	- Need Longitude and Latitude for each location, each copy of "common.js" will need these coordinates
		-http://maps.google.com/maps/geo?q=27+Church+Street,+Cambridge+MA&output=csv&key=ABQIAAAAhvtCISaRiyRbuN7WmOMMdhRuXA9IYUDRjsz6aOJRd0zqMqeVHBTLu4Fvud136vHOGscmJrVyIyyysA
	- Need a unique "get direction" URL for each copy of the location file
	
*/

function loadGMap() {
	if (document.getElementById("map")) {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			if (document.getElementById("map").className=="cambridge") {
				map.setCenter(new GLatLng(42.374379,-71.119964), 15);
			}
			if (document.getElementById("map").className=="boston") {
				map.setCenter(new GLatLng(42.343839,-71.100460), 15);
			}
			map.openInfoWindowHtml(map.getCenter(),document.getElementById('mapInfoWin').innerHTML);
		}
	}
}
