$(document).ready(function() {

	function staticNav() { 
	
		$('#content').css({ 'float' : 'left' });
		var position = $('.container').offset();
		
		var headerHeight = 470;//$("#header").height();
		var winHeight = $(window).height();
		var browserIE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;

		if (browserIE6) {
			$("#header").css({'position' : 'absolute'});
		} else {
			$("#header").css({'position' : 'fixed'});
		}
	
		if (headerHeight > winHeight) {
			$("#header").css({'position' : 'absolute'});
			
			$('#header').css({ 'left': ($('#content').width() + parseInt($('#content').css('padding-right')))+'px'});
		} else {
			if (browserIE6) {
				$('#header').css({ 'left': ($('.container').width() - $('#header').width())+'px'});
			} else {
				$('#header').css({ 'left': (position.left + $('.container').width() - $('#header').width())+'px'});
			}
		
		}
		
	}
	
	staticNav();
	
	$(window).resize(function () { //Each time the viewport is adjusted/resized, execute the function
		staticNav();
	});

});
