$(document).ready(function(){

	// Validate checkout form
	$("form#frmContact").validate({
		errorLabelContainer: $("div#errorContainer"),	
		rules: {
			txtName: { 			required: true, maxlength: 50 },
			txtCity: { 			required: true, maxlength: 50 },
			selCountry: { 		required: true },
			txtEmail: { 		required: true, maxlength: 50, email:true },
			txtPhone: {			required: true, maxlength: 15	},
			txtComments: { 		required: true	 },
			selBestContact:  { 	required: true	 },
			selHowHear: { 			 },
			txtHowHearOther: { 	maxlength: 50	 },
			chkBrochure: { 		 },
			txtAddress: { 		required: "#chkBrochure:checked"	 },
			chkTermsAgree: { 	required: true	 }
		},
		messages: {
			txtName: {			required: "Please enter a Name",
								maxlength: "Your entered Name exceeds the maximum length" },
			txtCity: {			required: "Please enter a City/State",
								maxlength: "Your entered City/State exceeds the maximum length" },
			selCountry: {		required: "Please select a Country" },
			txtEmail: {			required: "Please enter an Email Address",
								maxlength: "Your entered Email exceeds the maximum length",
								email:"Please enter a valid Email Address" },
			txtPhone: { 		required: "Please enter a Phone Number",
								maxlength: "Your entered Phone Number exceeds the maximum length" },
			txtComments: { 		required: "Please enter your Comments" },
			selBestContact: { 	required: "Please select the best way to contact you" },
			selHowHear: { 			 },
			txtHowHearOther: { 	maxlength: "Your entered How Did You Hear About Us exceeds the maximum length"	 },
			chkBrochure: { 		 },
			txtAddress: { 		required: "Please enter an Address we can mail the brochure to"	 },
			chkTermsAgree: { 	required: "You must agree to this websites Terms &amp; Conditions"	 }
		}
	});
	
	$("#btnSubmit").click(function() {
		if (!$('#frmContact').valid()) {
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	return true;	}
	});
	
	$("#chkBrochure").click(function() {
		$("#address").toggle();
	});
	
	$("#selHowHear").change(function() {
		if ( $(this).val() == 'Other' )
		{	$("#hearAboutOther").show();	}
		else {	$("#hearAboutOther").hide();	}
	});
	
});