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

  $(".LinkBottom").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name3 = $("input#name3").val();
		if (name3 == "") {
      $("label#name_error3").show();
      $("input#name3").focus();
      return false;
    }
		var email3 = $("input#email3").val();
		if (email3 == "") {
      $("label#email_error3").show();
      $("input#email3").focus();
      return false;
    }
	
	var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		if(!pattern.test(email3)){         
			$("label#email_error3").show();
		    $("input#email3").focus();
		    return false; 
		}
	
	var address = $("input#address3").val();
	
	var city = $("input#city3").val();
	
	var zipcode = $("input#zipcode3").val();
	
	var country = $("input#country3").val();
	
	var comments = $("textarea#comments").val();
		
		var dataString = 'name3='+ name3 + '&email3=' + email3 + '&address=' + address + '&city=' + city + '&zipcode=' + zipcode + '&country=' + country + '&comments=' + comments;
		//alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "ajax/contactus.php",
      data: dataString,
      success: function() {
        $('#contact_form3').html("<div id='message3'></div>");
        $('#message3').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message3').append("<img id='checkmark3' src='images/check.png' />");
        });
      }
     });
    return false;
	});
  $(".button").click(function() {
							  
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		 
		var email = $("input#email").val();
		
		if (email == "") {
		  $("label#email_error").show();
		  $("input#email").focus();
		  return false;
		}	
		
		var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		if(!pattern.test(email)){         
			$("label#email_error").show();
		    $("input#email").focus();
		    return false;  
		}
		
		var dataString = 'email=' + email;
		//alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "ajax/catcher.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</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;
	});
  $(".button2").click(function() {
							  
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		 
		
		var name = $("input#name2").val();
		
		if (name == "") {
		  $("label#name_error_footer").show();
		  $("input#name2").focus();
		  return false;
		}
		
		
		var email = $("input#email2").val();
		
		if (email == "") {
		  $("label#email_error_footer").show();
		  $("input#email2").focus();
		  return false;
		}	
		
		var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		if(!pattern.test(email)){         
			$("label#email_error_footer").show();
		    $("input#email2").focus();
		    return false;  
		}
		
				
		var query = $("textarea#query2").val();
		
		
		var dataString = 'email2=' + email + '&name2=' + name + '&query2=' + query;
		//alert (dataString);return false;
		
	  $.ajax({
      type: "POST",
      url: "ajax/catcher.php",
      data: dataString,
      success: function() {
        $('#contact_form_footer').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</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#name3").select().focus();
});

