function initScroll(){
	_nav = document.getElementById('thirdTierNav');
	_scrolltimer = null;
	_scrolling = false;
	if (document.all) {
		if (document.documentElement && document.documentElement.clientHeight) {
			var doc = document.documentElement;
		} else {
			var doc = document.body;
		}
	} else {
		var doc = document;
	}
	doc.onscroll = startScroll;
	window.onresize = startScroll;
}
function resetScroll(){
	stopScroll();
	_nav.style.top = '0px';
	window.scrollTo(0,0);
}
function startScroll(){
	if ( ! _scrolling) {
		_scrolling = true;
		doScroll();
	}
}
function stopScroll(){
	_scrolling = false;	
	clearTimeout(_scrolltimer);
}
function doScroll(){
	if (document.documentElement && document.documentElement.clientHeight) {
		var windowHeight = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		var windowHeight = document.body.clientHeight;
	} else {
		var windowHeight = window.innerHeight;
    }
	if (window.pageYOffset) {
		var scrollTop = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		var scrollTop = document.documentElement.scrollTop;
	} else if (document.body && document.body.scrollTop) {
		var scrollTop = document.body.scrollTop;
	} else {
		scrollTop = 0;
	}
	if (windowHeight >= 650) {
		var yCurrent = parseInt(_nav.style.top) || 0;
		
		if (yCurrent >= 0) {
			var yTarget = scrollTop-100;
		} else {
			var yTarget = 0;
		}
		
		var y = yCurrent + (yTarget - yCurrent) / 6;
		_nav.style.top = y + 'px';
		if (Math.abs(yTarget - y) <= 2) {
			stopScroll();
			_nav.style.top = yTarget + 'px';
		} else {
			_scrolltimer = setTimeout('doScroll()', 50);
		}
	} else {
		stopScroll();
		_nav.style.top = '0px';
	}
}

$(document).ready(function(){
    initScroll();
});