$(document).ready(function() {
	// validate signup form on keyup and submit
	var validator = $("#LoginForm").validate({
		rules:{
			login: {
				required: true,
				remote: "class/login_email.php",
				notEqualToTitle: true
			},
			senha: {
				required: true,
				notEqualToTitle: true
			}
		},
		messages:{
			login:{
				required: "<p>Campo obrigatório.</p>",
				remote: "<p>Usuário não cadastrado.</p>",
				notEqualToTitle: "<p>Campo obrigatório.</p>"
			},
			senha: {
				required: "<p>Campo obrigatório.</p>",
				notEqualToTitle: "<p>Campo obrigatório.</p>"
			}
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		/*submitHandler: function() {
			var login = document.getElementById('LoginForm').login.value;
			var senha = document.getElementById('LoginForm').senha.value;
			ajaxFunction("class/login_do.php","","LoginReturn","&login=" + login + "&senha=" + senha);
			return false;
		},*/
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	
});

