// var declaration
var agt=navigator.userAgent.toLowerCase();
var is_nav6up = ((is_nav && (is_major >= 5)) || (agt.indexOf('gecko') != -1));
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_major < 5));
var is_moz = (agt.indexOf('gecko') != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie55up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var MAC = navigator.platform.indexOf("Mac") != -1;
var demY = 0.7;
var sY = 0;
var accY = 24;
var lastScrY;
var clientY;
var logoY = 0;
var scrY = 0;
var topOffset;
var contentContainer;
var headerContainer;

	
			
// set content height on reload or resize of the window
window.onload = function() {
  setContentHeight();
}
window.onresize = function() {
  setContentHeight();
}


function viewPosition() {
	if(is_ie)      { return document.body.scrollTop; }
	else if(is_moz) { return window.pageYOffset; }
}


// function definitions
function init() 
{
	headerContainer = document.getElementById('headerContainer');
	contentContainer = document.getElementById('contentContainer');

	// set the height of the content container
	setContentHeight();
	
	// check browser
	if ( (navigator.appName.indexOf("Netscape")>-1) && (navigator.appVersion.indexOf("4.")>-1)) {
    } else {
	 	topOffset = 30 + parseInt(document.Headline.height);
		initLoop();
	 	if (is_opera && is_major <= 6) {
		 	a1clientX = window.innerWidth;
	 		a1clientY = window.innerHeight;
	 	}
	}
}

function initLoop() {

		document.getElementById("leftNav").style.position = "relative";
		document.getElementById("leftNav").style.cssFloat = "left";
		document.getElementById("leftNav").style.margin = "0 15px 0 0";
		
		document.getElementById("content").style.position = "relative";
		document.getElementById("content").style.cssFloat = "left";
		document.getElementById("content").style.margin = "0 15px 70px 0";
		
		document.getElementById("rightNav").style.position = "relative";
		document.getElementById("rightNav").style.cssFloat = "left";
		document.getElementById("rightNav").style.margin = "0px";
	if (is_ie && !MAC) {
		loopIE();
	}
	else if (is_ie && MAC) loopIEMac();
	else if (is_nav) loopNS();
	else {
		loop();
	}
}

function loopIE() {
	scrY = contentContainer.scrollTop;
	logoY = logoPos(scrY);
	document.getElementById("leftNav").style.top = Math.round(logoY) + "px";
	document.getElementById("rightNav").style.top = Math.round(logoY) + "px";
	(sY) ? setTimeout("loopIE()", 20) : setTimeout("loopIE()", 300);
}
function loopIEMac() {
	scrY = contentContainer.scrollTop;
	logoY = logoPos(scrY);
	document.all('leftNav').style.top = Math.round(logoY) + "px";
	document.all('rightNav').style.top = Math.round(logoY) + "px";
	(sY) ? setTimeout("loopIEMac()", 20) : setTimeout("loopIEMac()", 300);
}

function loopNS() {
	scrY = this.pageYOffset;
	logoY = logoPos(scrY);
	document.leftNav.top = Math.round(logoY) + "px";
	document.rightNav.top = Math.round(logoY) + "px";
	(sY) ? setTimeout("loopNS()", 20) : setTimeout("loopNS()", 300);
}

function loop() {
	scrY = contentContainer.scrollTop;
	logoY = logoPos(scrY);
	document.getElementById("leftNav").style.top = Math.round(logoY) + "px";
	document.getElementById("rightNav").style.top = Math.round(logoY) + "px";
	(sY) ? setTimeout("loop()", 20) : setTimeout("loop()", 300);
}

function logoPos(scrY) {
	if (scrY < topOffset) scrY = topOffset;
	scrY = scrY-topOffset;
	var dY = scrY - logoY;
	sY = demY *(sY + dY/accY);
	if ((sY < 0.3 && dY > 0.1) || (sY > -0.3 && dY < -0.1)) { 
		sY = 0; logoY = scrY; 
	}
	scrS = scrY - lastScrY;
	if ((scrS < 400) && (dY != 0) && (scrS > 0)) sY = 0;
	else if ((scrS > -380) && (dY != 0) && (scrS < 0)) sY = 0;
 	lastScrY = scrY;
	lastLogoY = logoY;
	logoY = logoY + sY;
	return logoY;
}

/* 

function logoPos(scrY) {
	if (scrY < topOffset) scrY = topOffset;
	scrY = scrY-topOffset;
	var dY = scrY - logoY;
	sY = demY *(sY + dY/accY);
	if ((sY < 0.3 && dY > 0.1) || (sY > -0.3 && dY < -0.1)) { 
		sY = 0; logoY = scrY; 
	}
	scrS = scrY - lastScrY;
	if ((scrS < 400) && (dY != 0) && (scrS > 0)) sY = 0;
	else if ((scrS > -380) && (dY != 0) && (scrS < 0)) sY = 0;
 	lastScrY = scrY;
	lastLogoY = logoY;
	logoY = logoY + sY;
	return logoY;
}


 */

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 setContentHeight() 
{
	if (document.getElementById) 
	{
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) 
		{
			var headerHeight = headerContainer.offsetHeight;
			var contentHeight = contentContainer.offsetHeight;
			var newContentHeight = (windowHeight - headerHeight);

			contentContainer.style.height = newContentHeight +'px';	

		}
	}
}


