//DESCRIBES VARIABLES
//container id to be resize
var div_id = 'container_fullscreen';

//describe the minmum width and height
var flashWidthMin = 920;
var flashWidthMax = false;

var heightMin = 560;
var heightMax = false;

var flashWidth = 0;
var sideBarWidth = 0;

//limit for srinking of window 
var winW = 0;
var winH = 0;
var calH = 0;

addLoadListener(initWindow);

//checks for page resize
function initWindow()
{
	window.onresize = function()
	{
		squeeze();
		
	};
	window.onresize();
	return true;
}

//functions amends all page content if page is siz eis smaller than limit
function squeeze()
{
	//gets the height for the window
	getWindowData();

	//calculates the height for the window
	//in respect to the set min and max
	processHeight();
		
	//calculate two other elements widths
	calculateFlash();
		
	var flash = document.getElementById(div_id);

	if(calH <= heightMin)
	{
		flash.style.height = calH +"px";
	}
	else
	{
		flash.style.height = "100%";	
	}
	
	if(flashWidth <= flashWidthMin)
	{
		flash.style.width = flashWidth + "px";
	}
	else
	{
		flash.style.width = "100%";	
	}
	
	//flash.innerHTML = flashWidth+' x '+calH;
	
	if(heightMax)
	{
		if(winH > heightMax)
		{
			flash.style.top = ((winH-heightMax)/2)+ "px";
		}
		else
		{
			flash.style.top = "auto";
		}
	}
	
	
	
	//address.innerHTML = curPos+' , '+addPos;

	return false;
}

function getWindowData() 
{
	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;
	}
}

function processHeight()
{
	calH = winH;	
	if(heightMin)
	{
		if(calH < heightMin)
		{
			calH = 	heightMin;
		}
	}
	
	if(heightMax)
	{
		if(calH > heightMax)
		{
			calH = 	heightMax;
		}
	}
}

function calculateFlash()
{
	flashWidth = winW;
	if(flashWidthMin)
	{
		if(flashWidth < flashWidthMin)
		{
			flashWidth = flashWidthMin;
		}
	}
	
	if(flashWidthMax)
	{
		if(flashWidth > flashWidthMax)
		{
			flashWidth = flashWidthMax;
		}
	}
	return false;
}

function getElementHeight(Elem) 
{
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) { 
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	} 
}

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();
			};
		}
	}
}
