$(function() {
	$('#imie_error').hide();
	$('#email_error').hide();
	$('#tresc_error').hide();
  $(".button").click(function() {

    $('#imie_error').hide();
	$('#email_error').hide();
	$('#tresc_error').hide();
		
	  var imie = $("input#imie").val();
		if (imie == "") {
      $("label#imie_error").show();
      $("input#imie").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var tresc = $("textarea#tresc").val();
		if (tresc == "") {
      $("label#tresc_error").show();
      $("textarea#tresc").focus();
      return false;
    }
		
		var dataString = 'imie='+ imie + '&email=' + email + '&tresc=' + tresc;
		//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "formsend.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("Wiadomość została wysłana")
        
        .hide()
        .fadeIn(500, function() {
        
        });
      } 
     });
    return false;
	});
});
/*
runOnLoad(function(){
  $("#imie").select().focus();
});
*/
