$(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 name = $("textarea#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("textarea#name").focus();
      return false;
    }
		var emailfrom = $("input#emailfrom").val();
		if (emailfrom == "Ihre mailadresse") {
      $("label#emailfrom_error").show();
      $("input#emailfrom").focus();
      alert("Bitte geben Sie Ihre E-Mail Adresse ein.");
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "mailadresse Empfänger") {
      $("label#phone_error").show();
      $("input#phone").focus();
      alert("Bitte geben Sie eine Empfänger E-Mail Adresse ein.");
      return false;
    }
    	
		var dataString = 'name='+ name + '&emailfrom=' + emailfrom + '&phone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.beatekopp.de/wp-content/themes/beatekopp/contact-form-handler2.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='messagethankyou'></div>");
        $('#messagethankyou').html("")
        .append("")
        .hide()
        .fadeIn(1500, function() {
          $('#messagethankyou').append("<img style='margin-left:2px;margin-top:-25px;' src='http://www.beatekopp.de/wp-content/themes/beatekopp/img/b_an_f_s_ok.gif' />");
        });  
      }
      
     });
    return false;
	});
});


