// JavaScript Document

$(document).ready(function(){
	$(window).load(function() {
		$('#bottom_bar').css('visibility','visible');		
		handle_footer();
	});	
	$(window).scroll(function(){
		handle_footer();
	});
	var scroll_time=Math.round(($('html').height()+$('html').offset().top));
	$('#footer_expand_button').click(function(){
		$('html, body').animate({ 
			scrollTop: $('#footer_container').offset().top 
		}, scroll_time,'easeOutSine');
	});
});

function handle_footer(){
	var p=$('#footer_container').position();
	var w=$(window).width();
	var h=$(window).height();
	var sp=$(window).scrollTop();
	if ((p.top-sp)<(h-($('#bottom_bar').height()+ parseInt($('#footer_container').css('marginTop')) ))) {
		$('#bottom_bar').css('zIndex','1');
		$('#footer_expand_button').fadeOut(400);
		$('#footer_container').css('zIndex','100');
	} else {
		$('#bottom_bar').css('zIndex','100');
		$('#footer_expand_button').fadeIn(400);
		$('#footer_container').css('zIndex','1');
	}
}

