/* Global Javascript */

// this will be our minimum width and minimum height
var minwidth = 925;
var minheight = 620;

// 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;
	//}
}


// Get Flash Movie
function getFlashMovieObject(movieName) {
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1) {
        if (document.embeds && document.embeds[movieName])
        return document.embeds[movieName]; 
    } else {
        return document.getElementById(movieName);
    }
}


// Check for Size
function checkForSize(){
	var w = getWindowWidth();
	var h = getWindowHeight();
	var e = document.getElementById("Content");
	
	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%";
	}
	
    var flashMovie=getFlashMovieObject("postal_natal");
    if(w<minwidth)
        w=minwidth;
    if(h<minheight)
        h=minheight;
    flashMovie.resizeFlash(w,h);
}


// 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 + ', location=0, resizable=0, scrollbars=0, toolbar=0, menubar=0, status=0, left=' + iLeft + ', top=' + iTop );
}


// INITIALIZER
window.onload = checkForSize;
window.onresize = checkForSize;
