
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number')
		windowWidth = window.innerWidth;
	else
		if (document.documentElement && document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth;
		else
			if (document.body && document.body.clientWidth)
				windowWidth = document.body.clientWidth;
	return windowWidth;
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number')
		windowHeight = window.innerHeight;
	else
		if (document.documentElement && document.documentElement.clientHeight)
			windowHeight = document.documentElement.clientHeight;
		else
			if (document.body && document.body.clientHeight)
				windowHeight = document.body.clientHeight;
	return windowHeight;
}

function setFooter() {
	var windowHeight = getWindowHeight();
	if (windowHeight > 0) {
		var header = getByID('header');
		var content = getByID('wrapper_main');
		var left = getByID('left');
		var footer = getByID('footer');
		
		if(!header || !content || !left || !footer)
			return;
			
		var headerHeight  = header.offsetHeight;
		var contentHeight  = content.offsetHeight;
		var footerHeight  = footer.offsetHeight;

		if (windowHeight - (headerHeight + contentHeight + footerHeight) >= 0) {
			footer.style.position = 'absolute';
			footer.style.top = (windowHeight - footerHeight) + 'px';
		}
		else
			footer.style.position = 'static';

		left.style.height = (windowHeight - headerHeight - footerHeight) + 'px';
	}
}

function getByID(id) {
	if (document.getElementById)
		return document.getElementById(id);
	else if (document.all)
		return document.all[id];
	else if (document.layers)
		return document.layers[id];
	else
		return false;
}

window.onresize = function() { setFooter(); }

var updFooter;

$(function() {
	setFooter();
	updFooter = setInterval('setFooter()', 1000);
	setTimeout('clearInterval(updFooter)', 15000);
	
	if ($("#okbox")) {
		$("#okbox").fadeIn(500, function() {
				setTimeout('$("#okbox").fadeOut(2000)', 2000);
			});
	}
	if ($("#errbox")) {
		$("#errbox").fadeIn(500, function() {
				setTimeout('$("#errbox").fadeOut(2000)', 15000);
			});
	}
});
