
 
var flashWidth; var flashHeight; var flashElement;
var maxFlashWidth; var maxFlashHeight;
var safeFlashWidth; var safeFlashHeight;
var borderPercentage = 0.9;
var bkgOffset = -7;
	
/* From Flash, initialize width & height of flash element */
function initialize( w, h, mw, mh, sw, sh ) {

	flashElement = document.getElementById("content");
	flashElement.style.overflow = "hidden";  //since we are displaying the flash movie now we set the overflow to hidden to get rid of the vertical scrollbar
	window.onresize = doResize;
	maxFlashWidth = mw;	
	maxFlashHeight = mh;	
	safeFlashWidth = sw;
	safeFlashHeight = sh;
	setFlashDimensions( w, h );
}

/* called by flash whenever the width & height of the flash movie change, for testing purposes this is called onStageResize from Flash*/
function setFlashDimensions( w, h ){

	flashWidth = w;
	flashHeight = h;
	doResize();
}

/* End From Flash */


/* To Flash */

//pass browser width / height to Flash for display only using External Interface, not completely necessary
function showDimensions( w, h ){

	//id = swf id set within swfobject, example: var so = new SWFObject("example.swf", "id", "100%", "100%", "8", "#000000");
    thisMovie("id").showDimensions( w, h );
}

function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}

/* End To Flash */

var timeoutId;
var sh;

function doScroll()
{
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
			var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
			if (!(ffversion==2))
				window.scrollTo(0, sh);
		}
		else
			window.scrollTo(0, sh);
}
	
function doResize() {	

	var bw; var bh;
	//http://www.quirksmode.org/viewport/compatibility.html
	if (self.innerHeight) { // all except Explorer
		bw = self.innerWidth;
		bh = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
		bw = document.documentElement.clientWidth;
		bh = document.documentElement.clientHeight;
	}else if (document.body) { // other Explorers
		bw = document.body.clientWidth;
		bh = document.body.clientHeight;
	}
	
	flashElement.style.height = bh < flashHeight ? flashHeight + "px" :  bh+"px";//"100%";
	flashElement.style.width = bw < flashWidth ? flashWidth + "px" : bw + "px";//"100%";
	
	//var sw = 0; 
	//var sh = 0;
	
	//bh is the body height
	//flashHeight is the minimum flash height
	
	
	var offset = 0;
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
		offset = 15;
	}
	//if screen is shorter than minimum flash height = scrollbars
	if (bh < flashHeight)
	{
		// no margin for centre alignment
		flashElement.style.margin = "0px 0px 0px 0px";
		//flash dimensions are fixed for set positioning.
		flashElement.style.height = flashHeight + "px";
		//pixel position for autoscrolling.
		sh = flashHeight - bh + offset;//(flashHeight - bh)/2;
		
		//window.scrollTo(0, sh);
		
		//Test> if current browser is FF2.x then scrollTo statement isn-t executed
		
		clearTimeout ( timeoutId );
		timeoutId = setTimeout ( "doScroll()", 500 );

		
		document.getElementById("bkgContainer").style.height = flashElement.style.height;
		document.getElementById("bkgContainer").style.backgroundPosition = "0px " + (Math.ceil((flashHeight-977)/2) + bkgOffset) +"px";
	}
	//screen is larger than flash height.
	else
	{
		// if body is bigger than max flash size add a margin, otherwise no margin.
		//flashElement.style.margin = bh > maxFlashHeight ? ((bh-maxFlashHeight)/2) + "px 0px 0px 0px" :  "0px 0px 0px 0px";
	
		if (bh > maxFlashHeight*(2-borderPercentage)) //document is bigger than max flash.
		{
			flashElement.style.margin = ((bh-maxFlashHeight)/2) + "px 0px 0px 0px";
			flashElement.style.height = maxFlashHeight + "px";
		}
		else if (bh < safeFlashHeight) // document is within safe and minimum flash size.
		{
			flashElement.style.margin = "0px 0px 0px 0px";
			flashElement.style.height = "100%";
		}
		else // document is between max flash and safe size
		{
			if (bh > safeFlashHeight*(2-borderPercentage))//if document is bigger than border + safe area
			{
				flashElement.style.height = bh*borderPercentage + "px";
				flashElement.style.margin = ((bh - (bh*borderPercentage))/2) + "px 0px 0px 0px" ;
			}
			else
			{
				flashElement.style.height = safeFlashHeight + "px";
				flashElement.style.margin = ((bh - safeFlashHeight)/2) + "px 0px 0px 0px" ;
			}
		}
	
		
		// if body is bigger than max flash size set the flash size to the max flash size, otherwise set it to 100%.
		//flashElement.style.height = bh > maxFlashHeight ? maxFlashHeight + "px" :  "100%";//bh+"px";
		
		document.getElementById("bkgContainer").style.height = "100%";
		document.getElementById("bkgContainer").style.backgroundPosition = "0px " + (Math.ceil((bh-977)/2) + bkgOffset) +"px";
	}
//	document.getElementById("bkgContainer").style.top = -233 +"px";
	
	//977
	
	//bw is the body width
	//flashWidth is the minimum flash width
	if (bw < flashWidth)
	{
		//show scrollbars
		flashElement.style.width = flashWidth + "px";
		sw = (flashWidth - bw)/2;
		
		document.getElementById("bkgContainer").style.width = flashElement.style.width;
	}
	else
	{
		if (bw > maxFlashWidth*(2-borderPercentage))// document bigger than max flash width + border
		{
			flashElement.style.width = maxFlashWidth + "px";
		}
		else if (bw < safeFlashWidth) // document between safe flash and min flash
		{
			flashElement.style.width = "100%";
		}
		else // document between safe flash and max flash
		{
			if (bw > safeFlashWidth*(2-borderPercentage))// document is wider than border + safe area
			{
				flashElement.style.width = bw*borderPercentage + "px";
			}
			else
			{
				flashElement.style.width = safeFlashWidth + "px";
			}
			//flashElement.style.width = bw*borderPercentage + "px";
		}
		//flashElement.style.width = bw > maxFlashWidth ? maxFlashWidth + "px" :  "100%";//bw+"px";
		document.getElementById("bkgContainer").style.width = "100%";
	}
		
	
	
	/* Removed, seemed to be the reason this was crashing Firefox on Mac. */
	//showDimensions( bw, bh );
}
	
