$(document).ready( function() {
	//colorbox
	$("a[rel='equipment']").colorbox();

	//contact us form validation
	$('.error').hide();
	$(".button").click( function() {
		// validate and process form here

		$('.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;
		}
		
		// gather checkbox data
		var services = [];
		$("#quoteForm input:checkbox:checked").each(
			function() {
				services.push($(this).val())
			});
		
		// get value from the rest of the non-required fields for processing
		var number = $("input#number").val();
		var typeOfMessage = $("select#typeOfMessage").val();
		var additionalComments = $("textarea#additionalComments").val();
		
		// contact us form jQuery AJAX processing
		var dataString = 'name='+ name + '&number=' + number + '&email=' + email + '&typeOfMessage=' + typeOfMessage + '&services=' + services + '&additionalComments=' + additionalComments;
		
		//alert (dataString);return false;  
		$.ajax({			
		  type: "POST",
		  url: "../includes/mailer.php",
		  data: dataString,
		  success: function() {
		  	$('#contactForm').html("<div id='message'></div>");
		    $('#message').html("<h2>Your Message Has Been Sent!</h2>")
		    .append("<p>Thanks for getting in touch with us! We'll respond as soon as possible!</p>")
		    .hide()
		    .fadeIn(1500, function() {
		      //
		    });
		  }
		});
		return false;
	});
});
