$(function() {
  $('.formerror').hide();
  
  $('.textinput').css({backgroundColor:"#FFFFFF"});
  
  $('.textinput').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
  $('.textinput').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $("#submit-btn").click(function() {
		// validate and process form
		// first hide any error messages
		
    $('.formerror').hide();
		
	  var name = $("#name").val();
		if (name == "") {
      $("#name-error").show();
      $("#name").focus();
      return false;
    }
		var email = $("#email").val();
		if (email == "") {
      $("#email-error").show();
      $("#email").focus();
      return false;
    }
		var comment = $("#message").val();
		if (comment == "") {
      $("#message-error").show();
      $("#message").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#hello').html("<div id='thanks'></div>");
        $('#thanks').html("<p>Thank you for your comment. <br />お問い合せ頂き誠にありがとうございます。 <br /><p>")
        .append("<p>We will be in touch soon. <br /> おってご連絡差し上げます。</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#thanks');
        });
      }
     });
    return false;
	});
});

