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;
				//alert('body width:' + document.body.clientWidth);
			}
		}
	}
	return windowHeight;
}

function setFooter() {
	if (document.getElementById) 
	{
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) 
		{
			var headerElement = document.getElementById('header');
			var headerHeight  = headerElement.offsetHeight;
			
			var contentElement = document.getElementById('mainContent');
			var contentHeight  = contentElement.offsetHeight;
			var footerElement;
			var footerHeight;
			if(document.getElementById('footer') != null)
			{
				footerElement = document.getElementById('footer');
				footerHeight  = footerElement.offsetHeight;
				//contentElement.style.height ='';
				//return;
			}
			var stuffHeight = headerHeight + footerHeight;
			if(!document.all)
			{
				if(document.getElementById('_ctl0_MainContent_ucInboxControl_radSplitterInbox') != null)
					{
						contentElement.style.height = windowHeight - stuffHeight;
						SetSplitterHeight(windowHeight - stuffHeight - 20,(windowHeight - stuffHeight));
						//SetSplitterHeight(stuffHeight);
					}	
			}
			if (windowHeight - stuffHeight >= 0 && dcontentHeight <=  (windowHeight - stuffHeight)) 
			{
					contentElement.style.height = windowHeight - stuffHeight - 4;
					if(document.getElementById('_ctl0_MainContent_ucInboxControl_radSplitterInbox') != null)
					{
						SetSplitterHeight(windowHeight - stuffHeight - 3,0);
					}
			}		
		}
	}
}

function resize_add_handler(obj, evt, handler, captures) 
{ 
        if (obj.addEventListener) 
                obj.addEventListener(evt, handler, captures); 
        else if (obj.attachEvent) 
                        obj.attachEvent('on' + evt, handler); 
        else 
        { 
                var old_handler = obj['on' + evt]; 
                if (null == old_handler) 
                        obj['on' + evt] = handler; 
                else obj['on' + evt] = function() 
                { 
                old_handler(); 
                handler(); 
                } 
        } 
}

var dcontentHeight;
/*
window.onload = function() {
	dcontentHeight = document.getElementById('mainContent').offsetHeight;
	setFooter();
}
*/
resize_DocOnLoad = function() {
	dcontentHeight = document.getElementById('mainContent').offsetHeight;
	setFooter();
}

resize_add_handler(window, 'load', resize_DocOnLoad, false);

window.onresize = function() {
	setFooter();
}
