// Browser 1.0
// 22-06-2007
// Benzin (Miguel Vieira 2009)
// Ricardo Moutinho

var isFull = false;

function browserInit(){
	window.onresize = resizeHandler;
	resizeHandler();
	
}


function setFullscreen(full){
	isFull = full;
	resizeHandler();
}

function resizeDiv(divID, width, height){
	
	e=document.getElementById(divID);

	if (isFull == true){
		var minWidth = 990;
		var minHeight = 570;
	
		var maxWidth = width;
		var maxHeight = height;
		
		if (width > minWidth){
			e.style.width = width + 'px';
		}
		else {
			e.style.width = minWidth + 'px';
		}

		if (height > minHeight){
			e.style.height = height + 'px';
		}
		else {
			e.style.height = minHeight + 'px';
		}
		document.getElementById('flashcontent').style.marginTop = "0px";
		document.getElementById('flashcontent').style.top = "0%";
		document.getElementById('flashcontent').style.marginLeft = "0px";
		document.getElementById('flashcontent').style.left = "0%";
	}
	else
	{
		var minWidth = 990;
		var minHeight = 570;
	
		var maxWidth = 990;
		var maxHeight = 570;
		
		if ((height > minHeight) && (height < maxHeight)){
			e.style.height = height + 'px';
			document.getElementById('flashcontent').style.position = "relative";
			document.getElementById('flashcontent').style.marginTop = "0px";
			document.getElementById('flashcontent').style.top = "0px";
		}
		else if (height > maxHeight)
		{
			e.style.height = maxHeight + 'px';
			var targetTop = -(maxHeight/2) + 'px';
			document.getElementById('flashcontent').style.marginTop = targetTop;
			document.getElementById('flashcontent').style.top = "50%";
			document.getElementById('flashcontent').style.position = "absolute";
		}
		else if (height < minHeight){
			document.getElementById('flashcontent').style.marginTop = "0px";
			document.getElementById('flashcontent').style.top = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
	
	
		if ((width > minWidth) && (width < maxWidth)){
			e.style.width = width + 'px';
			document.getElementById('flashcontent').style.marginLeft = "0px";
			document.getElementById('flashcontent').style.left = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
		else if (width > maxWidth)
		{
			e.style.width = maxWidth + 'px';
			var targetLeft = -(maxWidth/2) + 'px';	
			document.getElementById('flashcontent').style.marginLeft = targetLeft;
			document.getElementById('flashcontent').style.left = "50%";
			document.getElementById('flashcontent').style.position = "absolute";
		}
		else if (width < minWidth){
			document.getElementById('flashcontent').style.marginLeft = "0px";
			document.getElementById('flashcontent').style.left = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
	}
}


function resizeHandler(){
	var w = document.body.offsetWidth-21;
	var h = document.body.offsetHeight-4;
	//alert(w);
	resizeDiv('flashcontent', w, h)
}