$(document).ready(function(){

  // Hide the contact form
  function hideContactForm(x){
	var timeout = 0;
	
	if(x == "thanks"){ timeout = 2000; $("#form_outline").html("<h1>We got your message!</h1><h1>You will be contacted soon.</h1>"); }
	
	setTimeout(function(){
		
      $("#contact_form").fadeOut("fast", function(){
	    $("#main_content_container").fadeIn("slow");
	    $("#banner").animate({height:224}, function(){
	      $("#banner img").fadeIn("fast");
	    });	
	  });	
      $("a.show_contact_form").html("Contact")

    }, timeout);
  }

  // Show the contact form
  function showContactForm(){
    $("#main_content_container").fadeOut("fast", function(){
      $("#contact_form").fadeIn("slow");
      $("#banner img").fadeOut("fast", function(){});
      $("#banner").animate({height:10});	
    });
    $("a.show_contact_form").html("Back")
  }

  // Contact form animation
  $(".show_contact_form").click(function(){
	if ($("#banner").height() < 224){ 
	  hideContactForm("nothanks");	  
    } else {
      showContactForm();
    }
  });

  $("#contact_us_form").ajaxForm(function(){
    hideContactForm("thanks");
  });
  
	
});