$(document).ready(function() {
// this one requires the value to be the same as the first parameter
	$.validator.methods.equal = function(value, element, param) {
		return value == param;
	};
//registration

$("#reg_form").validate({
                rules : {
                        login : {required : true, minlength: 5, maxlength: 15},
                        password : {required : true, minlength: 5, maxlength: 15},
						password_check : {required : true, minlength: 5, maxlength: 15, equalTo: "#password"},
						email : {required : true, email: true},
						first_name : {required : true, minlength: 2}
               			},
			   //Messages
                messages : {
                        login : {required : "Введіть логін",minlength : "мінімум 2 символа",maxlength : "Забагато символів"},
					 password : {required : "Введіть пароль",minlength : "мінімум 5 символів",maxlength : "Забагато символів"},
			   password_check : {required : "Введіть пароль",minlength : "мінімум 5 символів",maxlength : "Забагато символів",equalTo : "Пароль не співпадає з попереднім"},
						email : {required : "Вкажіть e-mail",email: "Введіть вірний E-mail"} ,
				   first_name : {required : "Вкажіть Ваше ім'я",minlength : "Мінімум 2 символи"}
                		   },
				errorPlacement: function(error, element) 
						   		{
      					         var er = element.attr("name");
      							 error.appendTo(element.parent().find("label[for='" + er + "']").find("em"));
    							}
       					});
//profile form

$("#profile_form").validate({
                rules : {
						first_name : {required : true, minlength: 2},
                        password : {required : true, minlength: 5, maxlength: 15},
						password_check : {required : true, minlength: 5, maxlength: 15, equalTo: "#password"},
						email : {required : true, email: true, maxlength: 50}
               			},
			   //Messages
                messages : {
				   first_name : {required : "Вкажіть ім'я",minlength : "мінімум 2 символа"},
					 password : {required : "Введіть пароль",minlength : "мінімум 5 символів",maxlength : "Забагато символів"},
			   password_check : {required : "Введіть пароль",minlength : "мінімум 5 символів",maxlength : "Забагато символів",equalTo : "Пароль не співпадає з попереднім"},
			   email : {required : "Вкажіть E-mail",email: "Введіть вірний E-mail"}
                		   },
				errorPlacement: function(error, element) 
						   		{
      					         var er = element.attr("name");
      							 error.appendTo(element.parent().find("label[for='" + er + "']").find("em"));
    							}
       					});

//remind pass
$("#remind_form").validate({
                rules : {
						email : {required : true, email: true}
               			},
			   //Messages
                messages : {
						email : {required : "Вкажіть E-mail",email: "Введіть вірний E-mail"}     
                		   }
						   
       					});
//chang pass
$("#change_pass_form").validate({
                rules : {
						password : {required : true, minlength: 5, maxlength: 15}
               			},
			   //Messages
                messages : {
						password : {required : "Введіть пароль",minlength : "мінімум 5 символів",maxlength : "Забагато символів"}     
                		   }
       					});



});
