var ChuckNorris={debugMode:false,debug:{on:function(){ChuckNorris.debugMode=true;ChuckNorris.debug.add('=== Iniciando teste ===');Element.show($('debug'))},off:function(){ChuckNorris.debugMode=false;Element.hide($('debug'))},clear:function(){$('debug').innerHTML=''},add:function(input){if(ChuckNorris.debugMode){$('debug').innerHTML+='
> '+input}}},isEmpty:function(field){return(field.value!=''&&!field.value.match('_'))||false},isValidDate:function(field){var parts=field.value.split('\/');var dia=parseFloat(parts[0]);var mes=parseFloat(parts[1]);var ano=parseFloat(parts[2]);var diasTot=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(mes==2&&(ano%400==0||(ano%4==0&&ano%100!=0))){diasTot[mes-1]++}return(!((ano<1582||ano>4881)||(mes<1||mes>12)||(dia<1||dia>diasTot[mes-1])))||false},getIdade:function(field,dataAtual){var data=field;var arrData=data.value.split("/");var dtNascimento=new Date(arrData[2],arrData[1],arrData[0]);var idade=dataAtual.getFullYear()-dtNascimento.getFullYear();if(dataAtual.getMonth()1&&!((readyState==4)&&this._complete))this.respondToReadyState(this.transport.readyState);if(readyState==4){if(this.success()){if(this.onComplete)this.onComplete.bind(this).defer()}Carregando.remove()}else{if(readyState==1)Carregando.make()}};Formulario.prototype.erTelefone=new RegExp(/^\d{4}\-\d{4}$/);Formulario.prototype.Erro={add:function(field,error){formulario.addErro(field,error,'Error')},remove:function(field,error){formulario.removeSingleErro(field,error,'Error')},clearAll:function(){var form=$('formulario');var elements=form.getElements();elements.each(function(s,i){formulario.removeErro(s,'Error')})}};Formulario.prototype.ErroNI={add:function(field,error){formulario.addErro(field,error,'ErrorNI')},remove:function(field,error){formulario.removeSingleErro(field,error,'ErrorNI')},clearAll:function(){var form=$('formulario');var elements=form.getElements();elements.each(function(s,i){formulario.removeErro(s,'ErrorNI')})}};Formulario.prototype.Aviso={add:function(field,error){formulario.addErro(field,error,'Aviso')},remove:function(field,error){formulario.removeSingleErro(field,error,'Aviso')},clearAll:function(){var form=$('formulario');var elements=form.getElements();elements.each(function(s,i){formulario.removeErro(s,'Aviso')})}};Formulario.prototype.Info={add:function(field,error){formulario.addErro(field,error,'Info')},remove:function(field,error){formulario.removeSingleErro(field,error,'Info')},clearAll:function(){var form=$('formulario');var elements=form.getElements();elements.each(function(s,i){formulario.removeErro(s,'Info')})}};Formulario.prototype.validaErrosAvisos=function(e){new validateHandler(e);var qtdErro=formulario.getErrorCount('Error');var qtdErroNI=formulario.getErrorCount('ErrorNI');var qtdAviso=formulario.getErrorCount('Aviso');qtdErro=typeof(qtdErro)=='undefined'?0:qtdErro;qtdErroNI=typeof(qtdErroNI)=='undefined'?0:qtdErroNI;qtdAviso=typeof(qtdAviso)=='undefined'?0:qtdAviso;if(qtdErro>0){if(e!=undefined){Event.stop(e)}return false}var qtdTotal=qtdErroNI+qtdAviso;var msg;formulario.ErroNI.error=new Array();formulario.Aviso.error=new Array();if(!qtdErro&&qtdTotal&&qtdTotal!=0){if(formulario.validaErrosAvisos.msg){msg=formulario.validaErrosAvisos.msg}else{msg=(qtdTotal==1)?'Existe ':'Existem ';msg+=(qtdErroNI)?qtdErroNI+' erro':'';msg+=(qtdErroNI)?(qtdErroNI>1?'s ':' '):'';msg+=(qtdErroNI&&qtdAviso)?'e ':'';msg+=(qtdAviso)?qtdAviso+' aviso':'';msg+=(qtdAviso)?(qtdAviso>1?'s ':' '):'';msg+='. Deseja continuar?'}if(!confirm(msg)){if(e!=undefined){Event.stop(e)}return false}}return true};Event.observe(window,'load',function(){if(Prototype.Browser.IE&&$('formulario')&&typeof(formulario)!=='undefined'){Event.observe($('formulario'),'submit',formulario.validaErrosAvisos)}});var Handler={erroCriterio:Prototype.emptyFunction,erroMensagem:String(''),erroObject:Object(),field:Object(),messageTargets:Array(),start:function(erroCampo,erroCriterio,erroMensagem){this.erroCriterio=erroCriterio;this.erroMensagem=erroMensagem;this.messageTargets=new Array();this.field=erroCampo;this.addMessageTarget(erroCampo);this.observers(erroCampo)},validate:function(e,self){var erro=self.erroCriterio();if(erro==-1){return}else if(erro){self.messageTargets.each(function(s,i){self.erroObject.add(s,self.erroMensagem)})}else{self.messageTargets.each(function(s,i){self.erroObject.remove(s,self.erroMensagem)})}},removeMessage:function(erroMensagem){var self=this;this.messageTargets.each(function(s,i){self.erroObject.remove(s,self.erroMensagem)})},validateSubmit:function(e){if(formulario.getErrorCount('Error')>0){Event.stop(e);return}},addObserver:function(element,event){element=$(element);if(!event){this.observers(element);return}var self=this;Event.observe(element,event,function(e){self.validate(e,self)})},addMessageTarget:function(element){element=$(element);this.messageTargets.push(element)},observers:function(erroCampo){this.addObserver($('formulario'),'submit');this.addObserver(erroCampo,'change');this.addObserver(erroCampo,'blur');this.addObserver(erroCampo,'keyup')}};var objHandlers=Array();var validateHandler=function(e){objHandlers.each(function(s,i){s.validate(e,s)})};Handler.Erro=Class.create(Handler,{initialize:function(erroCampo,erroCriterio,erroMensagem){this.erroObject=formulario.Erro;this.start(erroCampo,erroCriterio,erroMensagem);objHandlers.push(this)}});Handler.ErroNI=Class.create(Handler,{initialize:function(erroCampo,erroCriterio,erroMensagem){this.erroObject=formulario.ErroNI;this.start(erroCampo,erroCriterio,erroMensagem);objHandlers.push(this)}});Handler.Aviso=Class.create(Handler,{initialize:function(erroCampo,erroCriterio,erroMensagem){this.erroObject=formulario.Aviso;var obj=this.start(erroCampo,erroCriterio,erroMensagem);objHandlers.push(this)}});Handler.Info=Class.create(Handler,{initialize:function(erroCampo,erroCriterio,erroMensagem){this.erroObject=formulario.Info;var obj=this.start(erroCampo,erroCriterio,erroMensagem);objHandlers.push(this)}});var Menu={open:function(self){var next=Menu.getChildHolder(self);Element.show(next);self.style.backgroundPosition='4px -25px';var parent=self.parentNode.parentNode.parentNode.firstChild;if(parent&&parent.hasClassName&&parent.hasClassName('Pai')){Menu.open(parent)}},close:function(self){var next=Menu.getChildHolder(self);Element.hide(next);self.style.backgroundPosition='4px 4px'},toggle:function(self){var next=Menu.getChildHolder(self);if(next.style['display']==''){Menu.close(self)}else{Menu.open(self)}},getChildHolder:function(parent){var next=parent.nextSibling;var i=0;while(next.nodeName!='UL'){next=next.nextSibling;if(++i==10||!next){return false}}return next}};Educachars={todos:String('\u002D\u00AA\a-zA-Z0-9\/\@\.\,\_\ \u00BA'),email:String('a-zA-Z0-9\@\.\_\u002D'),alfa:String('a-zA-Z'),numerico:String('0-9'),especial1:String('\/\.\,\u002D'),especial2:String('\u002D\u00AA\u00BA'),especial3:String('\u002D\u00AA\u00BA\/\.\,'),especial4:String('\u002D\u00AA\u00BA\/\.\,\_'),toUpper:function(e){if(Formulario.prototype.Util.keyCodeIsEscaped(e.keyCode)){return false}if(this.value)this.value=this.value.toUpperCase()},filtraTodos:function(element){element.value=element.value.replace(new RegExp('[ÁÀÂÃ]','gi'),'A');element.value=element.value.replace(new RegExp('[ÉÈÊ]','gi'),'E');element.value=element.value.replace(new RegExp('[ÍÌÎ]','gi'),'I');element.value=element.value.replace(new RegExp('[ÓÒÔÕ]','gi'),'O');element.value=element.value.replace(new RegExp('[ÚÙÛ]','gi'),'U');element.value=element.value.replace(new RegExp('[Ç]','gi'),'C');element.value=element.value.replace(new RegExp('[^'+Educachars.todos+']','g'),'')},aceitaEstes:function(element,quais){Educachars.filtraTodos(element);var stringExp=new String();var hasAlfa=false;quais.each(function(s,i){stringExp+=s;hasAlfa=(hasAlfa)?hasAlfa:((s==Educachars.alfa)?true:false)});if(hasAlfa){stringExp+='\ '}element.value=element.value.replace(new RegExp('[^'+stringExp+']','g'),'');element.value=element.value.replace(/\s+/g,' ')}};Event.observe(window,'load',function(){$$('input[rel=textoNormal]').each(function(s,i){eval("var controller = seamField_"+s.name+";");if(controller&&controller.mask==Prototype.emptyFunction){Event.observe(s,'blur',Educachars.toUpper);Event.observe(s,'blur',function(){Educachars.filtraTodos(this)})}})});var ValidacoesComuns={Util:{trim:function(input){return input.replace(/^\s+|\s+$/g,"")}},name:function(field,nomeDoCampo){var value=ValidacoesComuns.Util.trim(field.value);if(value.length>=1){if(value.length<4){return true}if(!value.match(new RegExp(/^\S{2,}\s\S{1,}/))){return true}var repeticoes=0;for(var i=0;i=4){return true;break}}}return false},nameEscola:function(field,nomeDoCampo){var value=ValidacoesComuns.Util.trim(field.value);if(value.length>=1){if(value.length<4){return true}}return false},nameCartorio:function(field,nomeDoCampo){return ValidacoesComuns.nameEscola(field,nomeDoCampo)}};