 $(document).ready(function(){
 			
	jQuery.validator.messages.required = "<span class='small red'>Required</span>";
	$("#informationForm").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted below'
					: 'You missed ' + errors + ' fields.  They have been highlighted below';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		},
		onkeyup: false,
		submitHandler: function() {
			$("div.error").hide();
			$.get("/formProcessor.php", { MoreInformation: $('#lname').val(), Company: $('#company').val(), Name: $('#name').val(), Title: $('#title').val(), Address: $('#address').val(), City: $('#city').val(), State: $('#state').val(), Zip: $('#zip').val(), Phone: $('#phone').val(), Fax: $('#fax').val(), Email: $('#email').val(), Comment: $('#comment').val() }, function(data){ $('#thankyou').html(data); } );

			$('#form1').hide();
			$('#form2').hide();
			$('#form3').hide();
			$('#thankyou').show();
		},
		messages: {
			email: {
				email: "Please enter a valid email address, example: you@yourdomain.com"
			}
		},
		debug:false
	});


	$('#cbRound').click(function(){
		$('#roundSize').toggleClass('required');
		$('#roundLength').toggleClass('required');
		$('#roundQuantity').toggleClass('required');
	});
	
	$('#cbHex').click(function(){
		$('#hexSize').toggleClass('required');
		$('#hexLength').toggleClass('required');
		$('#hexQuantity').toggleClass('required');
	});
	
	$('#cbFlat').click(function(){
		$('#flatWidth').toggleClass('required');
		$('#flatHeight').toggleClass('required');
		$('#flatLength').toggleClass('required');
		$('#flatQuantity').toggleClass('required');
	});
	
	$('#cbSquare').click(function(){
		$('#squareWidth').toggleClass('required');
		$('#squareLength').toggleClass('required');
		$('#squareQuantity').toggleClass('required');
	});
	
	$('#finish').change(function(){
		if($(this).val() == "Other")
			$('#other').toggleClass('required');
	});
	

	$("#quoteForm").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted below'
					: 'You missed ' + errors + ' fields.  They have been highlighted below';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		},
		onkeyup: false,
		submitHandler: function() {
			$("div.error").hide();
			$.get("/formProcessor2.php", { QuoteRequest: $('#lname2').val(), Company: $('#company1').val(), Name: $('#name1').val(), Title: $('#title1').val(), Address: $('#address1').val(), City: $('#city1').val(), State: $('#state1').val(), Zip: $('#zip1').val(), Phone: $('#phone1').val(), Fax: $('#fax1').val(), Email: $('#email1').val(), Grade: $('#grade').val(), Aircraft: $("input[name=aircraft]:checked").val(), Gun: $("input[name=gun]:checked").val(), Finish: $('#finish').val(), Other: $('#other').val(), Round: $('#cbRound').val(), RoundSize: $('#roundSize').val(), RoundLength: $('#roundLength').val(), RoundQuantity: $('#roundQuantity').val(), Hex: $('#cbHex').val(), HexSize: $('#hexSize').val(), HexLength: $('#hexLength').val(), HexQuantity: $('#hexQuantity').val(), Flat: $('#cbFlat').val(), FlatThick: $('#flatThick').val(), FlatWidth: $('#flatWidth').val(), FlatLength: $('#flatLength').val(), FlatQuantity: $('#flatQuantity').val(), Square: $('#cbSquare').val(), SquareWidth: $('#squareWidth').val(), SquareLength: $('#squareLength').val(), SquareQuantity: $('#squareQuantity').val(), Comment: $('#comment1').val() }, function(data){ $('#thankyou').html(data); } );

			$('#form1').hide();
			$('#form2').hide();
			$('#form3').hide();
			$('#thankyou').show();
		},
		messages: {
			email: {
				email: "Please enter a valid email address, example: you@yourdomain.com"
			}
		},
		debug:false
	});
	
	jQuery.validator.messages.required = "<span class='small red'>Required</span>";
	$("#informationForm2").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted below'
					: 'You missed ' + errors + ' fields.  They have been highlighted below';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		},
		onkeyup: false,
		submitHandler: function() {
			$("div.error").hide();
			$.get("formProcessor3.php", { MoreInformation: $('#lname').val(), Company: $('#company').val(), Name: $('#name').val(), Title: $('#title').val(), Address: $('#address').val(), City: $('#city').val(), State: $('#state').val(), Zip: $('#zip').val(), Phone: $('#phone').val(), Fax: $('#fax').val(), Email: $('#email').val(), Comment: $('#comment').val() }, function(data){ $('#thankyou').html(data); } );

			$('#form1').hide();
			$('#form2').hide();
			$('#form3').hide();
			$('#thankyou').show();
		},
		messages: {
			email: {
				email: "Please enter a valid email address, example: you@yourdomain.com"
			}
		},
		debug:false
	});
	
	
	jQuery.validator.messages.required = "<span class='small red'>Required</span>";
	$("#quoteForm2").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted below'
					: 'You missed ' + errors + ' fields.  They have been highlighted below';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		},
		onkeyup: false,
		submitHandler: function() {
			$("div.error").hide();
			$.get("formProcessor4.php", { MoreInformation: $('#lname1').val(), Company: $('#company1').val(), Name: $('#name1').val(), Title: $('#title1').val(), Address: $('#address1').val(), City: $('#city1').val(), State: $('#state1').val(), Zip: $('#zip1').val(), Phone: $('#phone1').val(), Fax: $('#fax1').val(), Email: $('#email1').val(), Comment: $('#comment1').val() }, function(data){ $('#thankyou').html(data); } );

			$('#form1').hide();
			$('#form2').hide();
			$('#form3').hide();
			$('#thankyou').show();
		},
		messages: {
			email: {
				email: "Please enter a valid email address, example: you@yourdomain.com"
			}
		},
		debug:false
	});
   
  $("input.phone").mask("(999) 999-9999");
  $("input.zipcode").mask("99999");
  
});