$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
 
 $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#f3ffef"});
	$(this).css("border", "1px solid #555555");
});

$('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
	$(this).css("border", "1px solid #e0e0e0");
  });

  $(".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 phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }


// Pflichtfeld Betreff 

	var subject = $("input#subject").val();
		if (subject == "") {
      $("label#subject_error").show();
      $("input#subject").focus();
      return false;
    }
	
	var comment = $("textarea#comment").val();
		if (!comment || comment == "Ihre Mitteilung") {
      $("label#comment_error").show();
      $("textarea#comment").focus();
      return false;
    }

		var dataString = 'name='+ name + '&phone=' + phone + '&subject=' + subject + '&comment=' + comment;
	  	// alert (dataString); /*debug*/
		
		$.ajax({
      type: "POST",
      url: "http://wp1186376.wp211.webpack.hosteurope.de/_sys/contactsend.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<br /><p>Vielen Dank, wir werden Sie umgehend kontaktieren.</p>")

		/*$('#message').append("<a href='' id='close_bn' onclick='self.parent.tb_remove();'><img src='http://www.mbutt.de/img/bn_de_close.png' /></a>") */

		$('#message').hide()
		
        $('#message').fadeIn(1500, function() {
        });
      }
	  
     });
    return false;
	});
});

