$(function () {
			
	
			
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".submitbutton").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "" || name == "name") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
	
		
		if (email == "" || email == "email") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		
		
		var dataString = 'name='+ name + '&email=' + email;
		//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "wp-content/themes/Shropshire-Live/enews-submit.php",
      data: dataString,
      success: function() {
        $('.form').html("<div id='message'></div>");
        $('#message').html("<h3>Thankyou</h3>")
        .append("<p>You have been added to our Newsletter database.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message');
        });
      }
     });
    return false;
	});
})
  
    
   
