isBig=false;

function refreshFlashMoviePosition() {

	if(isBig==true) {
		refreshBig();
	} else {
		refreshSmall();
	}

}

function refreshBig() {

	//alert ("refresh big");
	// container first
	var container = document.getElementById("container");

	container.style.left="50%";
	container.style.top="50%";
	
	// half of the new width
	container.style.marginLeft= "-475px";
	container.style.marginTop= "-262px";
	container.style.position="fixed";


}

function refreshSmall() {

	
	var container = document.getElementById("container");

	var placeholder = document.getElementById("placeholder");
	var leftSide=getPosition(placeholder)[0];
	var topSide=getPosition(placeholder)[1];

// alert ("refresh small " + leftSide);

	container.style.left = leftSide + 'px';
	container.style.top = topSide + 'px';

	container.style.marginLeft= "0px";
	container.style.marginTop= "0px";

	container.style.position="absolute";


	container.style.visibility="visible";


}

function refreshOnScroll() {
	// keeps it positioned on the screen
	/*
	if (isBig==true) {
		var container = document.getElementById("container");
		container.style.top=document.body.scrollTop;
	}
	*/
}


function makeSmall() {
	document.getElementById("controlTable").style.display="none";

	isBig=false; 

	var container = document.getElementById("container");
	container.style.width="685px";
	container.style.height="385px";

	hideOverlay();

	// now the flash file
	if (document.embeds && document.embeds['flashMapEmbeded']) {
	// it's mozilla or other
	// the embed tag CAN use the id/getElementById, but not always.
	//alert ("mozilla!");
		var swfEmbeded = document.embeds['flashMapEmbeded'];
		swfEmbeded.setAttribute("width","685px");
		swfEmbeded.setAttribute("height","385px");
	
	} else {
	// it's microsoft
	//alert ("microsoft!");
		var swf = document.getElementById("flashMap");
		swf.setAttribute("width","685px");
		swf.setAttribute("height","385px");
	}
	//flashMapEmbed
	//swf.style.visibility="hidden";

	refreshSmall();
}


function makeBig() {
	isBig=true;

	showOverlay();

	var container = document.getElementById("container");
	container.style.width="950px";
	container.style.height="525px";


	refreshBig();

	// now the flash file
	if (document.embeds && document.embeds['flashMapEmbeded']) {
	// it's mozilla or other
	// the embed tag CAN use the id/getElementById, but not always.
	//alert ("mozilla!");
		var swfEmbeded = document.embeds['flashMapEmbeded'];
		swfEmbeded.setAttribute("width","950px");
		swfEmbeded.setAttribute("height","525px");
	
	} else {
	// it's microsoft
	//alert ("microsoft!");
		var swf = document.getElementById("flashMap");
		swf.setAttribute("width","950px");
		swf.setAttribute("height","525px");
	}
	//flashMapEmbed
	//swf.style.visibility="hidden";

	document.getElementById("controlTable").style.display="block";

	
}

/////////////////////////////////////////


function getPosition(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}
 
	return [curleft,curtop];
}



/////////////////////////////////////// OVERLAY STUFF


function showOverlay() {

	var arrayPageSize = getPageSize();

	//alert(arrayPageSize[1]);

	var objOverlay = document.getElementById('overlay');
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = "block";
	objOverlay.style.visibility = 'visible';
}

function hideOverlay() {
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
}


function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
