jQuery(document).ready(function(){

  contact_tab_height = jQuery("#header #nav li.contact-us").height();
  contact_form_height = "423px";

  // Handle the contact us tab
  jQuery("#header #nav li.contact-us a").toggle(function() {
      
    open_contact_tab();
      

    return false;
  }, function() {
    jQuery('#ContactFormHolder')
      .addClass("empty")
      .children("div.wpcf7").remove();
    
    jQuery(this).parent("li").animate({ height: contact_tab_height }, 200);
    
    return false;
  });
  
  hashes = window.location.href.slice(window.location.href.indexOf("#"));
  
  if( hashes == "#contact-us" ) {
    open_contact_tab();
  }
  

});







function open_contact_tab() {
    jQuery("#header #nav li.contact-us a").parent("li").animate({ height: contact_form_height }, "fast", "swing");
  
    jQuery("#ContactFormHolder").load("/contact-us/ div.wpcf7", function() {

        // Contact Form 7 scripts Need to fire after the form is loaded.
        // If CF7 is upgraded this will have to be manually changed.
        // It'd be nice if this were automated...
        
        //jQuery.getScript("/wp/wp-content/plugins/contact-form-7/jquery.form.js?ver=2.52");
        jQuery.getScript("/wp/wp-content/plugins/contact-form-7/scripts.js?ver=2.4.4");
        
        jQuery("#ContactFormHolder").removeClass("empty");
      
      });
}
