$(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 first_name = $("input#first_name").val();
		if (first_name == "") {
      $("label#first_name_error").show();
      $("input#first_name").focus();
      return false;
    }
		    
	var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
    
	var dataString = 'first_name=' + first_name + '&phone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
	type: "POST",
	url: "inc/kontaktform/process.php",
	data: dataString,
	success: function() {
        $('#blivringetopform').html("<div id='submitmessage'>");
        $('#submitmessage').html("Tak skal du have.<br /><br />Jeg kontakter dig hurtigst muligt!")
        .hide()
        .fadeIn(800, function() {
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#first_name").select().focus();
});
