$(document).ready(function(){

  $('#NewsletterSignup input[type=text]').focus(function() {
    if($(this).attr('value') == "Email Address") {
        $(this).attr('value', "");
    }
  }).blur(function() {
    if($(this).attr('value') == "") {
        $(this).attr('value', "Email Address");
    }        
  })

	$('#NewsletterSignup').submit(function(){
	   $.ajax({
	     url:emailsignup_ajax_url,
	     data: $(this).serialize(),
	     type: 'GET',
	     dataType: 'json',
	     success: function(json){
	       if(json.result == 1){
	         window.alert("Thanks! You have been signed up for our mailing list.");
	           $('#NewsletterSignup input[type=text]').attr('value','');
	       }
	       else{
	         if(json.error != ""){
	           window.alert("We're sorry, an error occurred:\n" + json.error);
	         }
	       }
	     },
	     error: function(XMLHttpRequest, textStatus, errorThrown){
	       console.log("Ajax Error: "+textStatus);
	     }
	   });
	   return false;
	
	});

});