$(document).ready(function() {

		

	$("#cpf").mask("999.999.999-99");
	$("#cepconsultorio").mask("99999-999");
	$("#cepparticular").mask("99999-999");
	$("#telparticular").mask("(99)9999-9999");
	$("#telconsultorio").mask("(99)9999-9999");
	$("#admissao").mask("99/99/9999");
	$("#formatura").mask("99/99/9999");
	$("#datanascimento").mask("99/99/9999");
    /*$('#resposta').limit('280','#cont'); 
    $("#comentsForm").validate();*/
   jQuery.validator.addMethod("dateBR", function(value, element) {
     //contando chars
    if(value.length!=10) return false;
    // verificando data
    var data        = value;
    var dia         = data.substr(0,2);
    var barra1      = data.substr(2,1);
    var mes         = data.substr(3,2);
    var barra2      = data.substr(5,1);
    var ano         = data.substr(6,4);
    if(data.length!=10||barra1!="/"||barra2!="/"||isNaN(dia)||isNaN(mes)||isNaN(ano)||dia>31||mes>12)return false;
    if((mes==4||mes==6||mes==9||mes==11)&& dia==31)return false;
    if(mes==2 && (dia>29||(dia==29 && ano%4!=0)))return false;
    if(ano < 1900)return false;
    return true;
}, "Informe uma data válida"); 
	jQuery.validator.addMethod("verificaCPF", function(value, element) {
	    value = value.replace('.','');
	    value = value.replace('.','');
	    cpf = value.replace('-','');
	    while(cpf.length < 11) cpf = "0"+ cpf;
	    var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
	    var a = [];
	    var b = new Number;
	    var c = 11;
	    for (i=0; i<11; i++){
	        a[i] = cpf.charAt(i);
	        if (i < 9) b += (a[i] * --c);
	    }
	    if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	    b = 0;
	    c = 11;
	    for (y=0; y<10; y++) b += (a[y] * c--);
	    if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	    if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg)) return false;
	    return true;
	}, "Informe um CPF válido.");
	$("form#filiacao").validate({   
	    rules: {   
	        'formatura': {   
	            required: true,   
	            dateBR: true  
	        },
	        'admissao': {   
	            required: true,   
	            dateBR: true  
	        },
	        'datanascimento': {   
	            required: true,   
	            dateBR: true  
	        },
	        'cpf':{
	        	required: true,
	        	verificaCPF:true
	        }   
	    }  
	});
  $("form#boleto").validate();  
  
});
