(function($) {	

	var $f_csstop = 0;
	var $f_orgtop = 0;
	$(document).ready(function(){
		$f = $('#footer');
		if($f.length > 0)
		{
			$f_orgtop = Math.ceil($f.position().top);
			$f_csstop = parseInt($f.css('top'));
			$(window).bind('resize', function() {
				footerfix();
			});
			footerfix();
		}
	});
	
	this.footerfix = function() {
		$top = $f_csstop + ( $(window).height() - $('#footer').height() ) - $f_orgtop;
		$top = ( $top < $f_csstop ? $f_csstop : $top );
		$f.css({top:+$top+'px'});
	}

})(jQuery);
