$(document).ready(function() {

	if ($("#restore_form").length>0)
	$("#restore_form").validate({
		rules: {
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			email: {
				required: "Please provide email",
				email: "Format is incorrect"
			}
		}
	});
	
	if ($("#new_password_form").length>0) {
		$("#new_password_form").validate({
			rules: {
				password: {
					required: true,
					minlength: 5
				},
				confirm_password: {
					required: true,
					minlength: 5,
					equalTo: "#password"
				}
			},
			messages: {
				password: {
					required: "Please enter password",
					minlength: "Must be 5+ characters long"
				},
				confirm_password: {
					required: "Please enter password",
					minlength: "Must be 5+ characters long",
					equalTo: "Passwords don't match"
				}
			}
		});
		
		// check if confirm password is still valid after password changed
		$("#password").blur(function() {
			$("#confirm_password").valid();
		});
	}

});