$(document).ready(function(){  
	config = new Object();
	config.headerHeightCol = 65;
	config.headerHeightExp = 200;
	config.logoMarginCol = 9;
	config.logoMarginExp = 18;

	var headerHeight = config.headerHeightExp;
	var logoHeight = config.logoMarginExp;	
	
	var hoverConfig = {    
		over: headerExp,    
		timeout: 300,    
		out: headerCol    
	};

	$('#header').hoverIntent( hoverConfig );

	function headerExp() {
		$.fn.enterHeader(headerHeight, logoHeight);
	}
	function headerCol() {
		$.fn.leaveHeader(headerHeight, logoHeight);
	}
	
	$(document).scroll(function() {
		//animate to collapsed
		if ($(document).scrollTop() < (config.headerHeightExp - config.headerHeightCol) && $(document).scrollTop() > 0) {
			headerHeight = config.headerHeightExp - ($(document).scrollTop());
			logoHeight = config.logoMarginExp - ($(document).scrollTop()/15);
		}
		//collapsed
		else if ($(document).scrollTop() >= (config.headerHeightExp - config.headerHeightCol)) {
			headerHeight = config.headerHeightCol;
			logoHeight = config.logoMarginCol;
		}
		//expanded
		else if ($(document).scrollTop() == 0){
			headerHeight = config.headerHeightExp;
			logoHeight = config.logoMarginExp;
		}
		//expanded
		else {
			headerHeight = config.headerHeightExp;
			logoHeight = config.logoMarginExp;
		}

		if ($(document).scrollTop() <= 75) {
			$('.footer-info').show(150);
		}
		else if ($(document).scrollTop() > 75) {
			$('.footer-info').hide(150);
		}

		$('#header').height(headerHeight);
		$('#footer-logo').css("marginTop", logoHeight + "px");
	});

});

$.fn.enterHeader = function(x, i) {
	$('#header').animate({
		height: config.headerHeightExp + "px"
	}, 300 );
	$('#footer-logo').animate({
		marginTop: config.logoMarginExp + "px"
	}, 150 );
	if ($(document).scrollTop() > 75) { $('.footer-info').show(150) };
}

$.fn.leaveHeader = function(x, i) {
	$('#header').animate({
		height: x + "px"
	}, 300 );
	$('#footer-logo').animate({
		marginTop: i + "px"
	}, 150 );
	if ($(document).scrollTop() > 75) { $('.footer-info').hide(150) };
}
