$.validator.setDefaults({
	submitHandler: function() { $("#report_form").submit(); }
});

$().ready(function() {
	
	
	// validate signup form on keyup and submit
	$("#report_form").validate({
		rules: {
			contact_name: "required",
			contact_phone: "required",
			username: {
				required: true,
				minLength: 2
			},
			password: {
				required: true,
				minLength: 5
			},
			confirm_password: {
				required: true,
				minLength: 5,
				equalTo: "#password"
			},
			contact_email: {
				required: true,
				email: true
			},
			topic: {
				required: "#logdetails:checked",
				minLength: 2
			},
			agree: "required"
		},
		messages: {
			contact_name: "Please enter your contact_name",
			contact_phone: "Please enter your contact_phone",
			
			contact_contact_email: "Please enter a valid contact_email address",
			agree: "Please accept our policy"
		}
	});
	
	
	
	/*
	//code to hide topic selection, disable for demo
	var logdetails = $("#logdetails");
	// logdetails topics are optional, hide at first
	var topics = $("#logdetails_topics")[logdetails.is(":checked") ? "show" : "hide"]();
	// show when logdetails is checked
	logdetails.change(function() {
		topics[this.checked ? "show" : "hide"]();
	});
	
	
	
	//code to hide topic selection, disable for demo
	var purchase_contact = $("#purchase_contact");
	// logdetails topics are optional, hide at first
	var p_topics = $("#purchase_contact_topics")[purchase_contact.is(":checked") ? "show" : "hide"]();
	// show when logdetails is checked
	purchase_contact.change(function() {
		p_topics[this.checked ? "show" : "hide"]();
	});
	*/
});
