$(document).ready(function(){
	$("#send").click(function(){					   				   
		//$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var emailFromVal = $("#email").val();
		if(emailFromVal == '') {
			$("#emailNotice").html('<span class="error">You forgot to enter the email address to send from.</span>');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {	
			$("#emailNotice").html('<span class="error">Enter a valid email address to send from.</span>');
			hasError = true;
		}
		
		var nameVal = $("#name").val();
		if(nameVal == '') {
			$("#emailNotice").html('You forgot to enter your name.');
			hasError = true;
		}
		
		var messageVal = $("#inquiry").val();
		if(messageVal == '') {
			$("#emailNotice").html('You forgot to enter the message.');
			hasError = true;
		}
		
		
		if(hasError == false) {
			//$(this).hide();
			//$("#sendEmail li.buttons").append('<img src="/wp-content/themes/default/images/template/loading.gif" alt="Loading" id="loading" />');
			
			$.post("/scripts/email.php",
   				{ emailFrom: emailFromVal, nameFrom: nameVal, message: messageVal },
   					function(data){
   						$("#emailNotice").html('Thank you for your inquiry.  I look forward to being in touch!');											$("#name").val('');
   						$("#inquiry").val('');
   						$("#email").val('');
					}
				 );
		}
		
		return false;
	});						   
});