$(function() {
  $('.error').hide();
  //denne fliken endrer css style på focus og blur
  //$('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 Contact = $("input#Contact").val();
		if (Contact == "") {
      $("div#Contact_error").show();
      $("input#Contact").focus();
      return false;
    }
    
	  var Email = $("input#Email").val();
		if (Email == "") {
      $("div#Email_error").show();
      $("input#Email").focus();
      return false;
    }    

    var options = { 
				success: function() {
					$('#contact_form').html("<div id='message'></div>");
					$('#message').html("<h2>Reservation Form Submitted!</h2>")
					.append("<p>We will be in touch soon.</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message').append("<img id='checkmark' src='designbilder/check.png' />");
					});
				}        
    }; 
 
    // bind to the form's submit event 
    $('#reservationform').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    });
	});
	
	
  $(".button2").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#Name").val();
		if (name == "") {
      $("div#Name_error").show();
      $("input#Name").focus();
      return false;
    }
    
	  var Email2 = $("input#Email2").val();
		if (Email2 == "") {
      $("div#Email2_error").show();
      $("input#Email2").focus();
      return false;
    }    

    var options = { 
				success: function() {
					$('#contact_form2').html("<div id='message'></div>");
					$('#message').html("<h2>Contact Form Submitted!</h2>")
					.append("<p>We will be in touch as soon as possible.</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message').append("<img id='checkmark' src='designbilder/check.png' />");
					});
				}        
    }; 
 
    // bind to the form's submit event 
    $('#contactform').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    });
	});	
});


