﻿/*
javascript fix to background not properly extending to 100% of document length in all browsers
sergey zarouski june 28.2010
*/
function fixMainBg() {
	var d = document;
	var mainWrapper = d.getElementById('aspnetForm');
	var docBody = d.getElementsByTagName('body')[0];
	var container = d.getElementById('container');
	
	var viewportheight;
	var property;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerHeight != 'undefined')
	{
		viewportheight = window.innerHeight;
		property = "min-height";
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined'
	&& typeof document.documentElement.clientWidth !=
	'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportheight = document.documentElement.clientHeight;
		property = "height";
	}
	
	// older versions of IE
	else
	{
		viewportheight = document.getElementsByTagName('body')[0].clientHeight;
		property = "height";
	}
	
	//mainWrapper.style.cssText = property+":"+viewportheight+"px;";
	//docBody.style.cssText = "min-height:1px;";

	if(docBody.offsetHeight > container.offsetHeight) {
		container.style.cssText = property+":"+viewportheight+"px";
	} else {
		container.style.cssText = "";
	}
}

window.onload = fixMainBg;

if(navigator.appVersion.search('MSIE 6') === -1) {
	window.onresize = fixMainBg;
}