$(function() {
  $('.error').hide();
  $('input.text-input').css("background-image", "url(style/images/input_bg.jpg)");
  $('input.text-input').focus(function(){
//    $(this).css("background-image", "url(style/images/input_bg_focus.jpg)");
  });
  $('input.text-input').blur(function(){
    $(this).css("background-image", "url(style/images/input_bg.jpg)");
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      UberUpload.showAlert("Bitte verraten Sie uns Ihren Namen!", 400, 80, UberUpload.block_ui_enabled);
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      UberUpload.showAlert("Bitte verraten Sie uns Ihre E-Mail Adresse!", 400, 80, UberUpload.block_ui_enabled);
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      UberUpload.showAlert("Bitte verraten Sie uns Ihre Telefonnummer!", 400, 80, UberUpload.block_ui_enabled);
      return false;
    }
		var nachricht = $("textarea#nachricht").val();
		
    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&nachricht=' + nachricht;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<br><img id='checkmark' src='style/images/check.jpg' /><h2>Ihre Kontaktanfrage würde losgeschikt!</h2>")
        .append("Wir melden uns so schnell es geht.<br><br><br>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});

