// at least Internet Explorer 7
var gteIE7 = true /*@cc_on && @_jscript_version > 5.7 @*/;

window.onload = load;


var sideNav;
var header;
var content;

function load()
{
	if (gteIE7 == true) {
		// js code for IE8 and non-IE browsers
		window.onscroll = scroll;
		window.onresize = scroll;
		sideNav = document.getElementById('side_nav');
		header = document.getElementById('title_header');
		content = document.getElementById('content');
		scroll();
	}
}

function scroll()
{
	if (getScrollHeight() > 162) {
		if (header && content && header.style.position == '') {
			// Take the side nav and header out of normal flow and float
			header.style.position = 'fixed';

			// The header has been removed from flow from above Content,
			// so set its top so it doesn't jump up'
			content.style.top = header.clientHeight + 'px';
			content.style.marginBottom = header.clientHeight + 'px';
		}

		if (sideNav && sideNav.style.position == '') {
			sideNav.style.position = 'fixed';
		}
	} else {
		if (header && content && header.style.position == 'fixed') {
			header.style.position = '';
			content.style.top = '0';
			content.style.marginBottom = '0';
		}
		if (sideNav && sideNav.style.position == 'fixed') {
			sideNav.style.position = '';
		}
	}
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;

   return h ? h : 0;
}