$(document).ready(function(){
 // email form scripting
      var options = {
        target:        '#emailResponse',   // target element(s) to be updated with server response
        beforeSubmit:  emailSubmit,  // pre-submit callback
        success:       emailResponse  // post-submit callback
    };

    // bind form using 'ajaxForm'
    $('#emailSignup').ajaxForm(options);
    var emailBox = $('#emailSignup input.int_sign_up').val(); 
  $('#emailSignup input.int_sign_up').focus(function(){
      $(this).val('');
  });
   $('#emailSignup input.int_sign_up').blur(function(){
      if ($(this).val() == '') $(this).val(emailBox);
  });

// pre-submit callback
function emailSubmit() {
$('form#emailSignup input.submit').hide('fast');
$('form#emailSignup #throbber').html('<img src="/wp-content/themes/mrss-theme/images/throbber.gif">');
$('form#emailSignup #throbber').show('fast');
    return true;
};

// post-submit callback
function emailResponse() {
$('form#emailSignup #throbber').hide('fast')
$('form#emailSignup input.submit').show('fast');
$('form#emailSignup #emailResponse').show('fast');
};

// navigation script



navHeightCheck();
$('#page4 div#left_nav').addClass('homeNav');  // homepage does not expand
   //hide/show nav on portfolio page
$('div#navDownArrow').mouseover(function(){
 $('ul#navList').show('fast');
 $('div#navDownArrow').addClass('upArrow');   
});
$('div#navDownArrow').click(function(){
 $('ul#navList').hide('fast');
 $('div#navDownArrow').removeClass('upArrow');   
});

$('#left_nav a.primary').each(function(){
    $(this).click(function(e) {
          if($(this).parent('li').hasClass('expanded') || $(this).closest('div').hasClass('homeNav') ) {
            return true;}
          else{
            e.preventDefault();
            $(this).parent('li').addClass('expanded');
            navHeightCheck();
              }
                  });
            
                                } );
                                
 $('#left_nav a.secondary').each(function(){
    $(this).click(function(e) {
          if($(this).parent('li').hasClass('expandedTertiary')) {
            return true;}
          else{
            e.preventDefault();
            $(this).closest('li').addClass('expandedTertiary');
            navHeightCheck();
              }
                  });

                                } );   

 function navHeightCheck(){   // move sidebar out of the way of navigation
 var navHeight = $('#left_nav').height() - 150;
 $('#pageSidebar').css('margin-top', navHeight);
 };
 
 });
