var windowSet = false;
var winW = 0;
var winH = 0;

var minWidthOn = true;
var minWidth = 780;

var minHeightOn = true;
var minHeight = 500;

var setWinW = minWidth;
var setWinH = minHeight;

addLoadListener(initWindow);

//checks for page resize
function initWindow()
{
	window.onresize = function()
	{
		getPageSize();
		if(minHeightOn)
		{
			if(winH > minHeight){
				setWinH = winH;
			}
		}

		setElements();
	};
	window.onresize();
	return true;
}

function setElements()
{
	//add item here with id, and offset, and the dom object we are updating
	var toChangeID = [
		['flash' , 0, ['height']]
	];
	
	for(var i=0; i< toChangeID.length; i++)
	{
		var obj = document.getElementById(toChangeID[i][0]);
		if(obj)
		{
			for(j=0; j< toChangeID[i][2].length; j++)
			{
				if(toChangeID[i][2][j] == 'height')
				{
					obj.style.height = setWinH + "px";
				}
				else if(toChangeID[i][2][j] == 'width')
				{
					obj.style.width = setWinW + "px";
				}
			}
		}
	}
}

//set the window dimensions of the page
function getPageSize() 
{
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	  }
	  return true;
}

function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined'){
		window.addEventListener('load', fn, false);
	}else if (typeof document.addEventListener != 'undefined'){
		document.addEventListener('load', fn, false);
	}else if (typeof window.attachEvent != 'undefined'){
		window.attachEvent('onload', fn);
	}else{
		var oldfn = window.onload;
		if (typeof window.onload != 'function'){
		window.onload = fn;
		}else{
			window.onload = function(){
				oldfn();
				fn();
			};
		}
	}
}

