var map;

function GetWindowWidthHeight () {
	var myWidth = 0, myHeight = 0;
	if(typeof(window.innerWidth) == 'number')
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	return {'width' : myWidth, 'height' : myHeight};
}

function sizeMap () {
	var w = GetWindowWidthHeight().width;
	var h = GetWindowWidthHeight().height;

	center_w = w/2;
	m = document.getElementById("map");
	if (m) { m.style.top = 0; m.style.left = 0;  m.style.width=w; m.style.height=h; }
	s = document.getElementById("stop_button");
	if (s) { s.style.left = w-214; }
	l = document.getElementById("learn_button");
	if (l) { l.style.left = w-212; }
	i = document.getElementById("info");
	if (i) { i.style.top = h-244; }
}



function setInitialZoom () {
	var w = GetWindowWidthHeight().width;
	var h = GetWindowWidthHeight().height;
	
	if (w >= 1390 && h >= 730) {
	  map.setZoom(5);
	} else if (w >= 750 && h >= 375) {
	  map.setZoom(4);
	} else {
	  map.setZoom(3);
	}
}

window.onresize = function() { sizeMap() };

window.onload = addCodeToFunction(window.onload,function() {

	if (GBrowserIsCompatible()) {    
		sizeMap();
		map = new GMap2(document.getElementById("map"));
		map.setCenter(USCenter, 4);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setMapType(G_SATELLITE_MAP);
		setInitialZoom();
		addMarkers();
	} else {
		alert("Sorry, your browser isn't compatible with Google Maps!")
	}
	
	setTimeout("new Effect.Fade('splash')", 3500);
	setTimeout("new Effect.Appear('stop_button')", 4000);
	setTimeout("new Effect.Appear('learn_button')", 4000);
	setTimeout("new Effect.SlideDown('map_title')", 4000);
	setTimeout("new Effect.Appear('info');", 4000);
	setTimeout("setInterval(\"$('stop_image').src='images/stop_flash.png';\", 1000);", 5000);
	setTimeout("setInterval(\"$('stop_image').src='images/stop.png';\", 1000);", 5500);
	setTimeout("openingPan();", 5000);
});



