$(document).ready(function(){
	if($('#nav').length)
		_xHeader.init();
});

_xHeader = {
	_nOriginalNavWidth: 0,
	_nNavOffset: 0,
	_nNavHeight: 0,
	_bTopVis: false,
	
	init:function(){
		this.getNavDimensions();
		this.stretchToWindow();
		this.assignScrollLock();
	},
	
	getNavDimensions:function(){
		this._nNavOffset = $('#nav').offset().top;
		this._nNavHeight = $('#nav').height();
	},
	
	stretchToWindow:function(){
		$('#nav').width();
	},
	
	assignScrollLock:function(){
		$(window).scroll(function(){
			var wo = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
			if(wo >= _xHeader._nNavOffset){
				$('#placeholder').css('height', _xHeader._nNavHeight).show();
				$("#nav").addClass('fixed');
				topVis = true;
			}
			else if(wo < _xHeader._nNavOffset){
				$('#placeholder').hide();
				$("#nav").removeClass('fixed');
				topVis = false;
			}
		});
	}
}
