// JavaScript Document
$(document).ready(function()	{			
	
	// position everything
	positionIt();
	
	// if resize position again
	$(window).resize(positionIt);
	
	var footerHeight = 0;
	
	/* Contact */
	setTimeout(function()	{
		footerHeight = $("#footer").height();
						}, 100);
	
	$("#contact a").click(function()	{
	  expandIt();
	  return false;
	   });
	
	$("#contact_active a").click(function()	{
		contractIt(footerHeight);
		return false;
		});		

});

function positionIt()	{
	/* Make sure everything is set before filling 
	setTimeout(function()	{	
		whiteFill($(window).height());
		}, 100);*/
	whiteFill($(window).height());
	posLogo($(window).width());
			
}

/*
	Make sure logo displays correctly
*/

function posLogo(winWidth)	{
	if(winWidth < 1202)	{
		$("#wrapper").css({
		  overflow: "hidden"						  
		  });		
	} else	{
		$("#wrapper").css({
		  overflow: "visible"						  
		  });
	}
}

/*
	Make sure white fills the bottom of the screen
*/

function whiteFill(winHeight)	{
	contentHeight = $("#wrapper").height() + $("#footer").height();
	
	if(contentHeight < winHeight)	{
		diff = winHeight - contentHeight;
		diff += $("#footer").height();
		$("#footer").height(diff);
	}
}

/*
	Grow white footer area
*/

function expandIt()	{
	
	/* Doesn't PULL up, but doesn't leave any extra space...
	infoHeight = $("#footer #contact_info").height();
	
	$("#footer").animate({
						 height: "+=" + infoHeight
						 }, function()	{
							$("#contact_info").fadeIn(); 
						 });
	$("#contact").hide();
	$("#contact_active").show();
	*/
	
	infoHeight = $("#footer #contact_info").height();
	
	$("#footer").animate({
						 height: "+=" + infoHeight,
						 bottom: infoHeight
						 }, function()	{
							$("#contact_info").fadeIn();
							docHeight = $(document).height();
							fillPos = docHeight - infoHeight;
							$("#whiteFill").css({
												height : infoHeight,												
												position : "absolute",
												top : fillPos
												}).slideDown();
						 });
	
	$("#contact").hide().css("bottom", infoHeight);
	$("#contact_active").show().animate({
						  bottom: infoHeight							  
						  });
	
}

function contractIt(footerHeight)	{
	/*footerHeight = $(".footer_img").height();*/	
	
	$("#contact_info").fadeOut(); 
	$("#whiteFill").slideUp();
	$("#footer").animate({
						 height: footerHeight,
						 bottom: 0
						 });
	
	$("#contact_active").hide().css("bottom", 0);
	$("#contact").show().animate({
								 bottom: 0
								 });
}
