
 $(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#e2e1e1"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#DBA63C"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#e2e1e1"});
  });
  
  $(".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 email = $("input#email").val();
		if (email ==""){
	
	  $("label#email_error").show();
      $("input#email").focus();
		return false;
		}
		
		var re = new RegExp(/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)$/)
            if (!email.match(re)) {
				$("label#email_error").show();
				$("input#email").focus();
				return false;
			}
   
		
		var message = $("textarea#message").val();
		if (message == "") {
      $("label#message_error").show();
      $("input#message").focus();
      return false;
    }
	
	

	

////////

		
		var dataString = 'name='+ name + '&email=' + email + '&album=' + album;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Your questionnaire is sent!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
 });
runOnLoad(function(){
  $("input#name").select().focus();
});

