/*------------------------------------------------------------------------
version: 1.1
author: andy windle
email: andy.windle@ama.uk.com
www.lexgulf.com
--------------------------------------------------------------------------*/
/* =General
--------------------------------------------------------------------------*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

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() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var container = document.getElementById('container');
			var mainContent = document.getElementById('mainContent');
			var contentHeight = container.offsetHeight;
			var headerHeight = document.getElementById('header').offsetHeight;
			//alert(contentHeight);
			var footerElement =	document.getElementById('footer');
			var sideNavigation = document.getElementById('sideNavigation');
			var footerHeight = footerElement.offsetHeight;
			if (windowHeight-(contentHeight+footerHeight)>=0) {
				//footerElement.style.position='relative';
				//footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';
				sideNavigation.style.height = (windowHeight-footerHeight-headerHeight)+'px';
				mainContent.style.border = 'none';
				container.style.background = 'none';
				sideNavigation.style.borderColor = '#7AB340';
			}
			else {
				//footerElement.style.position='static';
			}
		}
	}
}

addLoadEvent(setFooter);
