var minWidth=-1;
var minHeight=-1;

var resizeSwfArray;
function setResizeArray(extSwfObjectArray)
{
	resizeSwfArray=extSwfObjectArray;
}
		
function setFlashSize(flashWidth,flashHeight)
{
	minWidth = flashWidth;
	minHeight = flashHeight;
	divResize();
	window.scrollTo(0,0);
	callOffset()
}

function setScrollPosition(x_offset,y_offset)
{
	window.scrollTo(x_offset,y_offset);
}

window.onload=function()
{
	divResize();
}
window.onresize=function()
{
	divResize();
	callOffset();
}


function getWindowSize()
{
	var winH, winW;
	if (parseInt(navigator.appVersion)>3) {
		if ( document.body.offsetWidth ){ // Gecko / WebKit
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		} else if ( document.body.offsetWidth ){ // MS
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	return { height: winH, width: winW };
}
function divResize()
{
	var winSize = getWindowSize();
	var w, h, min_w, min_h;
	
	if(minWidth == -1 )
	{
		min_w = "0px";
		w="100%"
	}else{
		w = winSize.width < minWidth ? minWidth+"px" : "100%";
		min_w = minWidth+"px";
	}
	
	if(minHeight == -1)
	{
		min_h = "0px";
		h = "100%";
	}else{
		h = winSize.height < minHeight ? minHeight+"px" : "100%";
		min_h = minHeight+"px";		
	}
	if( document.all ) document.body.scroll = ( w!="100%" || h!="100%" )? "auto" : "no";
	
	document.getElementById("flashContainer").style.minWidth = min_w;
	document.getElementById("flashContainer").style.minHeight = min_h;
	document.getElementById("flashContainer").style.width = w;
	document.getElementById("flashContainer").style.height = h;
}

window.onscroll = function()
{
    callOffset()
}

function callOffset()
{
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var dsocleft=document.all? iebody.scrollLeft : window.pageXOffset
	var dsoctop=document.all? iebody.scrollTop : window.pageYOffset
	
	var winSize = getWindowSize();
	
	var dsocright=minWidth-winSize.width-dsocleft;
	var dsocbottom=minHeight-winSize.height-dsoctop;
	
	var obj;
	for(var i=0; i<resizeSwfArray.length; i++ )
	{
		obj = swfobject.getObjectById(resizeSwfArray[i]);
		if( typeof( obj.setScrollOffset ) == 'function' )
		{
			obj.setScrollOffset( dsoctop , dsocleft, dsocright, dsocbottom);
		}
	}
}
