/* Global Javascript */

// this will be our minimum width and minimum height
var minwidth = 960;
var minheight = 765;

// Get Window Width
function getWindowWidth(){
	var r;
	
	if (document != null && document.body != null) {
		r = document.body.clientWidth;
	} else if (document != null && document.documentElement != null) {
		r = document.documentElement.clientWidth;
	}
	if(!Browser.Engine.trident4){
		return r;
	}
}

// Get Window Height 
function getWindowHeight(){
	var r;
	
	if (document != null && document.body != null) {
		r = document.body.clientHeight;
	} else if (document != null && document.documentElement != null) {
		r = document.documentElement.clientHeight;
	}
	if(!Browser.Engine.trident4){
		return r;
	}
}

// Check for Size
function checkForSize(){
	var w = getWindowWidth();
	var h = getWindowHeight();
	var e = $("flashcontent");
	
	if (w == null || h == null || e == null)
	return;
	
	//alert(w + '+' + h + '=' + e);
	
	if (w < minwidth) {
		e.style.width = minwidth + "px";
	} else {
		e.style.width = "100%";
	}
	
	if (h < minheight) {
		e.style.height = minheight + "px";
	} else {
		e.style.height = "100%";
	}
}


// Window Resize and Center
function resizeCenterWindow(sUrl, sName, iWidth, iHeight) {
	var iLeft;
	var iTop;
	
	if (screen.width > iWidth) {
		iLeft = parseInt((screen.width - iWidth) / 2);
	} else {
		iLeft = 0;
	}
	
	if (screen.height > iHeight) {
		iTop = parseInt((screen.height - iHeight) / 2);
	} else {
		iTop = 0;
	}
	
	window.open(sUrl, sName, 'width=' + iWidth + ', height=' + iHeight + ', resizable=0, scrollbars=0, toolbar=0, menubar=0, status=0, left=' + iLeft + ', top=' + iTop );
}


// INITIALIZER
window.addEvent('domready', function(){
	checkForSize();
});
window.addEvent('load', function(){
	checkForSize();
});
window.addEvent('resize', function(){
	checkForSize();
});

