$(document).ready(function(){
	if(document.documentElement){
		var bWidth = document.documentElement.clientWidth;
		var bHeight = document.documentElement.clientHeight;
	} else {
		var bWidth = Math.min(
			screen.avaiWidth , 
			$(document.body).innerWidth()
		);
		var bHeight = Math.min(
			screen.availHeight , 
			$(document.body).innerHeight()
		);
	}
	var tHeight = $('#header').innerHeight();
	newTop = bHeight - tHeight - 20;
	$('#header').css("top", newTop);
	
	$(window).resize(function(){
		if(document.documentElement){
			bWidth = document.documentElement.clientWidth;
			bHeight = document.documentElement.clientHeight;
		} else {
			bWidth = Math.min(
				screen.avaiWidth , 
				$(document.body).innerWidth()
			);
			bHeight = Math.min(
				screen.availHeight , 
				$(document.body).innerHeight()
			);
		}
		newTop = $(this).scrollTop() + bHeight - tHeight - 20;
		$('#header').css("top", newTop);
	});
	
	$(window).scroll(function(){
		newTop = $(this).scrollTop() + bHeight - tHeight - 20;
		$('#header').css("top", newTop);
	});
});

