
jQuery.extend(jQuery.validator.messages, {
        required: "Campo obrigat&oacute;rio",
        remote: "Campo iv&aacute;lido",
        email: "E-mail inv&aacute;lido",
        url: "URL inv&aacute;lida",
        date: "Data inv&aacute;lida",
        dateISO: "Data inv&aacute;lida (ISO)",
        dateDE: "Bitte geben Sie ein gültiges Datum ein",
		dateBR: "Data v&aacute;lida",
        number: "N&uacute;mero inv&aacute;lido",
        numberDE: "Bitte geben Sie eine Nummer ein",
        digits: "Forne&ccedil;a somente d&iacute;gitos",
        creditcard: "Cart&atilde;o de cr&eacute;dito inv&aacute;lido",
        equalTo: "Forne&ccedil;a o mesmo valor novamente",
        accept: "Valor com uma extens&atilde;o inv&aacute;lida",
        maxlength: jQuery.format("Forne&ccedil;a n&atilde;o mais que {0} caracteres"),
        minlength: jQuery.format("Forne&ccedil;a pelo menos {0} caracteres"),
        rangelength: jQuery.format("Forne&ccedil;a um valor entre {0} e {1} caracteres"),
        rangeValue: jQuery.format("Forne&ccedil;a um valor entre {0} e {1}"),
        range: jQuery.format("Forne&ccedil;a um valor entre {0} e {1}"),
        maxValue: jQuery.format("Forne&ccedil;a um valor menor ou igual a {0}"),
        max: jQuery.format("Forne&ccedil;a um valor menor ou igual a {0}"),
        minValue: jQuery.format("Forne&ccedil;a um valor maior ou igual a {0}"),
        min: jQuery.format("Forne&ccedil;a um valor maior ou igual a {0}")
});

jQuery.validator.addMethod("dateBR", function(value,element) {
	value = value.replace(/[\/]+/g,'');
	if(!(/^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/.test(value)))
		validacao =  false;
	else validacao = true;
	return this.optional(element) || validacao; 
}, "Data inv&aacute;lida");

jQuery.validator.addMethod("cpf", function(value, element){
	cpf = value.replace(/[^0-9]/g,'');
    var i;
    var soma = soma2 = 0;
    if (!(cpf.match(/^[0-9]{3,3}[.]{0,1}[0-9]{3,3}[.]{0,1}[0-9]{3,3}[-]{0,1}[0-9]{2,2}$/))) 
        validacao = false;
    for(i=0;i<10;i++) {
        if (i<9)
            soma += cpf.charAt(i) * (10 - i);
        soma2 += cpf.charAt(i) * (11 - i);
    }
    if(((soma % 11) < 2 ? 0 : 11 - (soma  % 11 )) != cpf.charAt(9))
        validacao = false;
    validacao = (((soma2 % 11 ) < 2 ? 0 : 11 - (soma2 % 11 )) != cpf.charAt(10)) ? false : true;
	if(cpf == '00000000000' || cpf.length != 11)
		validacao = false;
	return this.optional(element) || validacao;
}, "CPF inv&aacute;lido" ); 


jQuery.validator.addMethod("cnpj", function(value, element){
	cnpj = value.replace(/[^0-9]/g,'');
	if (cnpj.length < 14)
		 validacao = false;
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
		a[i] = cnpj.charAt(i);
		b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2)
		a[12] = 0;
	else a[12] = 11-x;
	b = 0;
	for (y=0; y<13; y++)
		b += (a[y] * c[y]); 
	if ((x = b % 11) < 2)
		a[13] = 0;
	else a[13] = 11-x;
	if ((cnpj.charAt(12) != a[12]) || (cnpj.charAt(13) != a[13]))
		validacao = false;
	else validacao = true;
	if(cnpj == '00000000000000' || cnpj.length < 14)
		validacao = false;
	return this.optional(element) || validacao;
}, "CNPJ inv&aacute;lido" ); 


