/* 
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not. 
*/
var flashDiv;
var flashResizable;
var flashHolderWidth;
var flashHolderHeight;
var prevFlashHolderWidth;
var prevFlashHolderHeight;

function getFlashWidth()
{
	return Number(document.getElementById(flashDiv).style.width.substr(-2));
}

function getFlashHeight()
{
	return Number(document.getElementById(flashDiv).style.height.substr(-2));
}
function setFlashWidth(newW){
	document.getElementById(flashDiv).style.width = newW+"px";
}
function setFlashHeight(newH){
	document.getElementById(flashDiv).style.height = newH+"px";		
}
function setFlashDiv(divid){
	flashDiv = divid;
	if( canResizeFlash() == "1" )
	{
		flashResizable = true;
	}else{
		flashResizable = false;	
	}
}
function setFlashSize(newW, newH){
	setFlashWidth(newW);
	setFlashHeight(newH);
}


function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}
function updateFlashHolderSize(){
	
	var myWidth = 0;
	var 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;
	}
	
	var minContentWidth = 940;
	var minContentHeight = 540;
	
	prevFlashHolderWidth = flashHolderWidth;
	prevFlashHolderHeight = flashHolderHeight;
	
	if( myWidth < minContentWidth )
	{
		flashHolderWidth = minContentWidth;	
	}
	else
	{
		flashHolderWidth = myWidth;
	}
	
	if( myHeight < minContentHeight )
	{
		flashHolderHeight = minContentHeight;	
	}
	else
	{
		flashHolderHeight = myHeight;
	}
	
	// set flash size
	if(flashResizable)
	{
		var windowWidthOffset = flashHolderWidth;
		var windowHeightOffset = flashHolderHeight;
		
		if( typeof( window.innerWidth ) == 'number' ) {
						
			if(flashHolderWidth != prevFlashHolderWidth){
				//windowWidthOffset -= 30;
			}
			
			if(flashHolderHeight != prevFlashHolderHeight){
				//windowHeightOffset -= 30;
			}
			setFlashSize(windowWidthOffset, windowHeightOffset);
			
		}else{

			setFlashSize(flashHolderWidth, flashHolderHeight);
		}
	}
	
	//alert("setting flashHolder to " + flashHolderWidth + "x" + flashHolderHeight + " current: " + myWidth + "x" + myHeight);
}




