$(document).ready(function(){
    $('#accordion').accordion({autoHeight:false, collapsible:true, active:false});
    $('#accordion h3').click(function() {
        this.blur();
      });
    $('#contactform, #close, #contactform2').click(function() {
    	this.blur();
    	$('#hiddenform').toggle('slow');
    	return false;
      });



    $('.error').hide();
    
    $(".button").click(function() {
        $('.error').hide();

               //alert (dataString);return false;
     var name = $("input#name").val();
     if (name == "") {  
    
          $("label#name_error").show();  
          $("input#name").focus();  
        
        return false;  
        
        }  
       var email = $("input#email").val();        
       if (email == "") {  
             $("label#email_error").show();  
             $("input#email").focus();  

             return false; 
        }
        else {
            regex= /^[a-zA-Z0-9][a-zA-Z0-9\._\-&!?=#]*@/;
            if(!regex.test(email)){
               
               $("label#email_error").html("invalid email"); 
               $("label#email_error").show();  
               $("input#email").focus(); 
                return false; 

            }

        }

        var message = $("textarea#message").val(); 
        if (message == "") {  
             
             $("label#message_error").show();  
             $("input#message").focus();  

             return false; 
        }
        var recaptcha = $("input#recaptcha_response_field").val(); 
        
         if (recaptcha == "") {  
             
              return false; 
        }

 
     	  var dataString = $('#hiddenform form').serialize();
	
		$.ajax({
              type: "POST",
            url: "http://www.cord.edu/assets/php/mailpop_proc.php",
            data: dataString,
            success: function(html) {
                $('#hiddenform').html(html);
                //$('#message').html();
                setTimeout("$('#hiddenform').hide();window.location.reload(false);",5000);
                         
        }
     });

    
      return false;

    });
  });
  

