// Browser 1.5
// v1.5 25-03-2010
// v1.0 22-06-2007
// Benzin Framework
// Copyright 2007-2010 Rolling Mill

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isFF  = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
var isSafari  = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var minWidth = 800;//720;
var minHeight = 550;

var maxWidth = 3600;//1280
var maxHeight = 2000;//900

var addH = 0;
var addW = 0;
var resizeDelay;

function browserInit(){
	//window.onresize = resizeHandler;
	window.onresize =function(){
		clearTimeout(resizeDelay);
		resizeDelay=setTimeout("resizeHandler()", 200);
	}

	resizeHandler();
	if (isFF)
		resizeHandler();
}

function resizeDiv(divID, width, height){
	e=document.getElementById(divID);
	//alert("resize: " + height);
	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 h;
	var w;
	var offset;
	var vOffset = 0;
	if (isIE)
		offset = -21;
	else if (isFF){
		offset = -20;
		vOffset = -5;
	}
	else if (isSafari){
		offset = -2;
		vOffset = -4;	
	}
	else
		offset = 0;
	if (document.body.offsetWidth < minWidth){
		if (!isFF)
			document.body.style.overflowX = "scroll";
			
		w = document.body.offsetWidth-0;
	}
	else {
		document.body.style.overflowX = "hidden";
			
		w = document.body.offsetWidth-0;
	}

	if (document.body.offsetHeight < minHeight){
		if (!isFF)
		 	document.body.style.overflowY = "scroll";
			
		 h = document.body.offsetHeight-0;
	}
	else {
    	 if (!isFF)
			 document.body.style.overflowY = "hidden";
	
		h = document.body.offsetHeight-0;
	}
	
	if (addH > 0){
		if (!isFF)
			document.body.style.overflowY = "scroll";
	}
	else {
		if (!isFF)
			document.body.style.overflowY = "hidden";
	}
	
	if (addW > 0){
		if (!isFF)
			document.body.style.overflowX = "scroll";
	}
	else{
		if (!isFF)
			document.body.style.overflowX = "hidden";
	}


	resizeDiv('flashcontent', w+addW, h+addH)
}

function adjustHeight(amt){
	//alert(amt);
	addH = amt;
}

function adjustWidth(amt){
	addW = amt;
}

function resetHeight(){
	//alert(amt);
	addH = 0;
	resizeHandler();
}

function resetWidth(){
	addW = 0;
	resizeHandler();
}

function getWindowHeight(){
	return document.body.offsetHeight;	
}

function getWindowWidth(){
	return document.body.offsetWidth;
}
