$(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"});
  //});

  $(".inputSubmit").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();


		
	  var fname = $("input#first_name").val();
		if (fname == "") {
      alert('Fornavn må være med');
      return false;
    }
    
	  var ename = $("input#last_name").val();
		if (ename == "") {
      alert('Etternavn må være med');
      return false;
    }

        
		var mail = $("input#email").val();
		if (mail.search(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/) == -1)        {
      alert('E-post må fylles ut og det må være en reell e-post');
      return false;
    }

    var options = { 
				success: function() {
					$('#contactscheme').html("<div id='message'></div>");
					$('#message').html("<h2>Ditt bestillingskjema har nå blitt sendt</h2>")
					.append("<p></p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message').append("<img id='checkmark' src='http://static.websys.no/files/sites/www.bluesfest2010.no/design/images/check.png' />");
					});
				}        
    }; 
 
    // bind to the form's submit event 
    $('#bestSkjema').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    });
	});
});

