$(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"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	
	var email = $("input#email").val();
		if (email.lastIndexOf(".") <= email.indexOf("@")) {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	
	var name = $("input#email").val();
		if (name == "Enter your email") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var dataString = 'email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "php/process.php",
      data: dataString,
      success: function() {
		 $('input[type="image"]').attr('disabled','disabled');
		  $('input[type="image"]').hide()
     $('input[type="text"]').keypress(function(){
            if($(this).val != ''){
               $('input[type="submit"]').removeAttr('disabled');
            }
     });
        $('.fieldbox').html("<div id='message' style='position:absolute;left:10px;top:0px;'></div>");
        $('#message').html("<b>Thank You!<br/>Email Submitted!</b>")
		
        .append("")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
