$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#AADDFF"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
	var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	var text = $("textarea#testo").val();
		if (text == "") {
      $("label#text_error").show();
      $("textarea#testo").focus();
      return false;
    }
	var required = $("input#required").val();
	
	var dataString = 'name='+ name + '&email=' + email + '&testo=' + text + '&required=' + required;
	//alert(dataString);
	//return false;
	
	$.ajax({
      type: "POST",
      url: "http://www.atlantide-design.com/mailsend/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will get in touch soon...</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images2011/form_check.png' />");
        });
      }
     });
    return false;
	});
});

