var layers_visible=[],top_interface="0",copy_from_formid="",DEBUG_MODE=false&&confirm("Ativar modo de debug?"),DEFAULT_TIMEOUT=60*1000,requestURLdone=[],requestURLold=[],LEFT,RIGHT,moz,POST,GET,XML,TEXT,tip;function Do(A){return A()}if(window.Ultra==null){window.Ultra=new Object}Ultra.Error=function(A){this.message=A};Ultra.Error.prototype.toString=function(){return(this.message!=null?this.message:"Plune gerou excessão desconhecida.")};window.Ultra.Floating=new Object;window.Ultra.Floating.maxZIndex=0;window.status="";function init(){if(opener){$(document.body).addClassName("AllBody")}}String.prototype.any=function(B,A){return B.include(this)};String.prototype.splice=function(A,C,B){if(A<0){A=this.length+A}return this.substr(0,A)+(B||"")+this.substr(A+C,this.length)};LEFT=1,RIGHT=2;String.prototype.pad=function(G,H,E){var F="",A=H-this.length,B,D,C;if(typeof G!="string"){G=String(G)}if(A<1){return this.substr(0,H)}B=Math.floor(A/G.length),D=A%G.length;for(C=0;C<B;C++){F+=G}F+=G.substr(0,D);switch(E){case LEFT:return F+this;case RIGHT:return this+F;default:throw"invalid side: "+E}};String.prototype.lpad=function(A,B){return this.pad(A,B,LEFT)};String.prototype.rpad=function(A,B){return this.pad(A,B,RIGHT)};String.prototype.asId=function(){return document.getElementById(this)};moz=!document.all;function keyCode(A){return moz?A.which:A.keyCode}function keyChar(A){return String.fromCharCode(keyCode(A))}function getTarget(A){return moz?A.target:A.srcElement}function fireEvent(A,B){return $(A).callEvent(B)}function addEvent(A,C,B){return Event.observe(A,C,B)}function removeEvent(A,C,B){return Event.stopObserving(A,C,B)}Ultra.ContextMenu=Class.create();Object.extend(Ultra.ContextMenu,{synchPosition:function(E){E=$(E);var C=parseInt(E.getStyle("top")||0),B=C+E.offsetHeight,D=B-(self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight),A;C-=Math.max(D,0);A=Math.max(C,0);E.setStyle({top:A+"px"})},event:"contextmenu",isFromSI:false,idPreffix:"b-",delay:100,callWith:function(E,C,B,A,F){B=B||this.event;var D=this.showEvent.bindAsEventListener(E,this,A,F);Event.observe(C,B,D);return D},showEvent:function(C,B,A,D){A=A!=null?A:C.clientX;D=D!=null?D:C.clientY;if(!B.fake){this.show(A,D)}else{delete B.fake}Event.stop(C)},initItem:function(F,B,E){var A,D,C;if(E!=null){D=this.hideItemContent.bind(E);A=this.showItemContent.bind(F,this,B,E,D);E.link=this.link.bind(E)}else{C=this;A=function(G){B.t=setTimeout(function(){if(F.fireEvent("onChange")===false){Event.stop(G)}},C.delay)}}Event.observe(B,"mouseover",A);Event.observe(B,"mouseout",function(){clearTimeout(B.t)})},link:function(A){this.listen("onHide",function(){return A.fireEvent("onHide")!==false})},getScreen:function(){var F=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,E=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop,C=self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,D=self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,A=F+C,B=E+D;return{top:E,left:F,width:C,height:D,right:A,bottom:B}},getZeroPosition:function(C){var B=C.parentNode,A=0,D=0;while(B!=null&&B.nodeType==1){if($(B).getStyle("position")=="absolute"&&(!moz||B.nodeName!="TABLE")){A+=parseInt($(B).getStyle("left")||0);D+=parseInt($(B).getStyle("top")||0)}B=B.parentNode}return{x:A,y:D}},show:function(H,F,E,A){if(!(H.fireEvent("onShow")&&this.fireEvent("onShow"))){return }$(this).setStyle({display:""});var I=H.getScreen(),B,G,D,C;F+=I.left;E+=I.top;if(!A){B=F+this.offsetWidth;G=E+this.offsetHeight;if(B>I.right){F-=B-I.right}if(G>I.bottom){E-=G-I.bottom}F=Math.max(I.left,F);E=Math.max(I.top,E)}D=H.getZeroPosition(this);F-=D.x;E-=D.y;$(this).setStyle({top:E+"px",left:F+"px",zIndex:++window.Ultra.Floating.maxZIndex,visibility:"visible"});C=this;H.hideSettings.events.each(function(J){Event.observe(H.hideSettings.element,J,C.hide)});H.listen("onShow",function(){C.hide();this.unlisten("onShow",arguments.callee)});H.listen("onClose",function(){C.hide();this.unlisten("onClose",arguments.callee)});this.visible=true;return true},hideActive:function(){return this.fireEvent("onClose")},showAtEvent:function(A){return this.show(A.clientX,A.clientY)},hide:function(B){if(B.fake){delete B.fake;return }else{if(!(B.fireEvent("onHide")&&this.fireEvent("onHide"))){return }}$(this).setStyle({display:"none",visibility:"hidden",height:""});var A=this;B.hideSettings.events.each(function(C){Event.stopObserving(B.hideSettings.element,C,A.hide)});this.visible=false;return true},hideSettings:{events:["mousedown","contextmenu"],element:document},hideItemContent:function(){this.fireEvent("onHide");$(this).setStyle({display:"none",visibility:"hidden",height:""})},showItemContent:function(D,A,C,B){var E=this;A.t=setTimeout(function(){if($(C).getStyle("visibility")=="visible"||!C.fireEvent("onShow")||!E.fireEvent("onChange")){return }E.listen("onHide",B);E.listen("onChange",function(){B();E.unlisten("onHide",B);E.unlisten("onChange",arguments.callee)});$(C).setStyle({display:""});var H=D.getScreen(),J=D.getZeroPosition(E),L=parseInt($(E).getStyle("left")||0)+J.x,F=L+A.offsetLeft+E.offsetWidth,K=parseInt($(E).getStyle("top")||0)+J.y+A.offsetTop,G=F+C.offsetWidth,I=K+C.offsetHeight;if(G>H.right){F-=E.offsetWidth+C.offsetWidth}else{F-=10}if(I>H.bottom){K-=I-H.bottom}F=Math.max(H.left,F);K=Math.max(H.top,K);F-=J.x;K-=J.y;$(C).setStyle({top:K+"px",left:F+"px",zIndex:++window.Ultra.Floating.maxZIndex,visibility:"visible"})},D.delay)},listeners:{onShow:[],onHide:[],onClose:[]},listen:function(C,B){var A=this.listeners[C];if(!A){throw"Unknow event "+C+"!"}if(!A.include(B)){A.push(B);return true}else{return false}},unlisten:function(C,B){var A=this.listeners[C];if(!A){throw"Unknow event "+C+"!"}if(A.include(B)){this.listeners[C]=A.without(B);return true}else{return false}},fireEvent:function(C){var B=this.listeners[C],A,D;if(!B){throw"Unknow event "+C+"!"}A=true;D=this;B.each(function(E){if(E.apply(D)===false){A=false;throw $break}});return A}});Ultra.ContextMenu.prototype.initialize=function(D,B,A){var C=window.Ultra.ContextMenu;D=$(D);C.hideSettings.events.each(function(E){Event.observe(D,E,function(){C.fake=true})});D.show=C.show.bind(D,C);D.showAtEvent=C.showAtEvent.bind(D);D.hide=C.hide.bind(D,C);D.listen=C.listen.bind(D);D.unlisten=C.unlisten.bind(D);D.listeners={onShow:[],onHide:[],onChange:[]};D.fireEvent=C.fireEvent.bind(D);B.each(function(F){var E=$(C.idPreffix+F);if(E==null){return }C.initItem(D,E,$(F))});if(A.linker!=null){$(A.linker).link(D)}else{if(A.caller!=null){C.callWith(D,A.caller,A.event)}}Try.these(function(){var E=String(D.firstChild.getAttribute("oninit"));if(E){new Function(E).apply(D)}})};function FormToHash(p,field_only){var myhash=new Object(),i,j;for(i=0;i<p.elements.length;i++){with(p.elements[i]){if(name==undefined||disabled==true||(field_only&&name.charAt(0)=="_")){continue}if((["radio","checkbox"].include(type)&&checked)||["hidden","text","textarea","select-one","password"].include(type)){if(p.elements[name].length){if(!myhash[name]){myhash[name]=new Array()}myhash[name].push(value)}else{myhash[name]=value}}else{if(type=="select-multiple"){for(j=0;j<childNodes.length;j++){if(childNodes[j].selected){myhash[name]=childNodes[j].value}}}}}}return myhash}function aryobjToAry(A){return $A(A)}function elformToObj(A){return Form.Methods.serialize(A,true)}function QueryString(){this.reset();var p=0 in arguments?arguments[0]:document.location.search,i,j,k,pairs,pair;if(!p){return }if(typeof p=="object"){if(typeof p.childNodes=="object"&&p.nodeName!="FORM"){p=elformToObj(p)}if(typeof p.elements=="object"&&p.nodeName=="FORM"){for(i=0;i<p.elements.length;i++){with(p.elements[i]){if(name==undefined||disabled==true){continue}if((["radio","checkbox"].include(type)&&checked)||["hidden","text","textarea","select-one","password"].include(type)){this.append(name,value)}else{if(type=="select-multiple"){for(j=0;j<childNodes.length;j++){if(childNodes[j].selected){this.append(name,childNodes[j].value)}}}}}}}else{for(var k in p){if(typeof p[k]=="object"){var _this=this;$A(p[k]).map(function(e){_this.append(k,e)})}else{this.append(k,p[k])}}}}else{if(typeof p=="string"){pairs=p.replace(/^.*\?/,"").split(/[&;\n]/);for(i=0;i<pairs.length;i++){pair=pairs[i].split("=");this.append(pair[0],unescape(pair[1]))}}}}QueryString.prototype.param=function(B,A){if(B==undefined){return this.parameters}else{if(A!=undefined){this.reset(B);this.append(B,A)}}return this.parameters[B]};QueryString.prototype.append=function(B,A){if(!this.param(B)){this.parameters[B]=[]}else{if(!(this.parameters[B] instanceof Array)){this.parameters[B]=[this.parameters[B]]}}if(A instanceof String){this.parameters[B].push(A)}else{if(A!=null&&typeof A=="object"){for(var C=0;C<A.length;C++){this.parameters[B].push(A[C])}}else{this.parameters[B].push(A)}}return this.parameters[B]};QueryString.prototype.reset=function(A,B){if(A==undefined){this.parameters={}}else{if(B==undefined){delete this.parameters[A]}else{this.param(A).splice(B<0?this.param(A).length+B:B,1)}}};QueryString.prototype.toString=function(A){var C=[],B,D;for(B in this.param()){for(D=0;D<this.param(B).length;D++){C.push(escape(B)+"="+escape(this.param(B)[D]).replace(/\+/g,encodeURIComponent("+")))}}C=C.join("&");if(!A){return C}else{if(!/[?&]$/.test(A)){A+=/\?/.test(A)?"&":"?"}}return A+C};QueryString.prototype.location=function(A){document.location.href=this.toString(A)};POST="POST",GET="GET",XML="responseXML",TEXT="responseText";function AJAX(F,A,E,D,C){this.method=F||GET;this.URL=A||"Class.cgi";if(E!=null&&typeof E=="object"&&E.tagName=="FORM"){E=$(E).serialize(true)}this.vars=E instanceof QueryString?E:new QueryString(E);this.events={success:D||AJAX.events.success,fail:AJAX.events.fail,loading:AJAX.events.loading,loaded:AJAX.events.loaded,interactive:AJAX.events.interactive,complete:AJAX.events.complete,error:AJAX.events.error};this.type=C||TEXT;var B=1;while(B in AJAX.requests){B++}AJAX.lastRequest=B;this.id=AJAX.requests[B]=this;this.actions=[]}AJAX.wait=function(B,C){C=C||this.lastRequest;var A=this.requests[C];if(!C){B()}else{A.actions.push(B)}};AJAX.prototype={method:null,URL:null,vars:null,events:null,type:null};AJAX.requests={};AJAX.status={1:"Não foi possível instanciar objeto XMLHTTP.",2:"URL não especificada.",3:"Método de submissão desconhecido.",4:"Tipo de resposta inválido.",403:"Você não tem permissão para esta requisição.",404:"Página não encontrada.",500:"Erro interno do servidor.",503:"Página requisitada não pode ser carregada."};AJAX.counter=0;AJAX.events=new Object;AJAX.events.loading=function(B,A){window.status="["+B+"] Carregando URL "+A+"..."};AJAX.events.complete=function(B,A){if(A==200){window.status=window.AJAX&&window.AJAX.counter?"Requisição n.º "+B+" concluída. Carregando (resta(m) "+window.AJAX.counter+")...":"Concluído."}else{window.status="Request #"+B+" falhou. Mensagem de erro"+(A in AJAX.status?": "+AJAX.status[A]:" desconhecida.")}};AJAX.events.success=eval;AJAX.events.fail=function(B){var A="não foi possível fazer requisição.\n\nErro "+B+":\n"+(B in AJAX.status?AJAX.status[B]:"<Desconhecido>");alert(new Ultra.Error(A))};AJAX.events.error=function(A){AJAX.counter--;if(A.constructor!=Event){alert(window.status=A||"A requisição AJAX foi interrompida!")}};AJAX.prototype.request=function(){var onSuccess,onFail,onLoading,onLoaded,onInteractive,onComplete,onError,XMLHTTP,type,vars,URL,method,reqNum,currentState,_this,__fail__;with(this.events){onSuccess=success,onFail=fail,onLoading=loading,onLoaded=loaded,onInteractive=interactive,onComplete=complete,onError=error}XMLHTTP;type=new String(this.type);if(window.XMLHttpRequest){XMLHTTP=new XMLHttpRequest;if(type==XML&&XMLHTTP.overrideMimeType){XMLHTTP.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{XMLHTTP=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{XMLHTTP=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return onFail(1)}}}}vars=this.vars,URL=this.URL;if(!URL){return onFail(2)}method=this.method.toUpperCase();if(method==GET&&vars){URL=vars.toString(URL);if(URL.length>1024){URL=this.URL;method=POST}}reqNum;if(window.XMLHttpRequest){XMLHTTP.onerror=onError}currentState=1;_this=this,__fail__=this.events.fail;XMLHTTP.onreadystatechange=function(){switch(XMLHTTP.readyState){case 1:if(currentState!=1){break}reqNum=++AJAX.counter;if(onLoading){onLoading(reqNum,URL)}currentState=2;break;case 2:if(currentState!=2){break}if(onLoaded){onLoaded()}currentState=3;break;case 3:if(currentState!=3){break}if(onInteractive){onInteractive()}currentState=4;break;case 4:if(currentState!=4){break}try{AJAX.counter--}catch(e){}var status=XMLHTTP.status,res,header=XMLHTTP.getResponseHeader("PluneException");if(header){header=unescape(header)}if(onComplete){onComplete(reqNum,status)}if(status==200&&!header){if(![window.XML,window.TEXT].include(type)){return __fail__(4)}res=XMLHTTP[type];onSuccess(res)}else{if(header&&onError){return onError(header)}else{return __fail__(status)}}currentState=null;_this.actions.invoke("call",_this,XMLHTTP);delete AJAX.requests[_this.id]}};XMLHTTP.open(method,URL,true);if(method==POST){XMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}XMLHTTP.setRequestHeader("Referer",document.location);switch(method){case POST:XMLHTTP.send(vars.toString());break;case GET:XMLHTTP.send(null);break;default:return onFail(3)}return this.id};function checkForm(I){I=$(I);var G=I.getAttribute("oncheckstart"),E=I.getAttribute("oncheckbefore"),J=I.getAttribute("check"),H=I.getAttribute("oncheckafter"),B,C,D,A,K;if(G){B=new Function("form","frm",G);try{B.call(I,I,I.elements)}catch(F){throw new Error("Error on 'checkstart' form event: "+F)}}C=new Object;if($A(I.elements).any(function(L){return checkField($(L),C)===false})){return false}if(E){B=new Function("form","frm",E);try{B.call(I,I,I.elements)}catch(F){throw new Error("Error on 'checkbefore' form event:"+F)}}if(J){B=new Function("form","frm",J);try{if(B.call(I,I,I.elements)==false){return false}}catch(F){throw new Error("Error on 'check' form event: "+F.description)}}for(D=0;D<I.elements.length;D++){A=I.elements[D],K=A.getAttribute("oncheckafter");if(K){B=new Function("el","form","frm",K);try{B.call(A,A,I,I.elements)}catch(F){throw new Error("Error on 'checkafter' form element event: "+F)}}}if(H){B=new Function("form","frm",H);try{B.call(I,I,I.elements)}catch(F){throw new Error("Error on 'checkafter' form event: "+F)}}return true}function checkField(E,G){var K=E.form,I,M,C,L,H,D,F,B,A;if(!G){G={}}if(E.disabled&&E.isChanging){E.isChanging=E.disabled=false;return true}if(!E.name||E.disabled||E.style.display=="none"||E.name in G){return true}if(["checkbox","radio"].include(E.type)){E=findElementAndIgnore(E,G)}I=E.getAttribute("oncheckbefore"),M=E.getAttribute("notnull"),C=E.getAttribute("pattern"),L=E.getAttribute("onnotnullfail")||K.getAttribute("onnotnullfail"),H=E.getAttribute("onpatternfail")||K.getAttribute("onpatternfail"),D=E.getAttribute("check");if(I){F=new Function("el","form","frm",I);try{F.call(E,E,K,K.elements)}catch(J){throw new Error("Error on 'checkbefore' form element event: "+J)}}B=M?["checkbox","radio"].include(E.type)?E.checked?E.value!=null&&E.value.length?false:true:true:E.value!=null&&E.value.length?false:true:false;if(B){if(L){F=new Function("el","form","frm",L);try{F.call(E,E,K,K.elements)}catch(J){throw new Error("Error on 'notnullfail' form/element event: "+J)}}return false}if(E.value!=null&&E.value.length){if(C){A=new RegExp(C);if(!A.test(E.value)){if(H){F=new Function("el","form","frm",H);try{F.call(E,E,K,K.elements)}catch(J){throw new Error("Error on 'pattern' form element event: "+J)}}return false}}if(D){F=new Function("el","form","frm",D);try{if(F.call(E,E,K,K.elements)==false){return false}}catch(J){throw new Error("Error on 'check' form event: "+J)}}}return true}function findElementAndIgnore(E,D){var F=E.form,B=E.name,A=F.elements[B],C;D[B]=true;if(A!=null){for(C=0;C<A.length;C++){E=A[C];if(E.checked){return E}}return A[0]||E}else{return E}}Ultra.Menu=Class.create();Ultra.Menu.prototype.initialize=function(D){var C=parent.$("Top").contentWindow,G=parent.$("Desktop"),I=G.contentWindow,K=C.$("Icon"),L=I.Ultra.ContextMenu,M=I.$("Main"),J=M.contentWindow,A=I.$("ExplorerContainer"),B,H,E,F;if(!D){B=function(){L.hideActive()};H=function(){try{J.Ultra.ContextMenu.hideActive();[J,G].each(function(Q){try{Q.Ultra.ChoiceDialog.dialogs.invoke("close")}catch(P){}})}catch(O){}};E=function(){L.hideActive();L.listen("onShow",H);try{J.Ultra.ContextMenu.listen("onShow",B)}catch(O){}Event.observe(C.document,"click",H);Event.observe(J.document,"mousedown",B);Event.observe(J.document,"contextmenu",B)};F=function(){L.unlisten("onShow",H);Event.stopObserving(C.document,"click",H)}}function N(O){if(!L.fake){prepareEvent(K,function(){try{I.$("Explorer").show(0,0);[J,G].each(function(R){try{R.Ultra.ChoiceDialog.dialogs.invoke("close")}catch(Q){}})}catch(P){}},250,"mouseout")}else{delete L.fake}O&&Event.stop(O)}K.observe("mouseover",N);K.observe("click",function(O){Event.stop(O)});K.observe("dblclick",function(){L.hideActive();I.requestURL("GET","Class.cgi?_ClassId=Ultra.INDEX&_Ultra.INDEX.Method=Explorer&_Show=1",null,A);K.hide();new Insertion.After(K,"<img src='/t/default/img/loading.gif' title='Recarregando pacotes do menu principal. Por favor, aguarde...' />")});if(!D){Event.observe(C.document,"click",function(){L.hideActive()});A.observe("click",function(Q){var O=Event.element(Q),P=O.tagName.toLowerCase()=="a"?O:O.up("a");if(P.target!="self"){M.setStyle({display:"block",zIndex:++I.Ultra.Floating.maxZIndex})}});Event.observe(M,"load",E);Event.observe(M,"unload",F)}};Ultra.Menu.reload=function(C){C.show(0,0);var B=parent.$("Top").contentWindow.$("Icon"),A=B.next("img");A.parentNode.removeChild(A);B.show()};Ultra.Class=Class.create();Object.extend(Ultra.Class.prototype,{initialize:function(A){this.ClassId=A},process:function(F,I,E){I=I||{};E=E||{};if(typeof I=="form"){I=FormToHash(I)}var C=this.ClassId,H={},B,A,D,G;$w("_Level _null __debug__").each(function(K){if(K in I){H[K]=I[K];delete I[K]}});for(B in I){if(!/\./.test(B)){A=B.indexOf("_")==0?B.replace(/^(_)(.+)$/,"$1"+C+".$2"):C+"."+B;H[A]=I[B];delete I[B]}}if(E.targetElement){I._V="SOA";I._VX="HTML";I["_"+C+".OK"]=1;I["_"+C+".NextMethod"]="Select"}Object.extend(I,H);I._ClassId=C;I["_"+C+".Method"]=F;D=this;if(E.onLoading){E.onLoading.call(D)}var J=E.targetElement?document.location.pathname:(E.keepSession?"REST.cgi":"/Ultra/REST.cgi");G=new AJAX(POST,J,I);G.events.success=function(L){if(E.targetElement){$(E.targetElement).update(L);return }var K;try{K=typeof L=="string"?L.evalJSON():null}catch(M){K={ErrorStatus:M.description}}finally{Object.extend(D,K);D.ClassId=C;if(!D.ErrorStatus){(E.onSuccess||Prototype.emptyFunction).call(D)}else{if(E.onError){E.onError.call(D,D.ErrorStatus)}else{lbox(D.ErrorStatus+"<br>"+D.ErrorStatus2)}}(E.onAfterAll||Prototype.emptyFunction).call(D)}};G.events.fail=E.onFail;G.request()},Select:function(B,A){this.process("Select",B,A)},Call:function(B,A){this.process("Call",B,A)},Browse:function(B,A){this.process("Browse",B,A)},MSelect:function(C,A){var B=$H({});for(k in C){if(k.indexOf("_")!=0){B[k]=C[k];delete C[k]}}C._MSelectOnly=1;C._MSelect=B.toQueryString();this.process("Browse",C,A)},Insert:function(B,A){this.process("Insert",B,A)},Delete:function(B,A){this.process("Delete",B,A)},Update:function(B,A){this.process("Update",B,A)},MultiExecute:function(B,A){this.process("MultiExecute",B,A)},MultiInsert:function(B,A){B._XMethod="MultiInsert";this.process("Insert",B,A)},$v:function(B,A){return A!=null?this.row[A][B].value:this.Field[B].value},$r:function(B,A){return A!=null?this.row[A][B].resolved:this.Field[B].resolved},setOption:function(C,B,A){C=$(C);if(B==null){B=C.FieldId()}if(C.setOption){C.setOption(this.$r(B),this.$v(B),A)}else{alert(new Ultra.Error("Campo "+C.getAttribute("description")+" não é uma combo."))}},map:function(G,C){G=$(G);var H=this,F,B,D,E,A;C.each(function(I){F=I.s,B=I.d||I.s,D=G.field(B),A=G.field("__Fake."+D.ClassId()+"."+B),E=H.constructor.maphandler[I.h||"value"];if(A){E.call(H,A,F);D.value=A.value}else{if(D){E.call(H,D,F)}}})}});Ultra.Class.maphandler={value:function(B,C){var A=this.$v(C);B.value=A!=null?A:""},resolved:function(B,C){var A=this.$r(C);B.value=A!=null?A:""},number:function(B,C){var A=typeof C=="function"?C.call(this):this.$v(C);B.value=A!=null?A:"";Ultra.Number.number2String.call(B)},combo:function(A,B){this.setOption(A,B)}};Ultra.ChoiceDialog=Class.create();Object.extend(Ultra.ChoiceDialog,{MIN_DIALOG_WIDTH:480,MAX_DIALOG_WIDTH:640,MAX_BODY_HEIGHT:100,MIN_BUTTON_WIDTH:100,DEFAULT_TITLE:"Plune",DEFAULT_CANCEL_OPTION:true,CANCEL_BUTTON_LABEL:"Cancelar",dialogs:[],Method:{close:function(C){var A=this.dialog,B;if(!A.showing()||(A.choice()&&(A.choice().handler.call(A)===false||!A.fire("choose")))||(A.cancel()&&!A.fire("cancel"))||(!A.fire("close")&&!C)){return false}B=this.previous(".ChoiceDialogBackground");try{document.body.removeChild(B);document.body.removeChild(this)}catch(D){}A.showing(false);(function(E){this.dialogs=this.dialogs.without(E)}).call(A.constructor,this);return true},choose:function(B){var A=this.dialog;if(B!=undefined){A.choice(A.getChoiceByValue(B))}return this.close()},cancel:function(){if(this.dialog.cancel()){this.dialog.choice(null)}return this.close()}}});$w("title body choice cancel showing").each(function(A){var B="_"+A;Ultra.ChoiceDialog.prototype[A]=function(C){if(C===undefined){return this[B]}else{this[B]=C;return this}}});Ultra.ChoiceDialog.prototype.message=Ultra.ChoiceDialog.prototype.body;Object.extend(Ultra.ChoiceDialog.prototype,{initialize:function(E){var A=this.constructor,C,B,D,G,F;this.title(A.DEFAULT_TITLE).cancel(A.DEFAULT_CANCEL_OPTION);this.choiceList=[];this.eventMap={};(function(H){$w("create show choose cancel close").each(function(I){H.eventMap[I]=[]})})(this);if(E){for(C in E){B=E[C];if(C=="choice"){if(typeof B=="string"){B=$w(B)}if(B instanceof Array){(function(H){B.each(function(I){H.addChoice(I,I)})})(this)}else{if(typeof B=="object"){for(D in B){G=B[D];if(typeof G=="string"){G={text:G}}else{if(G instanceof Array){G={text:G[0],handler:G[1],focus:G[2]}}else{if(typeof G!="object"){G={text:D,handler:G}}}}this.addChoice(D,G.text,typeof G.disabled=="boolean"?G.disabled:G.handler,G.focus)}}}}else{if(C.match(/^on[A-Z]/)){F=C.match(/^on(.+)/)[1].toLowerCase();this.listen(F,B)}else{this[C](B)}}}}return this},addChoice:function(D,E,C,A){var B={};B.value=new String(D);B.text=E;B.focus=A;if(typeof C=="boolean"){B.disabled=true}else{B.handler=C||Prototype.emptyFunction}this.choiceList.push(B);return this},dropChoice:function(A){if(typeof A=="string"){A=this.getChoiceByValue(A)}this.choiceList=this.choiceList.without(A);return A},getChoiceByValue:function(A){return this.choiceList.find(function(B){return B.value==A})},listen:function(A,B){this.eventMap[A].push(B);return this},unlisten:function(B,C){if(B){this.eventMap[B]=C?this.eventMap[B].without(C):[]}else{for(var A in this.eventMap){this.eventMap[A]=[]}}return this},fire:function(){var A=$A(arguments),D=A.shift(),B=this,C=true;this.eventMap[D].each(function(E){if(E.apply(B,A)===false){C=false;throw $break}});return C},show:function(){if(this.showing()||!this.fire("create")){return false}var F={top:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop,left:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,width:self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},D=(function(){new Insertion.Bottom(document.body,"<div></div>");return $($A(document.body.childNodes).last())})().addClassName("ChoiceDialogBackground").setStyle({position:"absolute",top:F.top+"px",left:F.left+"px",width:F.width+"px",height:F.height+"px",zIndex:++window.Ultra.Floating.maxZIndex}),A=this.dialog=(function(){new Insertion.Bottom(document.body,"<div></div>");return $($A(document.body.childNodes).last())})().addClassName("ChoiceDialog").setStyle({visibility:"hidden"}),E,G,B,J,K,I,H,C;[D,A].each(function(L){L.observe("contextmenu",function(M){Event.stop(M)})});if(moz){A.setStyle({"-moz-user-select":"none"})}else{A.observe("selectstart",function(L){Event.stop(L)})}E=this.constructor;new Insertion.Bottom(A,"<div class='title'>"+this.title()+"</div><div class='body'>"+this.body()+"</div><div class='buttons'></div>");G=A.down(".buttons");this.choiceList.each(function(M,L){B=(function(){new Insertion.Bottom(G,"<input type='button' name='"+M.value.escapeHTML()+"' value='"+M.text.escapeHTML()+"' />");return $($A(G.childNodes).last())})().addClassName("btn Choice").observe("focus",function(){A.dialog.choice(M)}).observe("click",function(){A.choose(this.name)});if(B.disabled){B.addClassName("Current")}B.disabled=M.disabled;if(B.getWidth()<E.MIN_BUTTON_WIDTH){B.setStyle({width:E.MIN_BUTTON_WIDTH+"px"})}});if(this.cancel()){J=(function(){new Insertion.Bottom(G,"<input type='button' value='"+E.CANCEL_BUTTON_LABEL+"' />");return $($A(G.childNodes).last())})().addClassName("btn Choice Cancel").observe("focus",function(){A.dialog.choice(null)}).observe("click",function(){A.cancel()});if(J.getWidth()<E.MIN_BUTTON_WIDTH){J.setStyle({width:E.MIN_BUTTON_WIDTH+"px"})}}A.dialog=this;Object.extend(A,E.Method);K=Math.min(F.width,Math.max(A.getWidth(),E.MIN_DIALOG_WIDTH),E.MAX_DIALOG_WIDTH),I=(F.left+(F.width/2)-(K/2)),H=(F.top+(F.height/2)-A.getHeight());A.setStyle({width:K+"px",top:Math.max(H,0)+"px",left:Math.max(I,0)+"px",visibility:"visible",zIndex:++window.Ultra.Floating.maxZIndex});(function(L){A.body=L;if(L.getHeight()>E.MAX_BODY_HEIGHT){L.setStyle({height:E.MAX_BODY_HEIGHT+"px"})}})(A.down(".body"));D=A.previous(".ChoiceDialogBackground");[{element:D,event:"click"},{element:window,event:"scroll"}].each(function(L){Event.observe(L.element,L.event,function(M){A[A.dialog.cancel()?"cancel":"close"]();Event.stopObserving(L.element,M.type,arguments.callee)})});Event.observe(document,"keydown",function(L){if(A.dialog.showing()){if(A==E.dialogs.last()&&L.keyCode==Event.KEY_ESC){A.cancel()}}else{Event.stopObserving(this,L.type,arguments.callee)}});new Draggable(A,{handle:A.down(".title"),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction,reverteffect:Prototype.emptyFunction});C=this.choiceList.find(function(L){return L.focus===true});if(C){A.down("input[name='"+C.value+"']").focus()}else{if(J){J.focus()}else{A.down("input[name='"+this.choiceList.first().value+"']").focus()}}this.showing(true);E.dialogs.push(A);if(!this.fire("show")){A.close(true);return false}else{return true}}});function COMPARE_TAG(A){return function(B){return B.nodeType==1&&B.tagName==A.toUpperCase()}}function COMPARE_ATTRIBUTE(A,B){return function(D){if(D.nodeType!=1){return false}var C=D.getAttribute(A);return B!=undefined?C==B:C!=undefined}}function getChilds(C,D){var A=[],B,E;for(B=0;B<C.childNodes.length;B++){E=C.childNodes[B];if(D(E)){A.push(E)}A=A.concat(getChilds(E,D))}return A}function getParent(B,C){var A=B.parentNode;if(A){return C(A)?A:getParent(A,C)}}function getPrevious(B,C){var A=B.previousSibling;if(A){return C(A)?A:getPrevious(A,C)}}function getNext(B,C){var A=B.nextSibling;if(A){return C(A)?A:getNext(A,C)}}(function(){function A(B,D,C){alert(new Ultra.Error("não pode executar operação "+B+".\n\n"+C))}Ultra.Try=function(F,C,G,B){var D,I=0,E=[];C=C||1000;G=G||10;B=B||A;function H(){try{F(D,I,E);clearInterval(D);return true}catch(J){E[I]=J;I++;if(I==G){clearInterval(D);B(D,I,E)}return false}}H()||(D=setInterval(H,C));return D}})();Ultra.Try(function(){Element.addMethods({callEvent:function(F,D){if(document.dispatchEvent){if(D.startsWith("on")){D=D.substr(2)}var E;if($w("click mousedown mouseup mouseover mousemove mouseout").include(D)){E=document.createEvent("MouseEvents");E.initMouseEvent("click",true,true,window,0,0,0,0,0,false,false,false,false,0,null)}else{E=document.createEvent("HTMLEvents");E.initEvent(D,true,false)}F.dispatchEvent(E)}else{if(!D.startsWith("on")){D="on"+D}F.fireEvent(D)}},getForm:function(F){var D=$(F),E=D.form;if(E){return $(E)}return D.up("form")}});function C(F,E){if(E==null){E=String(E)}var D=F.ClassId();if(D){if(E.indexOf(".")==-1){if(E.startsWith("_")){E="_"+D+"."+E.substr(1)}else{E=D+"."+E}}}return E}function B(G,D,F,E){G.fieldList(D).each(function(H){if(F==null||(H.value.toUpperCase()==F.toUpperCase())){H.checked=E}})}function A(D){return String(D.tagName).toUpperCase()!="SELECT"&&(D.toArray||D.length)}Element.addMethods("FORM",{ClassId:function(F,E){var D=F.elements._ClassId;if(D){if(E!=null){D.value=E}return D.value}},Method:function(F,E){var D=F.field("_Method");if(D){if(E!=null){D.value=E}return D.value}},Level:function(F,E){var D=F.elements._Level;if(D){if(E!=null){D.value=E}if(!isNaN(D.value)){return parseInt(D.value)}}},field:function(G,F,E){F=C(G,F);if(E==null||E<0||isNaN(E)){E=0}var D=G.elements[F];if(D){return $(A(D)?D[E]:D)}},fieldList:function(F,E){E=C(F,E);var D=F.elements[E];if(D){if(A(D)){D=$A(D).map(Element.extend)}else{D=[D]}return D}},checkCheckbox:function(F,D,E){return B(F,D,E,true)},uncheckCheckbox:function(F,D,E){return B(F,D,E,false)},save:function(F,D){var E=F.ClassId(),G=F.Method();if(E&&G){(new Ultra.Class(E)).process(G,F.serialize(true),D)}}});Element.addMethods($w("INPUT SELECT BUTTON TEXTAREA"),{ClassId:function(F){var D=F.name,E=(D.startsWith("_")?1:0);return D.substr(E,D.lastIndexOf(".")-E)},FieldId:function(E){var D=E.name;return D.substr(D.lastIndexOf(".")+1)},index:function(G){var F=G.form,E=G.name,D=-1;if(E&&F.elements[E]!=G){D=$A(F.elements[E]).indexOf(G)}return D},field:function(H,D){var F=C(H,D),E=H.index(),G=$(H.form);return G.field(F,E)||G.field(C(G,D))},allValues:function(F,D){try{return D.select("input[name="+F.name+"],select[name="+F.name+"],button[name="+F.name+"],textarea[name="+F.name+"]").map(function(G){return G.value})}catch(E){}},empty:function(D){return D.value.length==0},parseFloat:function(F,E){var D=parseFloat(typeof (E)!="undefined"?E:F.value.replace(".","","g").replace(",","."));return isNaN(D)?0:D}});Element.addMethods("SELECT",{setOption:function(H,I,F,E){if(F==null){F=""}var G=$(H),J=false,D;G.value=F;if(G.value!=F){D=document.createElement("option");D.text=I;D.value=F;G.options.add(D);D.selected=E==null||E;J=true}setTimeout(function(){G.callEvent("change")},0);return J},currentOption:function(D){return $(D.options[D.options.selectedIndex])}});Event.keyCode=function(D){return D.which||D.keyCode}},1000,10,function(){alert(new Ultra.Error("não pode carregar biblioteca extendida"))});function HelpSearch(E,C,A,B,D){requestURL("GET",(A?A:document.location.pathname)+"?_ClassId="+(B?B:"Ultra.INDEX")+"&_"+(B?B:"Ultra.INDEX")+".Method=AjaxSuperContext&_PackageId=*HELP*&_search_inside="+D+"&_Search="+E.elements._Search.value,null,C,0);$(C).style.display=""}function prepareEvent(D,B,E,F,C,G){E=E||500;F=F||"mouseout";var I=setTimeout(B,E),A;function H(){clearTimeout(I);Event.stopObserving(D,F,H)}Event.observe(D,F,H);if(C){A=G.type;function J(){B();Event.stopObserving(C,A,J)}Event.observe(C,A,J)}}function initForm(B){B=$(B);if(B){var A=B.getAttribute("init");if(A!=null){Ultra.Try(function(){(new Function(A)).call(B)})}return true}else{return false}}function checkBoolean(B){B=$(B);var A=B.next("input");if(B.checked){A.value=1}else{A.value=0}}function IECombo(B,A){if(!moz){Try.these(function(){var C=true;if(keyCode(A)==38){B.options[B.options.selectedIndex-1].selected=true}else{if(keyCode(A)==40){B.options[B.options.selectedIndex+1].selected=true}else{C=false}}if(C){Event.observe(B,"blur",function(D){$(B).callEvent("change");Event.stopObserving(B,D.type,arguments.callee)})}});if([38,40].include(keyCode(A))){Event.stop(A)}}}function toggleTrBelow(A){A=$(A);while(A&&!A.hasAttribute("rowtop")&&!A.hasClassName("row_total")){A=A.next();if(A.hasClassName("sibbSection")){return }A.toggle()}}function toggleTdRight(A){A=$(A);if(A.nodeName.toUpperCase()=="IMG"&&A.src){A.src=A.src.match(/\/action\/OpenUp.png$/)?A.src.replace(/\/OpenUp.png$/,"/OpenDown.png"):A.src.replace(/\/OpenDown.png$/,"/OpenUp.png");A.src=A.src.match(/\/action\/OpenLeft.png$/)?A.src.replace(/\/OpenLeft.png$/,"/OpenRight.png"):A.src.replace(/\/OpenRight.png$/,"/OpenLeft.png")}if(A.nodeName.toUpperCase()!="TD"){A=A.up("td")}while(A){A=A.next();A.toggle()}}function reorderBrowse(M,E,N,L,P){var C=Event.element(L);var I=M.elements;var F=I["_"+I._ClassId.value+".Method"].value=="AjaxBrowseCombo"?I._ParentClassId.value:I._ClassId.value;var B=I["_"+F+".Order"];var H=I["_"+F+".OrderDesc"];var K=$A(B.value.split(","));var A=$A(H.value.split(","));if(P&&!L.ctrlKey){tab=C.up("table");for(var J=1;J<tab.rows.length;J++){var G=tab.rows[J].cells[tab.rows[J].cells.length-4].firstChild;if(G&&G.firstChild){G.firstChild.src="/t/c/img/OrderAny.png";G.lastChild.innerHTML=""}}}if(N==null){N=A[K.indexOf(E)]=="0"?"1":A[K.indexOf(E)]=="1"?"":"0"}if(N==""&&!L.ctrlKey){B.value="";H.value=""}else{if(N==""){K.splice(K.indexOf(E),1);A.splice(K.indexOf(E),1);B.value=K.join(",");H.value=A.join(",")}else{if(L.ctrlKey&&B.value.length){if(K.indexOf(E)>-1){A[K.indexOf(E)]=N}else{K.push(E);A.push(N)}B.value=K.join(",");H.value=A.join(",")}else{B.value=E;H.value=N}}}K=$A(B.value.split(","));if(!P){M.onsubmit()}else{C.src="/t/c/img/Order"+(N=="1"?"Desc":N=="0"?"":"Any")+".png";C.nextSibling.innerHTML=K.indexOf(E)>-1?K.indexOf(E)+1:""}}function showHideFormSection(B){var A=B.rowIndex,C=B.parentNode.rows[A+1];while(C&&C.className!="row_section"&&!C.getAttribute("stopSection")&&(C.firstChild.className=="k"||A==B.rowIndex)){C.style.display=C.style.display=="none"?"":"none";A+=1;C=B.parentNode.rows[A+1]}}function showHideFormSection2(A){var B=A.nextSibling;while(B&&findChildElement(B,"INPUT")){B.style.display=B.style.display=="none"?"":"none";B=B.nextSibling}return void (0)}function ClassLock(B){var C=document.forms[B],A;C.setAttribute("LockCount",0);A=C.elements["_"+C.elements._ClassId.value+".Method"].value;C.elements["_"+C.elements._ClassId.value+".Method"].value="AjaxLock";requestURL("POST","Class.cgi",C,document.getElementById(B+".lockx"),0,false,true,true);C.elements["_"+C.elements._ClassId.value+".Method"].value=A;if(parseInt(C.getAttribute("LockCount"))==45){setTimeout(function(){try{if(confirm("Você já está há muito tempo com esse registro aberto. Clique OK em 1 minuto se não quiser perder seus dados!")){C.setAttribute("LockCount",0)}else{C.elements["_"+C.elements._ClassId.value+".Cancel"].click()}}catch(D){}},100)}if(parseInt(C.getAttribute("LockCount"))<60){C.setAttribute("LockEvent",setTimeout(function(){ClassLock(B)},20000))}else{if(parseInt(C.getAttribute("LockCount"))>=60){C.elements["_"+C.elements._ClassId.value+".Method"].value="Select";C.elements["_"+C.elements._ClassId.value+".XMethod"].value="Unlock";C.elements["_"+C.elements._ClassId.value+".Submit"].click()}}}function showFn(B,A,C,D){singleTime=D==1?0:1;var E=findParentElement(C,"FORM");requestURL("GET","Class.cgi?_ClassId="+B+"&_"+B+".Method=AjaxShowFn&_"+B+".FieldId="+A+"&_ParentFormId="+E.name,"",C,singleTime)}function Mask(B,E,D){var A=B.value.replace(/\W/gi,""),C;for(C=0;C<A.length;C++){if(!/[#A9%]/.test(E.charAt(C))){A=A.splice(C,1,E.charAt(C)+A.charAt(C))}else{if((E.charAt(C)=="A"&&!/[a-z]/i.test(A.charAt(C)))||(E.charAt(C)=="9"&&!/[0-9]/.test(A.charAt(C)))||(E.charAt(C)=="%"&&!/[0-9a-fA-F]/.test(A.charAt(C)))||(E.charAt(C)=="#"&&!/\w/.test(A.charAt(C)))){A=A.splice(C,1)}}}B.value=A.substr(0,E.length)}function raiseError(A,B){alert("RaiseError:"+B);showMyInterface(A);window.status=B;setTimeout(function(){$(A).activate()},100)}function onNotNullFail(A){raiseError(A,"Campo '"+(A.getAttribute("description")||"["+A.name+"]")+"' não pode ser nulo!")}function onPatternFail(A){raiseError(A,"Campo '"+(A.getAttribute("description")||"["+A.name+"]")+"' possui valor inválido!")}function showMyInterface(A){Try.these(function(){SuperInterfaceShow(A.getAttribute("layer_id"),A.getAttribute("layer_i"),1)});Try.these(function(){var B=findParentElement(A,"DIV","class","SuperInterfaceLayerOff").id.split(/-/);SuperInterfaceShow(B[1],B[2],1)})}Ultra.ArrayBuilder=function(A){A=$(A);var B=A.up("table");B.setAttribute("onAdd",B.getAttribute("onAdd")+";this.createSortable()");(A.createSortable=function(){Sortable.create(A,{tag:"tr",only:["i","p"],starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction,onUpdate:arguments.callee})})();A.observe("keypress",addToArrayByKey)};function addToArray(N,A){N=N.parentNode;var L=N.parentNode,H=N.nextSibling,K=N.cloneNode(true),J,F,I,D,B,M,E,G,C;I=function(P,O){M=F[O],E=M.selectedIndex;P.value=M.options[E].value};if(!A){$A(K.getElementsByTagName("input")).concat($A(K.getElementsByTagName("textarea"))).each(function(O){$(O);if((typeof (O.getAttribute("keeponclone"))!="undefined"&&typeof (O.getAttribute("keeponclone"))!="unknow"&&O.getAttribute("keeponclone")!="0"&&O.getAttribute("keeponclone")!="false")&&(O.disabled||O.hasClassName("fakedDisabledInput"))){return }if(!moz){if(typeof $(N).getForm().field(O.name)!="undefined"&&typeof $(N).getForm().field(O.name)!="unknow"){O.defaultValue=$(N).getForm().field(O.name).defaultValue}}if(O.getAttribute("keepOnClone")){return }else{O.value=O.defaultValue}});F=N.getElementsByTagName("select");aryobjToAry(K.getElementsByTagName("select")).map(function(P,O){if(P.getAttribute("keepOnClone")){I(P,O)}})}else{F=N.getElementsByTagName("select");aryobjToAry(K.getElementsByTagName("select")).map(I)}D=L.parentNode.getAttribute("onBeforeAdd");C=true;if(D){B=new Function("row",D);if((C)||(typeof C=="undefined")){C=B.call(L,K)}else{B.call(L,K)}}$A(K.getElementsByTagName("input")).concat($A(K.getElementsByTagName("select"))).concat($A(K.getElementsByTagName("textarea"))).each(function(O){var P=O.getAttribute("onBeforeAdd"),Q;if(P){Q=new Function(P);if((C)||(typeof C=="undefined")){C=Q.call(P)}else{Q.call(P)}}});if((!C)&&(typeof C!="undefined")){return false}L.insertBefore(K,H);D=L.parentNode.getAttribute("onAdd");if(D){B=new Function("row",D);B.call(L,K)}$A(K.getElementsByTagName("input")).concat($A(K.getElementsByTagName("select"))).concat($A(K.getElementsByTagName("textarea"))).each(function(O){var Q=O.getAttribute("onAdd"),P;if(Q){P=new Function(Q);P.call(O)}});return K}function addToArrayByKey(F){if(Event.element(F).readAttribute("sbox")=="1"){return }if(!F.shiftKey&&!F.ctrlKey&&[Event.KEY_RETURN,Event.KEY_TAB].include(F.keyCode)){var E=Event.element(F),D=E,H,C,B,A,G;do{H=D.up("td");C=H.up("tr");D=B=C.up("tbody");if(B.up("table").hasClassName("Browse")){break}}while(!B.up("table").hasClassName("Browse"));A=$A(C.getElementsByTagName("*")).select(function(I){$(I);return["INPUT","SELECT"].include(I.nodeName.toUpperCase())&&!I.disabled&&I.type!="hidden"&&I.visible()});if(B.lastChild==C&&A.last()==E){G=addToArray(H,F.ctrlKey);$($A(G.getElementsByTagName("*")).find(function(I){$(I);return["INPUT","SELECT","TEXTAREA"].include(I.nodeName.toUpperCase())&&!I.disabled&&I.type!="hidden"&&I.visible()})).activate();Event.stop(F)}}}function onAddExternalFile(B){var A=$A(B.getElementsByTagName("div")).first();if(A){A.parentNode.removeChild(A)}$A(B.getElementsByTagName("input")).each(function(C){if(C.type=="file"){C.disabled=false;$(C).setStyle({display:""})}else{if(C.type=="hidden"&&C.name&&C.name.endsWith(".keep")){C.parentNode.removeChild(C)}}})}function dropFromArray(H,E){if(E===undefined){E=true}var J=H.parentNode,I=J.parentNode,C=I.firstChild.className=="row_top"?2:1,A,G,D,B,F;D=$(J).up("table").getAttribute("onBeforeDrop");B=true;if(D){A=new Function(D);if((B)||(typeof B=="undefined")){B=A.call(D)}else{A.call(D)}}$A(J.getElementsByTagName("input")).concat($A(J.getElementsByTagName("select"))).concat($A(J.getElementsByTagName("textarea"))).each(function(K){var L=K.getAttribute("onBeforeDrop"),M;if(L){M=new Function(L);if((B)||(typeof B=="undefined")){B=M.call(L)}else{M.call(L)}}});if((!B)&&(typeof B!="undefined")){return false}B="";D=$(J).up("table").getAttribute("onDrop");if(D){A=new Function(D);A.call(D)}$A(J.getElementsByTagName("input")).concat($A(J.getElementsByTagName("select"))).concat($A(J.getElementsByTagName("textarea"))).each(function(K){var M=K.getAttribute("onDrop"),L;if(M){B+=M}});if(I.rows.length==C){if(!E){return false}G=$A(J.getElementsByTagName("input"));G=G.concat($A(J.getElementsByTagName("textarea")));G.each(function(K){if(K.getAttribute("keepOnClone")&&K.value!=K.defaultValue){K.value=K.defaultValue;return }if(["radio","checkbox"].include(K.type)){K.checked=false}else{if(!K.getAttribute("keepOnClone")){K.value=""}}});$A(J.getElementsByTagName("select")).each(function(K){if(K.options[0].value==""){K.value=""}})}else{I.removeChild(J)}A=new Function(B);A.call(B);return true}function getSession(A){A=A||"/";return String(Math.random()).substr(2,10).split("").join(A)}function popUp(F,A,C,G,D){var B,E;A=A||getSession("_")+"popup";if(G==null){G=getSession()}if(C==null){C="toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width=640,height=480"}if(!D){if(F.indexOf("?")==-1){F="Class.cgi?"+F}B=(G==-1?F:"/Ultra/"+G+"/"+F);return window.open(B,A,C)}else{B="/Ultra/"+G+"/"+(F.substr(0,F.indexOf("?"))||"Class.cgi");F=F.substr(F.indexOf("?")+1);E="<form method='post' action='"+B.escapeHTML()+"' target='"+A.escapeHTML()+"'>";$H(F.toQueryParams()).each(function(H){if(typeof H.value=="string"){H.value=[H.value.replace(/\'/gim,"&#39;")]}H.value.each(function(I){E+="<input type='hidden' name='"+H.key.escapeHTML()+"' value='"+I.escapeHTML()+"' />"})});E+="</form>";new Insertion.Bottom(document.body,E);E=$A(document.forms).last();window.open("",A.escapeHTML(),C);E.submit();document.body.removeChild(E)}}function SendMail(D,B,C,A){if(A){C=C.replace(/\r?\n/,"\n<br>")}if(D==undefined){D=""}if(B==undefined){B=""}if(C==undefined){C=""}var E=new QueryString({_ClassId:"Company.Mail","_Company.Mail.Method":"Insert","_Company.Mail.OK":"Fake","Company.Mail.To":D,"Company.Mail.Subject":B,"Company.Mail.Message":C}).toString();popUp(E,null,"toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width=800,height=640",null,(E.length>1000?true:false))}function popCalInsert(F,C,A,G){var E="Class.cgi?_ClassId="+C+"&_Level="+escape(F.elements._Level.value)+"&_"+C+".Method=Insert&"+C+"."+A+"="+escape(F.getAttribute("TODAY"))+"&_"+C+".OK=Fake&_"+C+".NextMethod="+escape("internal:opener.submit('"+F.name+"');"),B,D;for(B in G){if(G[B]&&B!=C+"."+A){E+="&"+(/\./.test(B)?"":C+".")+B+"="+escape(G[B])}}D="InsertForm"+getSession().replace(/\//gi,"_");return window.open(E,D,"toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width=640,height=480")}function cm(B){var A=Event.element(B);return calMenu(A,B)}function calMenu(C,D){var B=findParentElement(C,"FORM"),A=C.getAttribute("TODAY");try{if(A==null){A=findParentElement(C,"TD").getAttribute("TODAY")}}catch(D){}try{if(A==null){A=findParentElement(C,"TR").getAttribute("TODAY")}}catch(D){}B.setAttribute("TODAY",A);$("CalendarMenu-"+B.name).showAtEvent(D);Event.stop(D);return false}function XSchema(C,B,E,A,F,G,H){if(!B){alert("Erro interno: é obrigatório que se especifique a SchemaId como primeiro parâmetro para a função XSchema.");return false}if(typeof H!="undefined"){Event.stop(H)}var D;if(G){if(G.ClassFK){var I=/^\*\*.+\*\*\d+\*\*$/.test(G.ClassFK)?("Ultra.ClassFK.Name="+G.ClassFK.split("**").reverse()[1]):"Ultra.ClassFK.Name="+G.ClassFK;D=G.ClassFK=="*"?"_ClassId=Ultra.ClassFK&_Ultra.ClassFK.Method=Insert&Ultra.ClassFK.SignatureId="+C+"&Ultra.ClassFK.SchemaId="+B+"&Ultra.ClassFK.ClassId="+A+"&_Ultra.ClassFK.lockFields=SignatureId&_Ultra.ClassFK.lockFields=SchemaId&_Ultra.ClassFK.lockFields=ClassId&_Ultra.ClassFK.OK=Fake":"_ClassId=Ultra.ClassFK&_Ultra.ClassFK.Method=Update&Ultra.ClassFK.SignatureId="+C+"&Ultra.ClassFK.SchemaId="+B+"&Ultra.ClassFK.ClassId="+A+"&"+I}}else{if(F){D=F=="*"?"_ClassId=Ultra.ClassField&_Ultra.ClassField.Method=Insert&&_Ultra.ClassField.XMethod=Insert&Ultra.ClassField.SignatureId="+C+"&Ultra.ClassField.SchemaId="+B+"&Ultra.ClassField.ClassId="+A+"&_Ultra.ClassField.lockFields=SignatureId&_Ultra.ClassField.lockFields=SchemaId&_Ultra.ClassField.lockFields=ClassId&_Ultra.ClassField.OK=Fake":"_ClassId=Ultra.ClassField&_Ultra.ClassField.Method=Update&Ultra.ClassField.SchemaId="+B+"&Ultra.ClassField.ClassId="+A+"&Ultra.ClassField.FieldId="+F}else{if(A){D=A=="*"?"_ClassId=Ultra.Class&_Ultra.Class.Method=Insert&Ultra.Class.SignatureId="+C+"&Ultra.Class.SchemaId="+B+"&Ultra.Class.PackageId="+E+"&_Ultra.Class.lockFields=SignatureId&_Ultra.Class.lockFields=SchemaId&_Ultra.Class.lockFields=TypeOwner&_Ultra.Class.OK=Fake":"_ClassId=Ultra.Class&_Ultra.Class.Method=Update&Ultra.Class.SchemaId="+B+"&Ultra.Class.ClassId="+A}else{if(E){D=E=="*"?"_ClassId=Ultra.Package&_Ultra.Package.Method=Insert&Ultra.Package.SignatureId="+C+"&Ultra.Package.SchemaId="+B+"&_Ultra.Package.lockFields=SignatureId&_Ultra.Package.lockFields=SchemaId&_Ultra.Package.OK=Fake":"_ClassId=Ultra.Package&_Ultra.Package.Method=Update&Ultra.Package.SchemaId="+B+"&Ultra.Package.Id="+E}else{if(B){D=B=="*"?"_ClassId=Ultra.Schema&_Ultra.Schema.Method=Insert&Ultra.Schema.SignatureId="+C+"&_Ultra.Schema.Fake=1":"_ClassId=Ultra.Schema&_Ultra.Schema.Method=Update&Ultra.Schema.SchemaId="+B}}}}}popUp(D,"XSchema"+String(Math.random()).substr(2,10));return false}function DebugTask(C,G,B,E){if(!C){alert("Erro interno: é obrigatório que se especifique a SchemaId como primeiro parâmetro para a função DebugTask.");return false}var F={SchemaId:C,PackageId:G,ClassId:B,FieldId:E},D="_ClassId=Ultra.ClassDebugTask&_Ultra.ClassDebugTask.Method=Browse&_Ultra.ClassDebugTask.OK=1&_Ultra.ClassDebugTask.Order=DataFim&_Ultra.ClassDebugTask.OrderDesc=1&_Ultra.ClassDebugTask.XMethod=Docs",A;for(A in F){if(F[A]){D+="&Ultra.ClassDebugTask."+A+"="+F[A]}}popUp(D,"ClassDebugTask"+String(Math.random()).substr(2,10));return false}function splitQueryString(A){var D=A.split(/&|\?/gi),C={},B,E;for(B=0;B<D.length;B++){E=D[B].split("=");C[E[0]]=E[1]}return C}function bg2s(D,B){D=$(D);var A=D.getForm(),C=A.fieldList("_GroupBy").inject([],function(E,F){E.push(F.value);E.push(B.first().length?B.shift():"\\n");return E});return BrowseG2S(A.name,C)}function BrowseG2S(C,D){var E=document.forms[C],B,A;for(B=0;B<D.length;B+=2){E.elements[E.elements._ClassId.value+"."+D[B]].value=D[B+1]}for(A=0;A<E.elements.length;A++){if(E.elements[A].name=="_"+E.elements._ClassId.value+".GroupBy"){E.elements[A].disabled=true}}E.onsubmit()}function jumpField(E){var C=Event.element(E),B,A,D;if(!C.form){return }if(C.readAttribute("sbox")=="1"){return }if(E.ctrlKey||E.keyCode!=Event.KEY_RETURN||["button","submit","reset","textarea"].include(C.type)){return }B=E.shiftKey,A=$A(C.form.elements).select(function(F){return $(F)&&F.focus&&!F.disabled&&F.getStyle("display")!="none"&&F.getStyle("visibility")!="hidden"&&!["hidden","button","reset"].include(F.type)});A.each(function(F,G){D=A[G+(B?1:-1)];if(D==C){showMyInterface(F);$(F).activate();Event.stop(E);return $break}})}Ultra.Number={keypress:function(D){var A=Event.keyCode(D),E,B;if(!D.ctrlKey&&![9,13,35,36,37,38,39,40,46].include(A)){E=this.getAttribute("scale"),B=this.getAttribute("precision"),precisionfree=this.getAttribute("precisionfree");var C=this.value.split(",");if(precisionfree!=null&&B!=null&&C.length>1&&C[1].length>=B&&(A>=48&&A<=57)){Event.stop(D)}else{if([8,48].include(A)&&this.value.match(/^0(?:,0+)?$/)&&(B!=null||this.value=="0")&&precisionfree==null){if(A==8){this.value=""}Event.stop(D)}else{if(A==45&&this.getAttribute("signed")&&this.value.length>0&&!this.value.match(/^0(?:,0*)?$/)){this.value=this.value.indexOf("-")==0?this.value.substr(1):"-"+this.value;Event.stop(D)}else{if(E!=null&&(B!=null||(A!=44&&this.value.indexOf(",")==-1))&&this.value.replace(/\D/g,"").length==E&&A!=8){Event.stop(D)}else{if(A==44&&((precisionfree==null&&B!=null)||this.value.indexOf(",")>-1)){Event.stop(D)}else{if(![8,44].include(A)&&(A<48||A>57)){Event.stop(D)}}}}}}}},formatInt:function(D){var E=this.getAttribute("scale"),C=this.getAttribute("dotted"),A=D.replace(/\D/g,""),G,B,F;if(A!="0"){A=A.replace(/^0+/,"")}if(E!=null&&A.length>E){A=A.substr(A.length-E,E)}if(C){for(G="",B=A.length-1,F=1;B>=0;B--,F++){G=A.charAt(B)+G;if(F%3==0&&B!=0){G="."+G}}A=G}return A},trunc:function(B,C){if(C==null){C=0}var A=B.toString().indexOf("."),E,D;if(A==-1){return B}E=Math.pow(10,C+1);D=parseInt((B*E).toString().substr(A,C+1).substr(-1));if(D>=5){B=B+(9/E)}return parseFloat(B.toString().substr(0,A+C+1))},number2String:function(){var G=parseFloat(this.value),A,F,E,H,L,D,C,K,I,J,B;if(isNaN(G)){return }A=G<0&&this.getAttribute("signed"),F=this.getAttribute("scale"),E=this.getAttribute("precision");if(F!=null){F=parseInt(F)}if(E!=null){E=parseInt(E)}G=Ultra.Number.trunc(G,E);if(G<0){G*=-1}if(F!=null&&E!=null){F-=E}H=String(G).split("."),L=String(H[0]),D=H[1]!=null?String(H[1]):"";if(this.getAttribute("dotted")){C="",K=L.length;for(I=1;I<=K;I++){C=L.substr(K-I,1)+C;if(I%3==0&&I<K){C="."+C}}L=C}if(E!=null){if(D.length>E){D=D.substr(0,E)}else{if(E>0){L=L||"0";J=E-D.length;for(I=0;I<J;I++){D+="0"}}}}if(A){L="-"+L}B=L;if(D.length){B+=","+D}this.value=B},keyup:function(I){var G=this.getAttribute("scale"),F=this.getAttribute("precision"),C=this.getAttribute("precisionfree"),B=this.getAttribute("signed"),K,D,J,E,H;var A=this.value.split(",");if(F==0||A.length==1){K=Ultra.Number.formatInt.call(this,this.value);if(B&&this.value.indexOf("-")==0&&K!="0"){K="-"+K}this.value=K}else{if(F!=null&&C!=null&&A.length>1&&A[1].length==0){}else{if(F!=null){if(C!=null){F=A[1].length>F?F:A[1].length}D=this.value.replace(/\D/g,"");if(G!=null&&D.length>G){D=D.substr(D.length-G,G)}J=D.split(""),E=J.splice(J.length-F,F).join(""),K=Ultra.Number.formatInt.call(this,J.join(""));if(E.length>0){E=E.lpad(0,F)}if(E.length>0&&K.length==0){K="0"}if(B&&this.value.indexOf("-")==0&&(K.match(/[^0]/)||E.match(/[^0]/))){K="-"+K}this.value=K.length>0&&E.length>0?K+","+E:""}else{H=this.value.split(","),E=H.length>1?H.pop():null,K=Ultra.Number.formatInt.call(this,H.join(""));if(B&&this.value.indexOf("-")==0&&(K.match(/[^0]/)||(E!=null&&E.match(/[^0]/)))){K="-"+K}if(E!=null){if(K.length==0){K="0"}K+=","+E}this.value=K}}}},blur:function(F){var D=this.getAttribute("precision"),A=this.getAttribute("precisionfree"),E,C,B;if(D==null){E=this.value.split(",");if(E.length==2){C=E[0],B=E[1];B=parseFloat("."+B);if(B>0){this.value=C+","+String(B).substr(2)}else{this.value=C}}}else{if(D!=null&&A!=null){E=this.value.split(",");if(E.length==2&&!E[1]){this.value=E[0]}}}},setPrecision:function(A){this.setAttribute("precision",A);this.value=this.value.replace(".",".","g").replace(",",".");if(this.value.length>0){Ultra.Number.number2String.call(this)}},setValue:function(A){this.value=A;Ultra.Number.number2String.call(this)}};function putPoint(C){var D=0,B="",A;for(A=C.length-1;A>=0;A--){D++;B=C.charAt(A)+B;if(D%3==0&&A>0){B="."+B}}return B}function float2Money(D,F,C){D=String(D==null?"":D);if(D=="0"||D.length==0){return D}D=D.replace(/^0+/,"");F-=C;if(D.indexOf(".")==-1){D=putPoint(D.substr(Math.max(D.length-F,0),F));if(C>0){D+=","+String(0).times(C)}return D}else{var E=D.split("."),B=E[0].length==0?"0":putPoint(E[0].substr(Math.max(E[0].length-F,0),F)),A;if(!C){return B}A=E[1].substr(0,C).rpad(0,C);if(A.length>0){B+=","+A}return B}}function MaskMoney(A,E,D,G){if(A.value.length==0){return }var C=G?A.value.match(/-/g):null;var I=!C||C.length%2==0?1:-1;var H=A.value.replace(/\D/g,"");var F,B;if(H.length>E){H=H.substr(H.length-E)}else{H=H.lpad(0,E);F=H.substr(0,E-D),B=H.substr(H.length-D,D);H=Number(F+"."+B)*I;A.value=float2Money(H,E,D)}}function _MaskMoney(A,D,B,J,I){if(A.value.length==0||A.value=="0"){return }if(!(/-/).test(A.value)&&J){J=0}var E=A.value.replace(/\D/g,"").replace(/^0+/,"").substr(0,D),F=0,C=Math.max(E.length-B,0),G=putPoint(E.substr(0,C)),H=E.substr(C,E.length);if(H&&!G){G=0}if(Number(H)>0){H=H.lpad(0,B)}A.value=[G,H].grep("return String(e).length");if(J){A.value="-"+A.value}}function modifyDate(A,C){var B=A.value;if(B.match(/^\d{1,2}\/\d{1,2}\/(?:\d{2}|\d{4})$/)){if(B.match(/\/\d{2}$/)){A.value=B.replace(/\/(\d{2})$/,"/20$1")}}}function checkDate(B){var F=B.split("/"),A=parseInt(Number(F[0])),E=parseInt(Number(F[1])),C=parseInt(Number(F[2])),D;if([A,E,C].any(isNaN)){return false}D=E<8?E==2?!(C%100)?!(C%400)?29:28:!(C%4)?29:28:E%2?31:30:E%2?30:31;return A&&A<=D&&E&&E<=12}function changeParentSelect(J,G,H,I){var F=document.forms[J],A=F.elements[G],C=F.elements["_v."+G],D,B;if((!A.type)&&A.length){for(D=0;D<A.length;D++){if(A[D].getAttribute("ActiveCombo")==1){A=A[D];try{C=C[D]}catch(E){}}}}A.value=H;try{C.value=H}catch(E){}if(A.value!=H){B=document.createElement("option");B.text=I;B.value=H;B.selected=true;A.options.add(B)}window.setTimeout(function(){$(A).callEvent("change")},100);A.lastValue=H}function TextLimit(D,B,A,E){var C=B.value.replace(/[\r]/g,"").replace(/[\r\n]/g,"..").length+1;if(!B.onkeyup){B.onkeyup=function(){if(this.value.length>A){this.value=this.value.substr(0,A)}if(typeof E=="string"){document.getElementById(E).innerHTML=A-B.value.length}else{if(typeof E=="object"){E.innerHTML=A-B.value.length}}}}if(C>A&&![0,8].include(String(keyCode(D)))){return false}}function NumberOnly(C){var A=String(keyCode(C)),B=keyChar(C);if(![0,8,13].include(A)){return A!=32&&!isNaN(B)}}function PositiveNegativeOnly(E,B){var A=String(keyCode(E)),C=keyChar(E),D=new RegExp(/^[-]{1}/);D=D.exec(B.value);B.value=B.value.replace(/[A-Za-z!@#$%*+={}\[\]~^`´,.<>;\-]/gi,"");if(D!=null){B.value=D+B.value}if(B.value=="-"){B.value=""}if(![0,8,13,45].include(A)){return A!=32&&!isNaN(C)}if(A==45){if(B.value.indexOf("-")==-1){B.value="-"+B.value;return false}else{return false}}}function addNumber(B,E,C){var A=Number(B.value),D=Number(E);B.value=(A+D);if(!C&&Number(B.value)<0){B.value=0}}function SuperInterfaceShow(B,G,C){if(G==null){G=0}if(C){SuperInterfaceShow(B,layers_visible[B],0)}var F=getSIb(B,G),D,E,A;if(!F){return }D=F.getAttribute("altClass");E=getSI(B,G);A=E.getAttribute("altClass");if(C){layers_visible[B]=G;if(F.className.match(/Off$/)||F.className.match(/Off /)||!F.className){F.setAttribute("altClass",F.className);E.setAttribute("altClass",E.className);E.className=A||"SuperInterfaceLayer";F.className=D?D:"SuperInterfaceAba"}E.setAttribute("seen",1)}else{if(!F.className.match(/Off$/)||F.className.match(/Off /)||!F.className){F.setAttribute("altClass",F.className);E.setAttribute("altClass",E.className);E.className=A||"SuperInterfaceLayerOff";F.className=D?D:"SuperInterfaceAbaOff"}}}function SuperInterfaceInitMenu(E,F){E=$(E);F=$(F);var A,B=false,D,C;D=function(H){clearTimeout(A);if($(F).getStyle("visibility")!="visible"&&!B){var G=Position.page(E);F.show(G[0],G[1]+$(E).getHeight(),true);window.Ultra.ContextMenu.isFromSI=true;$(E).addClassName("SuperInterfaceAbaMenuOpened");B=true;Event.stopObserving(E,"mouseover",arguments.callee)}};Event.observe(E,"mouseout",function(){A=setTimeout(function(){B=false},0)});Event.observe(E,"mousedown",function(){B=true});C=function(){Event.observe(E,"mouseover",D);window.Ultra.ContextMenu.isFromSI=false};C();F.listen("onHide",function(){C();$(E).removeClassName("SuperInterfaceAbaMenuOpened")})}function SuperInterfaceInitMenuForIE7(A){if(!moz&&window.XMLHttpRequest){Event.observe(A,"mouseover",function(B){window.Ultra.ContextMenu.isFromSI=false});Event.observe(A,"mouseout",function(B){if(!Position.within(A,B.clientX,B.clientY)){window.Ultra.ContextMenu.isFromSI=true}else{Event.stop(B)}})}}function SuperInterfaceShowNext(A,C){var B=getSINextLayerUnseenIndex(A,C);if(B>0&&getSI(A,B)!=null){SuperInterfaceShow(A,B,1);if(getSI(A,B).offsetTop<300){window.scrollTo(0,0)}else{window.scrollTo(0,getSI(A,B).offsetTop)}return true}else{return false}}function getSI(A,B){return document.getElementById("layers-"+A+"-"+B)}function getSIb(A,B){return document.getElementById("b-layers-"+A+"-"+B)}function getSINextLayerIndex(A,C){var B;if(C==null||C==0){C=1}if(layers_visible[A]==0||layers_visible[A]==null){B=1}else{B=layers_visible[A]+C}if(getSI(A,B)){return B}else{return null}}function getSINextLayerUnseenIndex(A,B){var C=getSINextLayerIndex(A,B);if(C&&getSI(A,C).getAttribute("seen")!="1"){return C}else{return null}}function SuperInterfaceVertShow(A,C,B){if(C==null){C=0}if(B){if(layers_visible[A]!=null&&layers_visible[A]==C){SuperInterfaceShow(A,layers_visible[A],0);layers_visible[A]=null}else{if(B<2){SuperInterfaceShow(A,layers_visible[A],0)}layers_visible[A]=C;document.getElementById("layers-"+A+"-"+C).style.display="";document.getElementById("b-layers-"+A+"-"+C).className="SuperInterfaceVertAba"}}else{document.getElementById("layers-"+A+"-"+C).style.display="none";document.getElementById("b-layers-"+A+"-"+C).className="SuperInterfaceVertAbaOff"}}function checkCNPJ_CPF(A){var B=A.replace(/\D/g,"");if(B.length>0){if(B.length==11){return checkCPF(B)}else{if(B.length==14){return checkCNPJ(B)}else{return false}}}return true}function checkCPF(A){A=A.replace(/\D/g,"");var C,E,B,D;E=A.substr(0,9);B=A.substr(9,2);D=0;for(C=0;C<9;C++){D+=E.charAt(C)*(10-C)}if(D==0){return false}D=11-(D%11);if(D>9){D=0}if(B.charAt(0)!=D){return false}D*=2;for(C=0;C<9;C++){D+=E.charAt(C)*(11-C)}D=11-(D%11);if(D>9){D=0}if(B.charAt(1)!=D){return false}return true}function checkCNPJ(B){B=B.replace(/\D/g,"");var D,F,C,A,E;F=B.substr(0,12);C=B.substr(12,2);A=0;E=0;for(D=0;D<12;D++){E+=F.charAt(11-D)*(2+(D%8))}if(E==0){return false}E=11-(E%11);if(E>9){E=0}if(C.charAt(0)!=E){return false}E*=2;for(D=0;D<12;D++){E+=F.charAt(11-D)*(2+((D+1)%8))}E=11-(E%11);if(E>9){E=0}if(C.charAt(1)!=E){return false}return true}function maskCNPJ_CPF(A,C){var B=A.value.length;if(B<=14||(keyCode(C)==8&&B==14)){Mask(A,"999.999.999-99",C)}if(B>14){Mask(A,"99.999.999/9999-99",C)}}function checkValueInput(C,B,A){(function(F,G){var E=inputInArr(F,G);if(E!=null){B=B[E]}})(C.form,C);if(B.lastValue==null){B.lastValue=""}for(var D=0;D<B.childNodes.length;D++){if(B.childNodes[D].value==null){B.childNodes[D].value=""}if(C.value.toUpperCase()==B.childNodes[D].value.toUpperCase()){B.childNodes[D].selected=true;C.value=B.childNodes[D].value;if(C.value!=B.lastValue){$(B).callEvent("change")}B.lastValue=C.value;return true}}if(A&&C.value!=B.lastValue){changeParentSelect(B.form.name,B.name,C.value,"Carregando...")}}function checkValueInputOnBlur(B,A){(function(F,G){var E=inputInArr(F,G);if(E!=null){A=A[E]}})(B.form,B);var D=false,C;for(C=0;C<A.childNodes.length;C++){if(B.value.toUpperCase()==A.childNodes[C].value.toUpperCase()){D=true}}if(B.value!=""&&!D){alert("Valor digitado não é uma opção válida.")}return D}function showBrowseForm(B){var C=document.forms[B],A=C.elements["_"+C.elements._ClassId.value+".Method"].value,D=C.elements._ParentFormId.value;window.open("",B,"width=420,height=550,left=0,top=0,scrollbars=yes,menubar=no,status=no,toolbar=no,titlebar=no,resizable=yes,location=no,directories=no");C.target=B;C.elements["_"+C.elements._ClassId.value+".Method"].value="BrowseForm";C.submit();C.elements._ParentFormId.value=D;C.elements["_"+C.elements._ClassId.value+".Method"].value=A;C.target=""}function RenameReport(B,A,C,F){var E=document.forms[B],D=prompt("Renomear Relatório "+C,F);if(D==null||D.length==0||D==F){return }E.elements["_"+E.elements._ClassId.value+".ClassReportId"].value=C;E.elements["_"+E.elements._ClassId.value+".XMethod"].value="Rename";E.elements["_"+E.elements._ClassId.value+".Filename"].value=D;submitReport(B,A);E.elements["_"+E.elements._ClassId.value+".ClassReportId"].value=""}function SaveReportAs(B,A,C){var D=document.forms[B];if(!confirm("Deseja mesmo sobreescrever este Modelo com as configurações da consulta atual?")){return }D.elements["_"+D.elements._ClassId.value+".ClassReportId"].value=C;D.elements["_"+D.elements._ClassId.value+".XMethod"].value="Save";submitReport(B,A);D.elements["_"+D.elements._ClassId.value+".ClassReportId"].value=""}function DeleteReport(D,B,E,A){var F=document.forms[D],C="Deseja realmente excluir definitivamente este Modelo?";if(A){C+="\n\nATENÇÃO: Este modelo está compartilhado com outras unidades!"}if(!confirm(C)){return }F.elements["_"+F.elements._ClassId.value+".ClassReportId"].value=E;F.elements["_"+F.elements._ClassId.value+".XMethod"].value="Delete";submitReport(D,B);F.elements["_"+F.elements._ClassId.value+".ClassReportId"].value=""}function BookmarkReport(C,B,D){var A=document.forms[C].elements;if(!confirm("Deseja realmente "+(D==""?"desmarcar":"definir")+" o Modelo "+D+" como padrão incial desta tabela?")){return }A["_"+A._ClassId.value+".ClassReportId"].value=D;A["_"+A._ClassId.value+".XMethod"].value="Bookmark";submitReport(C,B);A["_"+A._ClassId.value+".ClassReportId"].value=""}function ShareReport(D,B,E,C){var A=document.forms[D].elements;if(!confirm("Deseja realmente "+(C==1?"compartilhar":"tornar privado")+" o Modelo "+E+(C==1?" com os demais usuários desta empresa":"")+"?")){return }A["_"+A._ClassId.value+".ClassReportId"].value=E;A["_"+A._ClassId.value+".XMethod"].value=C==1?"Share":"Unshare";submitReport(D,B);A["_"+A._ClassId.value+".ClassReportId"].value=""}function SaveReport(H,D,G){var C=document.forms[H].elements,F=C["_"+C._ClassId.value+".Filename"],B=C._ClassId.value,E=C._ParentClassId.value,A;if(G==2){C._ClassId.value=C._ParentClassId.value;C._ParentClassId.value=B;C._SubMethod.value=2}if(F&&F.value.length==0){A=prompt("Nome do Modelo","Favorito");if(A==null||A==""){return }F.value=A}if(C["_"+C._ClassId.value+".Bookmark"]&&G){C["_"+C._ClassId.value+".Bookmark"].checked=G?true:false}C["_"+C._ClassId.value+".XMethod"].value="Save";submitReport(H,D);C["_"+C._ClassId.value+".XMethod"].value="";C._ClassId.value=B;C._ParentClassId.value=E;C._SubMethod.value=""}function submitReport(D,C){var E=document.forms[D],B=E.elements,A=B["_"+B._ClassId.value+".Method"].value;B["_"+B._ClassId.value+".Method"].value="AjaxReport";requestURL("POST","Class.cgi",E,C,0);B["_"+B._ClassId.value+".Method"].value=A;E.target=""}function LoadReportMSelect(D,B){var F=document.forms[D],C=F.elements,A=C._ClassId.value;if(($A(C["_"+A+".MSelect"])[0]&&$A(C["_"+A+".MSelect"])[0].type!="hidden")&&!isChecked(C["_"+A+".MSelect"])){alert("Selecione um ou mais registros para aplicar o Modelo ou clique no nome do Modelo para não restringir.");return false}try{window.Ultra.ContextMenu.currentMenu.hide()}catch(E){}LoadReport(F.name,B,{_MSelectOnly:1})}function LoadReport(E,C,G){var F=document.forms[E],D=F.elements,B=D._ClassId.value;var A={_ClassId:D._ClassId.value,_Level:D._Level.value};A["_"+B+".Method"]="AjaxBrowse";A["_"+B+".ParentElementId"]=D["_"+B+".ParentElementId"].value;if(C){A["_"+B+".ClassReportId"]=C}else{A["_"+B+".Reset"]=1}if(G){for(k in G){A[k]=G[k]}}if(A["_"+B+".MSelectOnly"]||A._MSelectOnly){delete A._MSelectOnly;A["_"+B+".MSelectOnly"]=1;if(D["_"+B+".MSelect"]&&D["_"+B+".MSelect"].value){A["_"+B+".MSelect"]=[D["_"+B+".MSelect"].value]}else{A["_"+B+".MSelect"]=[$A(D["_"+B+".MSelect"]).map(function(H){if(H.checked||H.type=="hidden"){return H.value}else{return null}})]}}if(D["_"+D._ClassId.value+".Method"].value=="AjaxBrowse"){requestURL("POST","Class.cgi",A,document.getElementById(D["_"+B+".ParentElementId"].value),0,180000)}else{D["_"+D._ClassId.value+".Method"].value="BrowseForm";D["_"+D._ClassId.value+".ClassReportId"].value=C;F.target="_self";F.submit()}}function showReportsBelow(B){var C=B.nextSibling,A=C.style.display?"":"none";while(C&&C.className!="row_top"){C.style.display=A;C=C.nextSibling}}function popupInstance(E,F){var G=document.forms[E],A=G.action,D=G.elements._Level.value,C=G.elements["_"+G.elements._ClassId.value+".Method"].value,B;G.action="/Ultra/"+getSession()+"/Class.cgi";G.elements._Level.value=0;G.elements["_"+G.elements._ClassId.value+".Method"].value=F?F:"Select";B="popupSelect_"+getSession().replace(/\//g,"_");window.open("",B,"toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width=640,height=480");setValue(E,{},true,B);G.action=A;G.elements._Level.value=D;G.elements["_"+G.elements._ClassId.value+".Method"].value=C;return false}function FormCancel(B,A){B=$(B);if(confirm("As alterações no registro serão perdidas. Deseja mesmo continuar?")){if(A){window.open(A,"_self")}else{if(B.Method()=="Update"){B.field("_XMethod").value="Unlock";B.field("_NextMethod").value="";B.Method("Select");B.submit()}else{window.open(document.location.pathname+"?"+$H({_ClassId:B.ClassId(),_Level:B.Level()}).toQueryString(),"_self")}}}return false}function ri(D,F){var G=findParentElement(D,"FORM"),B,C,E,A;G=document.forms[G.getAttribute("PForm")];B=D.nodeName=="TR"?D:findParentElement(D,"TR");C=(new String(B.getAttribute("key"))).toQueryParams();E={};for(A in C){E[G.elements._ClassId.value+"."+A]=C[A]}E["_"+G.elements._ClassId.value+".Method"]=F?F:"Select";setValue(G.name,E,true)}window.rowInstance=ri;function pmeCheck(B){var A=document.forms[B].elements;if(!A["_"+A._ClassId.value+".MSelect"]||!isChecked(A["_"+A._ClassId.value+".MSelect"])){alert("Escolha um ou mais registros para poder executar a operação!");return false}return true}function pme(B,E,D,C,A){return popupMultiExecute(B,E,D,C,A)}function popupMultiExecute(L,C,M,G,J){var I=document.forms[L],F=document.forms[L.replace(/^P/,"")]||I,E=I.elements,D=E._ClassId.value,B=I.action,N=E._Level.value,K=E["_"+D+".Method"].value,A=E._History.value,H;if(M){if(isChecked(E["_"+D+".MSelect"])){slaveCheck(E["_"+D+".MSelect"],"_"+D+".MSelect",0)}if(M&&new String(M).match(/=/)){E["_"+D+".XMethod"].value=M}else{E["_"+D+".XMethod"].value=F.getAttribute("Selected")}}else{if(!pmeCheck(L)){return false}}I.action="/Ultra/"+getSession()+"/Class.cgi";E._Level.value=0;E["_"+D+".Method"].value="MultiExecute";E["_"+D+".XForeignKeyId"].value=C;E._History.value=D+":MultiExecute";if(G){new Ultra.Class(D).MultiExecute(FormToHash(I),{onSuccess:(J?J:function(){if(this.ErrorStatus2&&this.ErrorStatus2.MultiInsert){alert(this.ErrorStatus2.MultiInsert)}else{alert("OK!")}})})}else{H="popupMultiInsert_"+getSession().replace(/\W/g,"_");window.open("",H,"toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width=640,height=480");I.target=H;I.submit()}I.action=B;E._Level.value=N;E["_"+D+".Method"].value=K;E._History.value=A;E["_"+D+".XMethod"].value="";I.target=null;return false}function showBrowseFormField(B,C,H,L,N){var I=$(B).up("form"),G=I.field(C),D=I.elements,O=D._Level.value,A=D._ClassId.value,F=D._ParentFormId.value,K=D["_"+D._ClassId.value+".Method"].value,J=D._ParentFieldId.value,E,M;if(!N){N=$(G).up("td")}if(L!=undefined){for(E=0;E<L.length;E++){if(D[L[E]]&&D[L[E]].tagName=="INPUT"){D[L[E]].oncontextmenu();return false}}}if(K=="BrowseCombo"||K=="AjaxBrowseCombo"){D._ClassId.value=D._ParentClassId.value}M=D["_"+D._ClassId.value+".Method"].value;I.target=I.name;D["_"+D._ClassId.value+".Method"].value="AjaxBrowseFormField";D._ParentFormId.value=I.name;D._ParentFieldId.value=C;D._BrowseFormFieldType.value=H;requestURL("POST","Class.cgi",I,N,0);D._Level.value=O;D["_"+D._ClassId.value+".Method"].value=M;D._ClassId.value=A;D["_"+D._ClassId.value+".Method"].value=K;D._ParentFormId.value=F;D._ParentFieldId.value=J;I.target="";return false}function showBrowseFormOptions(D,C,B){var A=D.elements["_"+D.elements._ClassId.value+".Method"].value;D.elements["_"+D.elements._ClassId.value+".Method"].value="AjaxBrowseFormOptions";requestURL("POST","Class.cgi",D,C,B);D.elements["_"+D.elements._ClassId.value+".Method"].value=A}function showSlaveChildForm(J,C,F,D,B,E,A){var H=document.forms[J],I=H.elements["_"+C+".Method"].value,G=H.elements["_"+C+".ParentMethod"].value;H.elements["_"+C+".Method"].value="AjaxSlaveChild";H.elements["_"+C+".ParentMethod"].value=E?E:D;H.elements["_"+C+".SlaveClassId"].value=F;requestURL("POST","Class.cgi",H,B,A!=0?1:0);H.elements["_"+C+".Method"].value=I;H.elements["_"+C+".ParentMethod"].value=G}function ShowBrowseAddFields(D,A){var E=document.forms[D],C=E.elements._ClassId.value,B=E.elements["_"+A+".Method"].value;E.elements._ClassId.value=A;E.elements["_"+A+".Method"].value="AjaxBrowseAddFields";requestURL("POST","Class.cgi",E,document.getElementById(D+".AddFields"),1);E.elements._ClassId.value=C;E.elements["_"+A+".Method"].value=B}function doAjaxInputEvent(M,E,D,H,A,G,B){var J=document.forms[M],L=J.elements._ClassId.value,K=J.elements["_"+J.elements._ClassId.value+".Method"].value,I=J.elements._ParentClassId.value,C=J.elements._ParentFieldId.value,F;J.elements._ClassId.value=E;J.elements["_"+J.elements._ClassId.value+".Method"].value="AjaxInputEvent";J.elements._ParentClassId.value=E;J.elements._ParentFieldId.value=D;if(J.elements._ParentFieldIdIndex){if(J.elements[H.name]!=undefined&&J.elements[H.name].length){for(F=0;F<J.elements[H.name].length;F++){if(H==J.elements[H.name].item(F)){J.elements._ParentFieldIdIndex.value=F}}}else{J.elements._ParentFieldIdIndex.value=""}}if(A.length){A=A[J.elements._ParentFieldIdIndex.value||0]}if(G!=undefined){setValue(M,G,false)}if(!B){requestURL("POST",document.location.pathname,J,A,0)}else{requestURLeval("POST",document.location.pathname,J,A)}J.elements._ClassId.value=L;J.elements["_"+J.elements._ClassId.value+".Method"].value=K;J.elements._ParentClassId.value=I;J.elements._ParentFieldId.value=C}var controleTimeout,block=1,inputlastvalue="",changeInput;function AjaxFloatCombo(C,U){var W,H,F,D,V;var R,I,P=0;var B=$(C).form;var K=C.index();var M=-1;var S=B.Method();var Q,G;var S,A,J,N;var L;CriaSearchBox(B);if(typeof B.elements[C.name.substr(0,(C.name.length-2))][K]!="undefined"&&typeof B.elements[C.name.substr(0,(C.name.length-2))][K]!="unknown"){V=B.elements[C.name.substr(0,(C.name.length-2))][K]}else{V=B.elements[C.name.substr(0,(C.name.length-2))]}I=V.selectedIndex;if(U&&typeof U.type!="unknown"){if(U.type=="blur"){if(I>=0){SetInputValue(C,K,V.options[I].text)}window.setTimeout(function(){$("searchbox").style.display="none"},100);return false}if(U.keyCode){D=U.keyCode}else{if(U.which){D=evt.which}}if(D==9){if(I>=0){SetInputValue(C,K,V.options[I].text)}window.setTimeout(function(){$("searchbox").style.display="none"},100);return false}else{Q=String.fromCharCode(D)}if(D==27){if(I>=0){SetInputValue(C,K,V.options[I].text)}window.setTimeout(function(){$("searchbox").style.display="none"},100);return false}if(D==40||D==38){var O=$("searchbox").down().childElements();if($("searchbox").style.display=="none"){$("searchbox").style.display="block";P=1}for(R=0;R<O.length;R++){if(O[R].hasClassName("sva")){M=R;O[R].removeClassName("sva")}}M=M+(D==40?1:-1);if(typeof O[M]=="undefined"||O[M].hasClassName("spanvalueclose")||P==1||typeof O[M+1]=="undefined"){M=0}O[M].addClassName("sva");return false}if(D==13){Event.stop(U);clearTimeout(controleTimeout);if($("searchbox").style.display=="none"){AjaxFloatComboDirect(C,U);return false}var O=$("searchbox").down().childElements();if(O.length>1){for(R=0;R<O.length;R++){if(O[R].hasClassName("sva")){M=R}}O[M].onclick()}return false}if(D==37||D==39||D==16||D==17||D==18||D==35||D==36||D==61||D==59){clearTimeout(controleTimeout);return false}}G=C.value;if(block==1){clearTimeout(controleTimeout);controleTimeout=setTimeout(function(){block=0;AjaxFloatCombo(C,U)},800)}if(G!=""&&block==0&&G!=inputlastvalue){clearTimeout(controleTimeout);block=1;inputlastvalue=G;W=plune_positionedOffset(C);$("searchbox").style.left=W[0]+"px";$("searchbox").style.top=(W[1]+23)+"px";L=C.getAttribute("ClassId");var E=B.elements;A=E["_"+L+".Method"].value;J=E._ClassId.value;S=E["_"+J+".Method"].value;N=E._ParentClassId.value;B.Method("AjaxFloatCombo");try{B.field("_ComboFieldId").value=C.getAttribute("FieldId")}catch(T){}E["_"+L+".ComboFieldId"].value=C.getAttribute("FieldId");E["_"+L+".Method"].value="AjaxFloatCombo";E._ClassId.value=L;E._ParentClassId.value=L;E._ParentFieldId.value=C.getAttribute("FieldId");E._SubMethod.value=G;E._ParentFieldIdIndex.value=(K==-1?"":K);submitTo(B,$("searchbox"));$("searchbox").style.display="block";E["_"+J+".Method"].value=S;try{B.field("_ComboFieldId").value=""}catch(T){}E["_"+L+".ComboFieldId"].value="";E["_"+L+".Method"].value=A;E._ClassId.value=J;E._ParentClassId.value=N;E._ParentFieldId.value="";E._SubMethod.value="";E._ParentFieldIdIndex.value="";return true}else{if(G!=inputlastvalue){block=1;window.setTimeout(function(){$("searchbox").style.display="none"},100);return false}}}function AjaxFloatComboDirect(E,L){var B,H,A,I,D,F;var N,C,M,K;clearTimeout(changeInput);B=$(E).up("span").down("input");if(B.value!=""){I=B.index();D=$(B).form;H=plune_positionedOffset(B);$("searchbox").style.left=H[0]+"px";$("searchbox").style.top=(H[1]+23)+"px";F=B.getAttribute("ClassId");var G=D.elements;C=G["_"+F+".Method"].value;M=G._ClassId.value;N=G["_"+M+".Method"].value;K=G._ParentClassId.value;D.Method("AjaxFloatCombo");try{D.field("_ComboFieldId").value=B.getAttribute("FieldId")}catch(J){}G["_"+F+".ComboFieldId"].value=B.getAttribute("FieldId");G["_"+F+".Method"].value="AjaxFloatCombo";G._ClassId.value=F;G._ParentClassId.value=F;G._ParentFieldId.value=B.getAttribute("FieldId");G._SubMethod.value=B.value;G._ParentFieldIdIndex.value=(I==-1?"":I);submitTo(D,$("searchbox"));$("searchbox").style.display="block";G["_"+M+".Method"].value=N;try{D.field("_ComboFieldId").value=""}catch(J){}G["_"+F+".ComboFieldId"].value="";G["_"+F+".Method"].value=C;G._ClassId.value=M;G._ParentClassId.value=K;G._ParentFieldId.value="";G._SubMethod.value="";G._ParentFieldIdIndex.value=""}}Element.plune_returnOffset=function(A,B){var C=[A,B];C.left=A;C.top=B;return C};function plune_positionedOffset(A){var B=0,C=0;do{B+=A.offsetTop||0;C+=A.offsetLeft||0;A=A.offsetParent;if(A){if(A.tagName.toUpperCase()=="BODY"){break}}}while(A);return Element.plune_returnOffset(C,B)}function SetInputValue(B,A,C){if(C==""||C=="* Selecione"||C=="* Indefinido"){C="Digite...";$(B).value=C;$(B).style.color="#777"}else{$(B).style.color="#000";if($(B).value!=C){$(B).focus()}$(B).value=C}}function ChangeValueField(E,C,H,D,F){var B=$(C).form;var I,A;SearchsetOption(C,D,E.innerHTML);try{C.onchange()}catch(G){}A=B.elements[C.name+".x"];SetInputValue(A,F,E.innerHTML);$("searchbox").style.display="none"}function SSV(B,A,F,E,D,C){SetSpanValue(B,A,F,E,D,C)}function SetSpanValue(H,C,G,D,E,I){clearTimeout(changeInput);window.setTimeout(function(){clearTimeout(changeInput)},100);var B=document.forms[I];var A,F;E=(E==""?-1:E);if(typeof B.elements[C][E]!="undefined"&&typeof B.elements[C][E]!="unknown"){F=B.elements[C][E]}else{F=B.elements[C]}SearchsetOption(F,D,H.innerHTML);F.callEvent("change");if(typeof B.elements[C+".x"][E]!="undefined"&&typeof B.elements[C+".x"][E]!="unknown"){A=B.elements[C+".x"][E]}else{A=B.elements[C+".x"]}SetInputValue(A,E,H.innerHTML);$("searchbox").style.display="none";inputlastvalue=""}function OcultaDiv(B,D){var C=$(B).form;CriaSearchBox(C);var A=B.index();var F;if(typeof C.elements[B.name.substr(0,(B.name.length-2))][A]!="undefined"&&typeof C.elements[B.name.substr(0,(B.name.length-2))][A]!="unknown"){F=C.elements[B.name.substr(0,(B.name.length-2))][A]}else{F=C.elements[B.name.substr(0,(B.name.length-2))]}var E=F.selectedIndex;if(E>=0){clearTimeout(changeInput);changeInput=setTimeout(function(){if($(B).value==""){SetInputValue($(B),A,"");SearchsetOption(F,"","")}else{if(isNaN(F.options[E].text)){SetInputValue($(B),A,F.options[E].text)}}$("searchbox").style.display="none"},200)}else{window.setTimeout(function(){$("searchbox").style.display="none"},100)}}function OnChangeSel(B,E){var D=Event.element(E);var C=$(D).form;var A=D.index();var G=D.selectedIndex;var F;if(typeof C.elements[D.name+".x"][A]!="undefined"&&typeof C.elements[D.name+".x"][A]!="unknown"){F=C.elements[D.name+".x"][A]}else{F=C.elements[D.name+".x"]}if(G>=0){SetInputValue(F,A,D.options[G].text)}}function SearchsetOption(F,B,D){if(B==null){B=""}var C=$(F),E=false,A;C.value=B;if(C.value!=B){A=document.createElement("option");A.text=D;A.value=B;C.options.add(A);A.selected=true;E=true}return E}function CriaSearchBox(A){if(!$("searchbox")){var B=document.createElement("div");B.setAttribute("id","searchbox");B.setAttribute("name","searchbox");$(A).appendChild(B);B.className="searchbox"}}var lboxauto;function lbox(K,F){var C,J,B,D;if(!F){F={}}if(K==""){alert("Html está nulo");return false}if(!$("divfloat")){var A=document.createElement("div");A.setAttribute("id","divfloat");A.setAttribute("name","divfloat");A.setAttribute("onclick","lbox('fecha', '')");document.body.appendChild(A);A.className="divfloat";A.style.display="none";var E=document.createElement("div");E.setAttribute("id","divfloat2");E.setAttribute("name","divfloat2");document.body.appendChild(E);E.className="divfloat2";E.style.display="none"}if(K!="fecha"){C='<div style="margin:0px 8px 8px 8px;"><div style="position:relative;top:-8px;left:8px;display:block; text-align:right; margin-bottom:0px"><a onclick="lbox(\'fecha\',\'\')"><img src="/t/c/img/action/Close.png"></a></div>'+K+"</div>";$("divfloat2").innerHTML=C;var L=parseInt(document.body.scrollTop);var H=parseInt(document.body.clientHeight);if(document.documentElement&&!document.documentElement.scrollTop){L=(document.documentElement.clientHeight/2)-$("divfloat2").getHeight()/2;D=document.documentElement.clientHeight}else{if(document.documentElement&&document.documentElement.scrollTop){L=((document.documentElement.clientHeight/2)+document.documentElement.scrollTop)-$("divfloat2").getHeight()/2;D=document.documentElement.clientHeight+document.documentElement.scrollTop}else{if(document.body&&document.body.scrollTop){L=(document.body.scrollTop+(document.body.clientHeight/2))-$("divfloat2").getHeight();D=document.body.scrollTop+document.body.clientHeight}}}if(L<0){L=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;if(typeof F.height!="undefined"&&typeof F.height!="unknow"){$("divfloat").style.height=F.height+"px"}else{D=D+$("divfloat2").getHeight();if(D>(document.height?document.height:document.body.scrollHeight)){$("divfloat").style.height=D+"px"}else{$("divfloat").style.height=(document.height?document.height:document.body.scrollHeight)+"px"}}}else{if(typeof F.height!="undefined"&&typeof F.height!="unknow"){$("divfloat").style.height=F.height+"px"}else{if(D>(document.height?document.height:document.body.scrollHeight)){$("divfloat").style.height=D+"px"}else{$("divfloat").style.height=(document.height?document.height:document.body.scrollHeight)+"px"}}}$("divfloat2").style.top=(L+30)+"px";var I=parseInt(document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth);B=(I/2)-(($("divfloat2").getWidth())/2);$("divfloat2").style.left=B+"px";Effect.toggle($("divfloat"),"appear",{to:0.45,duration:0.5});Effect.toggle($("divfloat2"),"appear",{duration:0.5})}else{if(F.agora){$("divfloat").style.display="none";$("divfloat2").style.display="none"}else{Effect.toggle($("divfloat"),"appear",{duration:0.5});Effect.toggle($("divfloat2"),"appear",{duration:0.5});clearTimeout(lboxauto)}try{F.unset("autoclose")}catch(G){}return true}if(F.autoclose){lboxauto=setTimeout(function(){Effect.toggle($("divfloat"),"appear",{duration:1});Effect.toggle($("divfloat2"),"appear",{duration:1})},F.autoclose>1?F.autoclose:1500)}}function popupBrowseCombo(O,K,F,E,H,A){var G=K.elements;var C=G[F+"."+E],I,D,B,N;if(C.length){for(I=0;I<C.length;I++){C[I].setAttribute("ActiveCombo",null)}if(A.type=="select-one"&&A.name==F+"."+E){D=A}else{B=findParentElement(A,"TD").getElementsByTagName("select");for(I=0;I<B.length;I++){if(B[I].name==F+"."+E){D=B[I]}}if(!D){alert("Impossível descobrir qual o elemento SELECT de destino da consulta! Abortando...");return }}B=(findParentElement(A,"TABLE","isArray","1")||findParentElement(A,"TABLE")).getElementsByTagName("select");if(B.length<G[F+"."+E].length){B=G[F+"."+E]}N=0;for(I=0;I<B.length;I++){if(B[I].name==F+"."+E){if(D==B[I]){G._ParentFieldIdIndex.value=N;B[I].setAttribute("ActiveCombo",1)}N++}}}oldAction=K.action;oldClassId=G._ClassId.value;oldLevel=G._Level.value;oldMethod=G["_"+F+".Method"].value;oldParentFormId=G._ParentFormId.value;oldParentClassId=G._ParentClassId.value;oldParentFieldId=G._ParentFieldId.value;oldForeignFieldId=G._ForeignFieldId.value;try{oldNextMethod=G["_"+oldClassId+".NextMethod"].value}catch(L){}var M;var J;try{M=parseInt(screen.width*0.7)}catch(L){}try{J=parseInt(screen.height*0.4)}catch(L){}if(!M){M=680}if(!J){J=340}window.open("",O,"width="+M+",height="+J+",scrollbars=yes,menubar=no,status=no,toolbar=no,titlebar=no,resizable=yes,location=no");K.target=O;K.action="/Ultra/"+getSession()+"/Class.cgi";G._ClassId.value=F;G._Level.value=0;G["_"+F+".Method"].value="BrowseCombo";try{G["_"+oldClassId+".NextMethod"].value=""}catch(L){}G["_"+F+".ComboFieldId"].value=E;G._ParentFormId.value=K.name;G._ParentClassId.value=F;G._ParentFieldId.value=E;G._ForeignFieldId.value=H;K.submit();G._ForeignFieldId.value=oldForeignFieldId;G._ParentFieldId.value=oldParentFieldId;G._ParentClassId.value=oldParentClassId;G._ParentFormId.value=oldParentFormId;K.target="_self";G["_"+F+".Method"].value=oldMethod;try{G["_"+oldClassId+".NextMethod"].value=oldNextMethod}catch(L){}K.action=oldAction;G._ClassId.value=oldClassId;G._Level.value=oldLevel;G._ParentFieldIdIndex.value=""}function ubbe(B,F,G,D,E,C,A,I){var H=$(B);if(F){H.setAttribute("browseUpdateId",setTimeout(function(){ubbex(B,F,G,D,E,C,A,I)},F))}else{ubbex(B,F,G,D,E,C,A,I)}}function ubbex(el,delay,data,extra,ClassId,FieldId,brefresh,cancelev){var _this=$(el);var thisform=Element.extend(_this.form),td=_this.up("td")||_this.up("div");if(td.up("table.BrowseArray")){td=td.up("table.BrowseArray").up("td")}if(!td){return false}var tr=td.up("tr[key]")||_this.up("div[key]"),editspan=td.down(".bu-e"),viewspan=td.down(".bu-v");if(editspan.getAttribute("sent")){return false}function onAfterAll(){editspan.update("").removeAttribute("sent");_this.removeAttribute("onblur");viewspan.show()}if(_this.value!=data&&!cancelev){var params=tr.readAttribute("key").toQueryParams();params[_this.FieldId()]=_this.allValues(editspan);if(extra){eval(extra)}new Ultra.Class(ClassId).Update(params,{onSuccess:function(){var value=this.Field[FieldId].resolved;viewspan.fieldValue=this.Field[FieldId].value;if(viewspan.fieldValue!=null){viewspan.update(value!=null&&!String(value).empty()?value:viewspan.fieldValue).removeAttribute("isNull")}else{if(value!=null){viewspan.update(value)}viewspan.setAttribute("isNull","1")}if((value==null||String(value).empty())&&(viewspan.fieldValue==null||String(viewspan.fieldValue).empty())){viewspan.update("<nobr><i>* Indefinido</i></nobr>")}if(brefresh){try{thisform.elements["_"+ClassId+".Submit"].click()}catch(e){}}},onAfterAll:onAfterAll});editspan.setAttribute("sent","1");editspan.update("<img src=/t/default/img/loading.gif />")}else{onAfterAll()}_this.removeAttribute("browseUpdateId")}function ubb(D,C,B,A){updateByBrowse(D,C,B,A)}function updateByBrowse(F,I,E,H){if(H){Event.stop(H)}$(F).hide();var K=F.up("tr[key]")||F.up("div[key]"),A=K.getForm(),G=A.ClassId(),B=F.readAttribute("isNull")?"":[F.fieldValue,E,""].find(function(L){return L!=null}),D={_ClassId:G,_ParentClassId:G,_ParentFieldId:I,_Level:A.Level()},C,J;if(E!=null){D._data=B}J=K.readAttribute("key").toQueryParams();for(C in J){D[G+"."+C]=J[C]}D["_"+G+".Method"]="AjaxInputEvent";D["_"+G+".FormId"]=[A.name,A.name];requestURL("POST",document.location.pathname,D,F.previous("span"))}function ubm(D,C,B,A){updateByModal(D,C,B,A)}function updateByModal(D,C,B,A){if(!D.down("span.bu-v")){D.innerHTML="<span><span class='bu-e div__helper2'></span><span class=bu-v>"+D.innerHTML+"</span></span>"}else{D.innerHTML="<span><span class='bu-e div__helper2'></span><span class=bu-v>"+D.down("span.bu-v").innerHTML+"</span></span>"}ubb($(D).down("span.bu-v"),C,B,A)}function FormComboReload(FormId,ClassId,FieldId,thisCombo){var myform=document.forms[FormId];if(typeof myform=="undefined"){myform=$(thisCombo).up("form")}var els=myform.elements,old_ClassId=els._ClassId.value,old_Level=els._Level.value,old_method=els["_"+ClassId+".Method"].value,combo=els[ClassId+"."+FieldId],comboIndex,i,inputs,ii,el,req;if(combo.length){for(i=0;i<combo.length;i++){combo[i].setAttribute("ActiveCombo",null)}inputs=(findParentElement(thisCombo,"TABLE","isArray","1")||findParentElement(thisCombo,"TABLE")).getElementsByTagName("select");ii=0;for(i=0;i<inputs.length;i++){if((inputs[i].name==ClassId+"."+FieldId)&&(inputs[i]==thisCombo)){try{inputs[i].setAttribute("ActiveCombo",1);els._ParentFieldIdIndex.value=ii;comboIndex=ii;combo=inputs[i]}catch(e){}}if(inputs[i].name==ClassId+"."+FieldId){ii++}}}els._ClassId.value=ClassId;els._Level.value=0;try{els["_"+ClassId+".OK"].value="Fake"}catch(e){}try{els["_"+ClassId+".ReloadFieldId"].value=FieldId}catch(e){}els["_"+ClassId+".Method"].value="AjaxCombo";req=new AJAX(POST,"/Ultra/"+getSession()+"/Class.cgi",myform);req.events.success=function(res){res=eval(res);var Combo,vCombo,tab,AllCombos,inputs,i,ii,iii,Option,k,tr,td,chk,td2,lastVal;for(i=0;i<res.length;i+=2){Combo=els[res[i]],vCombo=els["_v."+res[i]];if(!Combo){}else{if(Combo.type=="select-one"||Combo.type=="checkbox"||Combo.length){if(Combo.type!="select-one"&&Combo.length&&els[ClassId+"."+FieldId].type!="select-one"&&els[ClassId+"."+FieldId].length){inputs=(findParentElement((Combo.length?Combo[0]:Combo),"TABLE","isArray","1")||findParentElement((Combo.length?Combo[0]:Combo),"TABLE")).getElementsByTagName("select");iii=0;for(ii=0;ii<inputs.length;ii++){if(inputs[ii].name==res[i]){if(iii==comboIndex){Combo=inputs[ii]}iii++}}AllCombos=[Combo]}else{if((Combo.type=="checkbox"||Combo[0].type=="checkbox")){tab=findParentElement((Combo.length?Combo[0]:Combo),"TR").parentNode;for(iii=1;tab.childNodes.length>0;iii++){tab.removeChild(tab.lastChild)}AllCombos=[null]}else{if(Combo.type!="select-one"&&Combo.length){AllCombos=Combo.length&&Combo[0].type=="select-one"?Combo:[Combo[Combo]]}else{AllCombos=Combo.length&&Combo[0].type=="select-one"?Combo:[Combo]}}}for(iii=0;iii<AllCombos.length;iii++){Combo=AllCombos[iii];if(Combo&&Combo.disabled&&!Combo.getAttribute("ActiveCombo")){continue}if(Combo&&Combo.type=="select-one"){Combo.options.length=0}for(ii=2;ii<res[i+1].length;ii+=2){if(Combo&&Combo.type=="select-one"){Option=document.createElement("option");(function(opt){if(typeof opt=="string"){Option.value=opt}else{for(k in opt){Option.setAttribute(k,opt[k])}}})(res[i+1][ii]);Option.text=res[i+1][ii+1];Combo.options.add(Option)}else{if(res[i+1][ii]!=""||res[i+1].length==4){tr=tab.insertRow(-1);td=tr.insertCell(-1);chk=document.createElement("input");chk.type="checkbox";(function(opt){if(typeof opt=="string"){chk.value=opt}else{for(k in opt){chk.setAttribute(k,opt[k])}}})(res[i+1][ii]);chk.name=res[i];td.appendChild(chk);td2=tr.insertCell(-1);td2.innerHTML="<img src='"+findParentElement(tab,"TABLE").getAttribute("ClassImg")+"' align=absmiddle> "+res[i+1][ii+1]}else{continue}}}}lastVal=Combo?Combo.value:null;if(Combo&&Combo.type=="select-one"&&res[i+1][0]!=null&&Combo.value!=res[i+1][0]&&true){Combo.value=res[i+1][0]}if(Combo&&Combo.type=="select-one"&&Combo.value==""){Combo.value=lastVal}}else{if(Combo&&Combo.type=="text"){Combo.value=res[i+1][0]}}}if(Combo&&vCombo&&vCombo.type=="text"){vCombo.value=Combo.value}}combo.disabled=false;if(el){if(el.oldSrc!=null){el.src=el.oldSrc}else{el.style.display="none"}}};req.request();els._ClassId.value=old_ClassId;els._Level.value=old_Level;try{els["_"+ClassId+".OK"].value="1"}catch(e){}try{els["_"+ClassId+".ReloadFieldId"].value=""}catch(e){}els["_"+ClassId+".Method"].value=old_method;try{els._ParentFieldIdIndex.value=""}catch(e){}if(combo.nextSibling!=null&&combo.nextSibling.tagName=="IMG"){el=combo.nextSibling;el.oldSrc=el.src}else{el=document.createElement("IMG");combo.parentNode.appendChild(el)}el.border=0;el.src="/t/default/img/loading.gif"}function addSelectOptions(D,C){var B,A;for(B=0;B<C.length;B++){A=document.createElement("option");A.value=C[B][0];A.text=C[B][1];D.options.add(A)}}function submitForm(A,J){A=$(A);rollbackSubmitDisabled(A);if(!J){J=A.getAttribute("loadingImgId")}var E=A.elements._ClassId.value,B,G,K;var I=A.getAttribute("SIID");if(I&&A.getAttribute("SINext")&&getSINextLayerUnseenIndex(I)&&getSI(I,getSINextLayerUnseenIndex(I)).getAttribute("readonly")!="1"&&confirm("Gostaria de preencher também os dados de ["+new String(getSIb(I,getSINextLayerUnseenIndex(I)).innerHTML+" ").stripTags()+"]?")==true&&SuperInterfaceShowNext(I)){return false}if(["Insert","Update"].include(A.elements["_"+E+".Method"].value)){B=checkForm(A)}if(B!=false){G=$(J).show();submitBtn=A.elements["_"+E+".Submit"];K=submitBtn.value;submitBtn.disabled=true;submitBtn.value="Aguarde...";var H=A.elements["_"+E+".Submit2"];if(H&&!H.length){H=new Array(H)}var D=new Array();var C=new Array();for(var F=0;H&&F<H.length;F++){C.push($(H[F].nextSibling));D.push(H[F].value);$(H[F].nextSibling).show();H[F].value="Aguarde..."}$A(A.elements).any(function(L){if(L.getAttribute("submitDisabled")&&L.disabled==true){L.disabled=false;L.setAttribute("wasDisabled",1)}});if(A.Method()=="Update"&&(A.field("_submitByAjax")||(A.field("_NextMethod").value=="submitByAjax"))){A.save({keepSession:true,onSuccess:function(){lbox("<img src='/t/c/img/action/OK.gif' class=ico> Operação realizada com sucesso!",{autoclose:1})},onAfterAll:function(){submitBtn.disabled=false;submitBtn.value=K;G.hide();for(var L=0;H&&L<H.length;L++){if(C[L]){C[L].hide()}if(H[L]){H[L].value=D[L]}}}});rollbackSubmitDisabled(A);return false}}return B!=false}function rollbackSubmitDisabled(A){$A(A.elements).any(function(B){if(B.getAttribute("wasDisabled")&&B.disabled==false){B.disabled=true;B.removeAttribute("wasDisabled")}})}function appendLoadingImg(B){var A=document.createElement("IMG");A.border=0;A.src="/t/default/img/loading.gif";B.parentNode.appendChild(A);if(B.type=="submit"){B.value="Aguarde..."}return A}function requestURLeval(meth,myURL,params,el){if(el){el.innerHTML=el.clientWidth>200?"<p class=loading><img src=/t/default/img/loading.gif border=0> Carregando...</p>":"<b class=loading_small><img src=/t/default/img/loading.gif border=0></b>"}var req=new AJAX(meth,myURL,params),oldHTML;req.events.success=function(res){res=eval(res);if(el){el.innerHTML=""}};if(el){oldHTML=el.innerHTML;req.events.complete=function(){el.innerHTML=oldHTML}}req.request()}var UltraAJAXCache;function initUltraCache(A){try{if(parent&&document!=parent.document){if(A||parent.Ultra.AJAXCache==undefined){parent.Ultra.AJAXCache=new Hash()}UltraAJAXCache=parent.Ultra.AJAXCache}else{if(opener&&opener.opener&&opener.opener.parent){if(A||opener.opener.parent.Ultra.AJAXCache==undefined){opener.opener.parent.Ultra.AJAXCache=new Hash()}UltraAJAXCache=opener.opener.parent.Ultra.AJAXCache}else{if(opener&&opener.parent){if(A||opener.parent.Ultra.AJAXCache==undefined){opener.parent.Ultra.AJAXCache=new Hash()}UltraAJAXCache=opener.parent.Ultra.AJAXCache}else{if(A||window.Ultra.AJAXCache==undefined){window.Ultra.AJAXCache=new Hash()}UltraAJAXCache=window.Ultra.AJAXCache}}}}catch(B){}}initUltraCache();function getUltraCache(A){return A?UltraAJAXCache[A]:UltraAJAXCache}function setUltraCache(A,B){UltraAJAXCache[A]=B}function resetUltraCache(){initUltraCache(true)}function requestURL(J,H,E,B,A,M,C){if(M==undefined){M=DEFAULT_TIMEOUT}var D=B.id+"@"+H,G,K,I,F,L;if(B.nodeName=="TR"&&B.childNodes.length==1){B=B.childNodes[0]}if(A==1&&requestURLdone.include(D)&&B.innerHTML.length!=0){return }else{if(A==2){if(getUltraCache(J+"$"+H+"?"+E)!=null){Element.update(B,getUltraCache(J+"$"+H+"?"+E));return }}else{}}G=requestURLdone.length-1;B.lastRequest=H;K=new AJAX(J,H,E);I=String(B.innerHTML);F=false;if(M!==false){L=setTimeout(function(){F=true;alert("Requisição foi cancelada porque atingiu o tempo limite("+(M/1000)+" segundos). Por favor, Tente novamente.");Element.update(B,I)},M)}K.events.success=function(O){clearTimeout(L);if(F){return }try{if(A==2){setUltraCache(J+"$"+H+"?"+E,O)}Element.update(B,O);requestURLdone.push(D)}catch(Q){alert("Não pode atualizar elemento "+B.nodeName+": "+Q.description+" - O HTML pode estar desconforme?");if(DEBUG_MODE){if(!moz){if(confirm(Q.description+"\n\nDeseja ver o conteúdo da resposta?")){var P=open(),N=P.document.createElement("textarea");N.value=O;N.style.width="100%";N.style.height="100%";P.document.body.appendChild(N)}}}}};I=String(B.innerHTML);K.events.error=function(N){try{clearTimeout(L);AJAX.events.error(N);Element.update(B,I)}catch(O){}};if(C){K.events.fail=new Function}K.events.loading=function(Q,O){AJAX.events.loading(Q,O);var R=B,P,N;if(R.innerHTML.length>100&&(R.clientWidth<=200||R.clientHeight<=70)){for(P=0;P<B.childNodes.length;P++){if(B.childNodes[P]&&(B.childNodes[P].nodeType==1&&B.childNodes[P].style.position=="absolute")&&(B.childNodes[P].clientWidth>B.clientWidth||B.childNodes[P].clientHeight>B.clientHeight)){R=B.childNodes[P]}}}if(R.nodeName=="TR"||(R.innerHTML.length>100&&R.clientWidth>200&&R.clientHeight>50)){N=document.createElement("div");N.style.position="absolute";if(R.style.position=="absolute"){N.style.top=R.style.top;N.style.left=R.style.left}N.style.width=R.clientWidth+"px";N.style.height=R.clientHeight+"px";N.style.background="url( /t/default/img/loading_bg.gif )";N.style.zIndex=1000;N.innerHTML="<table width='100%' height='100%' border=0><tr><td valign=middle align=center><p class='loading_inside'><img src=/t/default/img/loading.gif border=0> Carregando...</p></td></tr></table>";B.insertBefore(N,B.firstChild)}else{if(R.clientWidth>200&&R.clientHeight>50){R.innerHTML="<p class=loading><img src=/t/default/img/loading.gif border=0 align=absmiddle> Carregando...</p>"}else{R.innerHTML="<img aclass=loading_small src=/t/default/img/loading.gif border=0 align=absmiddle alt=loading>"}}};K.request()}function BrowseFormOrderChange(A,B){var C=document.forms[A];if(C.elements["_"+C.elements._ClassId.value+".OrderDesc"].value==1){C.elements["_"+C.elements._ClassId.value+".OrderDesc"].value=0;B.src="/t/default/img/OrderDesc.gif"}else{C.elements["_"+C.elements._ClassId.value+".OrderDesc"].value=1;B.src="/t/default/img/Order.gif"}}function slaveCheck(B,C,D){if(B.item){B=B[0]}var E=B.form,A;if(D==undefined){D=B.checked}for(A=0;A<E.elements.length;A++){if(E.elements[A].name==C){E.elements[A].checked=D;var F=$(E.elements[A]).previous();if(F&&F.src.match(/(shown|hidden)\.png/)){F.src=F.src.replace(/(shown|hidden)\.png/,D?"shown.png":"hidden.png")}}}}function bms(D,A){var B=$(D).up("form").field(A);var C=countChecked(B.form.elements[D.name]);if(C==0){B.disabled=false;B.value=""}else{B.disabled=true;if(C==1){B.value="1 Selecionado"}else{B.value=C+" Selecionados"}}}function countChecked(B){var C=0;if(B!=undefined){if(B.nodeName=="INPUT"){if(B.checked){C=1}else{C=0}}else{try{for(var A=0;A<B.length;A++){if(B[A].checked){C++}}}catch(D){}}}return C}function uncheckAll(B){if(B!=undefined){if(B.nodeName=="INPUT"){B.checked=false}else{for(var A=0;A<B.length;A++){B[A].checked=false}}}}function isChecked(B){if(B!=undefined){if(B.nodeName=="INPUT"){return B.checked}else{try{for(var A=0;A<B.length;A++){if(B[A].checked){return true}}}catch(C){}}}return false}function uncheck(B){for(var A=0;A<B.elements.length;A++){if(B.elements[A].name=="_"+B.elements._ClassId.value+".GroupBy"){B.elements[A].checked=false}}}function createInputs(Field,pattern,mask){Field.style.display="none";pattern=pattern||"%d/%m/%Y";mask=mask||"99/99/9999";var Cell=Field.parentNode,DataInicio=document.createElement("input"),DataFim=document.createElement("input"),NOBRDe=document.createElement("nobr"),NOBRAte=document.createElement("nobr"),ImgCalendarDe=document.createElement("img"),ImgCalendarAte=document.createElement("img");Cell.appendChild(NOBRDe);NOBRDe.appendChild(document.createTextNode("De: "));NOBRDe.appendChild(DataInicio);NOBRDe.appendChild(ImgCalendarDe);Cell.appendChild(NOBRAte);NOBRAte.appendChild(document.createTextNode(" Até: "));NOBRAte.appendChild(DataFim);NOBRAte.appendChild(ImgCalendarAte);ImgCalendarDe.src="/t/default/img/action/Calendar.gif";ImgCalendarDe.onclick=function(){return showCalendar(this.previousSibling,pattern)};ImgCalendarAte.src="/t/default/img/action/Calendar.gif";ImgCalendarAte.onclick=function(){return showCalendar(this.previousSibling,pattern)};with(DataInicio){id=Field.name+".Inicio";name=Field.name+".Inicio";style.width="80px"}DataInicio.onkeypress=function(e){e=document.all?window.event:e;return NumberOnly(e)};DataInicio.onkeyup=function(e){return Mask(this,mask,e)};with(DataFim){id=Field.name+".Fim";name=Field.name+".Fim";style.width="80px"}DataFim.onkeypress=function(e){e=document.all?window.event:e;return NumberOnly(e)};DataFim.onkeyup=function(e){return Mask(this,mask,e)};return false}function returnDate(B,A){if(B.length>=1&&A.length>=1){return B+" - "+A}else{return B+A}}function move(Element,pos){var Row=Element.parentNode.parentNode,cloneRow=Row.cloneNode(true),Table=Row.parentNode,rowAround=pos==0?Row.nextSibling:(pos==1?Row.previousSibling:undefined),cloneAround,RowOldChecked,AroundOldChecked;if(rowAround!=undefined&&rowAround.className!="row_mid"&&rowAround.className!="row_top"){cloneAround=rowAround.cloneNode(true);RowOldChecked=Row.firstChild.firstChild.checked;AroundOldChecked=rowAround.firstChild.firstChild.checked;with(Table){replaceChild(cloneRow,rowAround);replaceChild(cloneAround,Row)}cloneRow.firstChild.firstChild.checked=RowOldChecked;cloneAround.firstChild.firstChild.checked=AroundOldChecked}}function moveTop(Element){var Row=findParentElement(Element,"TR"),cloneRow=Row.cloneNode(true),Table=Row.parentNode,rowAround,cloneAround,RowOldChecked,AroundOldChecked;rowAround=Table.firstChild;if(rowAround!=undefined&&rowAround.className!="row_mid"&&rowAround.className!="row_top"){cloneAround=rowAround.cloneNode(true);RowOldChecked=Row.firstChild.firstChild.checked;AroundOldChecked=rowAround.firstChild.firstChild.checked;with(Table){insertBefore(Row,rowAround)}cloneRow.firstChild.firstChild.checked=RowOldChecked;cloneAround.firstChild.firstChild.checked=AroundOldChecked}}function findParentElement(B,A,C,D){if(B.parentNode!=null){if(B.parentNode.nodeName==A&&(!C||(B.parentNode.getAttribute(C)==D))){return B.parentNode}else{return findParentElement(B.parentNode,A,C,D)}}else{return null}}function findChildElement(B,A,D,F){var C,E;if(B.childNodes!=null&&B.childNodes.length>0){for(C=0;C<B.childNodes.length;C++){if(B.childNodes[C].nodeName==A&&(!D||(B.childNodes[C].getAttribute(D)==F))){return B.childNodes[C]}else{E=findChildElement(B.childNodes[C],A,D,F);if(E!=null){return E}}}}else{return null}}function sumAppend(B,A){B.value=B.value*1+A*1}function inetPress(A,B){if(!/[.]/.test(String.fromCharCode(keyCode(B)))&&!/[0-9]/.test(String.fromCharCode(keyCode(B)))&&keyCode(B)!=8&&keyCode(B)!=0){return false}else{if(/[.]/.test(String.fromCharCode(keyCode(B)))&&(A.value.findChar(".")>=3||A.value.charAt(A.value.length-1)==".")){return false}}}function inetUp(A,C){var D=A.value.split("."),B;if(keyCode(C)!=8&&keyCode(C)!=37&&keyCode(C)!=38&&keyCode(C)!=40){for(B=0;B<D.length+1;B++){if(D[B]>255){D[B]=D[B].substr(0,D[B].length-1)}}A.value=D.join(".");if(keyCode(C)==39&&A.value.charAt(A.value.length-1)!="."&&A.value.findChar(".")<3){A.value=A.value+"."}if(D[D.length-1].length==3&&A.value.findChar(".")<3){A.value+="."}}}function smb(E,D,C){if(typeof D=="string"){D=$A(D)}var F=Event.element(E).up("tr[key]")||Event.element(E).up("tr"),A=F.getForm().name.substr(1),B;if(D){B={Update:D[0],Delete:D[1]}}ShowMenuBrowse(A,E,F,B,C);Event.stop(E)}function ShowMenuBrowse(O,N,Q,P,M){var K=document.forms[O],L=document.forms["P"+O],C=K.elements._ClassId.value,A,I=($(Q).readAttribute("key")||"").toQueryParams(),B,J,F,H,E,G;K.setAttribute("Selected",$(Q).readAttribute("key"));L.setAttribute("Selected",$(Q).readAttribute("key"));if(copy_from_formid&&document.forms[copy_from_formid]!=undefined&&(parseInt(document.forms[copy_from_formid].elements._Level.value)==(parseInt(L.elements._Level.value)+1)||(document.forms[copy_from_formid].elements._Level.value==L.elements._Level.value&&document.forms[copy_from_formid].elements._ClassId.value==L.elements._ClassId.value))){document.forms[copy_from_formid].elements._copyTo.value="_ClassId="+C+"&_Level="+K.elements._Level.value+"&"+$H(I).toQueryString();A={New:"none",Paste:"",Cancel:"none",SelectAll:"none",DeleteSelected:"none",Copy:"none",Move:"none",Delete:"none",Update:"none"}}else{A={New:"",Paste:"none",Cancel:"none",SelectAll:"",DeleteSelected:"",Move:"",Copy:"",Delete:"",Update:"",MultiInserttrigger:"",MultiInsertdata:"",Insertdata:"",Inserttrigger:"",Insertlog:"",InsertSelect:""};if(!isChecked(L.elements["_"+L.elements._ClassId.value+".MSelect"])){A.DeleteSelected=A.Move=A.MultiInserttrigger=A.MultiInsertdata=A.Copy="none"}else{A.Delete=A.InsertSelect=A.Update=A.Inserttrigger=A.Insertdata=A.Insertlog="none"}}if(P){for(J in P){A[J]=P[J]==0?"none":A[J]}}if(M){for(J in M){A[J]=M[J]=="0"?"none":""}}for(J in A){var D=J.split(/\./);F=/\./.test(J)?window.Ultra.ContextMenu.idPreffix+"XInsert_"+D[0]+"."+D[1]+"_"+O:window.Ultra.ContextMenu.idPreffix+J+O;H=document.getElementById(F);if(H){H.style.display=A[J]}}for(J in I){K.elements[C+"."+J].value=I[J]}E=document.all?(document.documentElement.scrollTop-45):window.scrollY;G=document.all?document.documentElement.scrollLeft:window.scrollX;("ContextMenu-"+O).asId().showAtEvent(N);Event.stop(N);return false}function acts(E){var D=Event.element(E),F=D.up("tr"),B=F.readAttribute("key").toQueryParams(),C=$(document.forms[F.getForm().name.replace(/^P/,"")]),A;for(A in B){C.field(A).value=B[A]}$("ContextMenu-"+C.name+"-Actions").showAtEvent(E);Event.stop(E)}function ControlerMenuPopUp(A){document.currentPopUp=A;if(!document.onclick){document.onclick=function(D){D=document.all?window.event:D;var C=document.all?D.srcElement:D.target,B=true;while(C.parentNode!=null){if(C.tagName=="A"){this.currentPopUp.style.display="none";break}else{C=C.parentNode;if(C==this.currentPopUp){B=false;break}else{if(C==this.currentPopUp.parentNode){break}}}}if(B){this.currentPopUp.style.display="none"}}}}function setValue(_Form,Hash,Submit,target){var Form=document.forms[_Form],oldTarget,hbval={},k,field,doSubmit;for(k in Hash){if(Form.elements[k]){hbval[k]=Form.elements[k].value}}for(k in Hash){if(Form.elements[k]){Form.elements[k].value=Hash[k]}else{field=document.createElement("input");with(field){type="hidden";name=k;value=Hash[k]}Form.appendChild(field)}}if(Submit){if(target){oldTarget=Form.target;Form.target=target}try{doSubmit=Form.onsubmit()}catch(e){}if(doSubmit!==false){Form.submit()}if(target){Form.target=oldTarget}for(k in hbval){if(Form.elements[k]){Form.elements[k].value=hbval[k]}}}return hbval}function submitTo(B,A){requestURL("POST","Class.cgi",$(B),$(A),0,180000)}function reorder(C,H,G,E,A){if(H==G){return }var D=C.rows[H].cloneNode(true),B=C.rows[G].cloneNode(true),F;C.replaceChild(D,C.rows[G]);C.replaceChild(B,C.rows[H]);F=$(A);if(C.rows[C.rows.length-1]!=$(E)){F.setStyle({display:"none"})}else{F.setStyle({display:""})}}function checkInterval(A){return/^\d+:\d+(:\d+)?$/.test(A)}function formatInterval(A,D){var B=String(keyCode(D)),C=keyChar(D);if(!/\d|[:]/.test(C)&&![0,8,13].include(B)){return false}else{if(/[:]/.test(C)){if(A.length==0||A.charAt(A.length-1)==":"||A.findChar(":")>1){return false}}}}function formatFloat(A,D){var B=String(keyCode(D)),C=keyChar(D);if(!/\d|[\.]/.test(C)&&![0,8,13].include(B)){return false}else{if(/[\.]/.test(C)&&A.indexOf(".")>=1){return false}}}function formatFloatSigned(A,D){var B=String(keyCode(D)),C=keyChar(D);if(!/\d|[\.]|[\-]/.test(C)&&![0,8,13].include(B)){return false}else{if(/[\-]/.test(C)&&A.indexOf("-")!=-1){return false}else{if(/[\.]/.test(C)&&A.indexOf(".")>=1){return false}}}}function formatSignalAjust(A){if(A.indexOf("-")==-1){return A}else{return"-"+A.replace(/\-/,"")}}function moveTHead(C,E){var D=C.rows[1],B=C.rows[2],A=document.documentElement.scrollTop;if(A){A-=81}D.style.top=B.style.top=A+"px"}function inspectElement(C){var A=[],B,D;for(B in C){A.push(B+" => "+C[B])}D=A.join("<br />");doDebug(D)}function initBrowserScroll(G){var B=document.getElementById(G),F=B.rows[1],C=B.rows[2],A,D;function E(){A=document.documentElement.scrollTop;if(A<81){A=null}else{if(A>81){A-=81}}D=A?A+"px":"";[F,C].each(function(H){if(H&&H.style){H.style.top=D}})}Event.observe(window,"scroll",E)}function sr(D){if(D.getAttribute("selected")){return }D.setAttribute("selected","1");var C=new Array,B=aryobjToAry(D.cells);B.map(function(E){C.push(E.className=="selectedBrowseRow"?"":E.className);E.className="selectedBrowseRow"});function A(){function E(){B.map(function(G,F){G.className=C[F]});Event.stopObserving(D,"mouseout",A);Event.stopObserving(document,"mousedown",E);D.removeAttribute("selected")}Event.observe(document,"mousedown",E)}Event.observe(D,"mouseout",A)}window.selectRow=sr;function popDoubleInsert(){var A=window.open("","_blank","");requestURL("GET","/Ultra/"+getSession()+"/Class.cgi","_ClassId=tbMovimentacaoFinanceira&_tbMovimentacaoFinanceira.Method=Insert",A.document,0)}function nav(){var A=navigator.appName;if(A.indexOf("Microsoft")!=-1){return"ie"}if(A.indexOf("Netscape")!=-1){return"ff"}if(A.indexOf("Konqueror")!=-1){return"kq"}if(A.indexOf("iPhone")!=-1){return"ip"}if(A.indexOf("Safari")!=-1){return"sf"}}function StartDrag(B,E){var A=document.getElementById(E),D,C;if(nav()=="ff"||nav()=="kq"){D=B.layerX;C=B.layerY}else{if(nav()=="ie"){D=event.offsetX;C=event.offsetY;A=A.style}}document.onmousemove=function(F){if(A){if(nav()=="ff"||nav()=="kq"){A.style.top=F.pageY-C+"px";A.style.left=F.pageX-D+"px"}else{if(nav()=="ie"){A.pixelLeft=event.clientX-D+document.body.scrollLeft;A.pixelTop=event.clientY-C+document.body.scrollTop;return false}}}};document.onmouseup=function(){A=null}}function changeDisplay(id,e){var el=document.getElementById(id);if(el.style.display=="none"||!el.style.display){with(el.style){display="block";top=e.clientY+"px";left=e.clientX+"px"}}else{el.style.display="none"}}function inputInArr(C,D){var B=D.name,A;if(C.elements[B]!=undefined&&C.elements[B].tagName==undefined){for(A=0;A<C.elements[B].length;A++){if(D==C.elements[B][A]){return A}}}else{return null}}function toMask(B){if(String(B).indexOf(".")==-1){B=String(B)+".00"}var C=String(B).split(".")[0],A=String(B).split(".")[1];if(A.length>2){A=A.substr(0,2)}return C+"."+String(A).rpad(0,2)}function unMaskMoney(A){return A.replace(/\./g,"").replace(/,/,".")}function InterfaceHide(D){var C=(D.split("-")[1]),B,E,A;document.getElementById(D).style.display="none";document.getElementById("b-"+D).style.display="none";for(A=0;A<3;A++){B=document.getElementById("layers-"+C+"-"+A),E=document.getElementById("b-layers-"+C+"-"+A);if(E.style.display=="block"||E.style.display=="table-cell"){E.onclick();break}}}function InterfaceShow(D){var C=true,B=D.split("-")[1],A;for(A=0;A<3;A++){if(document.getElementById("layers-"+B+"-"+A).style.display!="none"){C=false}}if(C){document.getElementById(D).style.display=moz?"table-cell":"block"}document.getElementById("b-"+D).style.display=moz?"table-cell":"block";document.getElementById("b-"+D).onclick()}function handleColumnOptions(G,L,D,R){var N=["sortColumn","group","subTotalizeColumn","Fx","Info"],J=N.map(function(S){return"b-"+L+"."+S}),E,Q,K,A,I,F,C,O,P,M;if(D){E=aryobjToAry(D.parentNode.parentNode.childNodes).grep(function(S){return S>=3}).map(function(S){return S?S.childNodes[D.cellIndex]:document.createElement("td")});if(R){Q=new Array;E.map(function(S){if(S){if(S.className!="selectedBrowseRow"){K=S.className}S.className="selectedBrowseRow"}Q.push(K)});function H(S){if(document.body.hideMenu==false){return }E.map(function(U,T){if(U){U.className=Q[T]}});Event.stopObserving(document,"click",H)}Event.observe(document,"click",H)}}function B(S){return S.nodeType==1&&J.include(String(S.getAttribute("id")))}A=document.getElementById("Top"+L);I=getChilds(A,B);I.map(function(S){if(S){S.style.display=R?"block":"none"}});if(typeof document.forms[L].elements["_"+G+".SubTotal"]!="undefined"){F=document.forms[L].elements["_"+G+".SubTotal"]}else{F=""}C=document.getElementById(L+".sortColumn");C.style.display=!R||F?"none":"block";M=document.getElementById("b-"+L+".hideColumn");O=!R||!D?"none":"block";if(D&&R){P=D.parentNode.childNodes.length;if(P==2){O="none"}}M.style.display=O}function hideColumnOptions(A,B,C){if(("Top"+B).asId().showAtEvent(C)){handleColumnOptions(A,B,null,false)}Event.stop(C)}function addColumnAfter(C,A){var B=C.firstChild;B.checked=!B.checked;B.value=A+">"+window.activeColumn.name}function showColumnOptions(D,L,B,K,G,I){if(!("Top"+L).asId().showAtEvent(G)){return }Event.stop(G);var C=document.forms[L],A,F,H,E,J,M;window.activeColumn={name:B,element:K};if(I!="BrowseForm"){handleColumnOptions(D,L,K,true);A=C.elements["_"+D+".Order"].value;if(A==B){F=C.elements["_"+D+".OrderDesc"].value;A=F?"Desc":"Asc";H=document.getElementById(L+".sort"+A+"Column");H.checked=true}else{H=C.elements[L+".sortColumn"];H[0].checked=false;H[1].checked=false}H=C.elements[L+".groupColumnCheck"];if(H!=null){H.checked=$(C).down("[name=_"+D+".GroupBy][value="+B+"]")?true:null}H=C.elements[L+".subTotalizeColumnCheck"];if(H!=null){H.checked=$(C).down("[name=_"+D+".SubTotal][value="+B+"]")?true:null}}}function hideColumn(G,D,H){var B=window.activeColumn.element,A=window.activeColumn.name,C=document.forms[G].elements[D+"."+A],E;if(C.value){C=C.parentNode.removeChild(C);appendInput(document.forms[G],C)}function F(I){return I.nodeType==1&&I.cellIndex==B.cellIndex}E=getChilds(B.parentNode.parentNode,F);E.map(function(I){if(I){I.parentNode.removeChild(I)}})}function sortColumn(J,C,H){var F=document.forms[J].elements,D="_"+C+".",B=window.activeColumn.name,A=F[D+"Order"],I=F[D+"OrderDesc"],E,K,G;if(A.value==B&&((I.value&&H)||(!I.value&&!H))){E=K="";G=H?"sortDescColumn":"sortAscColumn";String(J+"."+G).asId().checked=false}else{E=B;K=H||"";G=H?"sortDescColumn":"sortAscColumn";String(J+"."+G).asId().checked=true}A.value=E;I.value=K;trySubmit(J,C)}function appendInput(C,B,A){A=A||C;if(!moz){C.elements[C.elements.length]=B}A.appendChild(B)}function removeInput(Input){if(!moz){with(Input){name=value=""}}var Parent=Input.parentNode;Parent.removeChild(Input)}function groupColumn(F,B){var D=String(F+".groupColumnCheck").asId(),E=D.checked,H=document.forms[F],A=window.activeColumn.name,C=aryobjToAry(H.elements),G;if(E){G=$(H).down("[name=_"+B+".GroupBy][value="+A+"]");if(G){removeInput(G)}D.checked=false}else{G=document.createElement("input");G.type="hidden";G.name="_"+B+".GroupBy";G.value=A;appendInput(H,G);D.checked=true}trySubmit(F,B)}function subTotalizeColumn(F,B){var D=String(F+".subTotalizeColumnCheck").asId(),E=D.checked,H=document.forms[F],A=window.activeColumn.name,C=aryobjToAry(H.elements),G;if(E){G=$(H).down("[name=_"+B+".SubTotal][value="+A+"]");if(G){removeInput(G)}D.checked=false}else{G=document.createElement("input");G.type="hidden";G.name="_"+B+".SubTotal";G.value=A;appendInput(H,G);D.checked=true}trySubmit(F,B)}function trySubmit(B,A){var D=document.forms[B],C=D.elements["_"+A+".doAutoSubmit"];if(C&&C.checked){D.elements["_"+A+".Method"].value="AjaxBrowse";D.onsubmit()}}function Input(A){if(A.type=="checkbox"){A.style.border="none"}else{A.onfocus=function(){A.oldClass=A.className;A.className=A.oldClass+" focus"};A.onblur=function(){A.className=A.oldClass?A.oldClass:undefined}}if(A.disabled){A.style.backgroundColor="#F8F8F8";A.style.color="#525252"}}function showBrowseFn(F,K,M,B,C){if(B&&B.value&&B.value.match(/^Html::input::Function::ReverseFK/)){return }var J=document.forms[M]||B.form,C=window.activeColumn?window.activeColumn.name:B.getAttribute("FieldId"),I,H,G,L,E,N,A,D;if(B.nodeName=="SELECT"){I=findParentElement(B,"LI");H=findParentElement(B,"UL");for(G=0;H.lastChild!=I;H.removeChild(H.lastChild)){}L=document.createElement("li");H.appendChild(L);B=L;if(K=="Fn"||K=="*Fn"){E=document.getElementById(M+".Fg");if(E){E.lastActiveColumn=""}}}N=J.elements._ParentFieldId.value;A=J.elements["_"+F+".Method"].value;D=J.elements["_"+F+".XMethod"].value;J.elements._ParentFieldId.value=C;J.elements["_"+F+".Method"].value="AjaxShowFn";J.elements["_"+F+".XMethod"].value=K;if(K.substr(0,1)=="*"||C!=B.lastActiveColumn){requestURL("GET","Class.cgi",J,B,0)}J.elements._ParentFieldId.value=N;J.elements["_"+F+".Method"].value=A;J.elements["_"+F+".XMethod"].value=D;B.lastActiveColumn=C}function changeAggFn(F,E,L,D,B){var J=D.form,I,A,C,H,G,K;if(B==null){B=0}if(!J.elements[D.name]){return }else{if(J.elements[D.name].nodeName=="SELECT"){I=[J.elements[D.name]]}else{I=J.elements[D.name]}}if(J.elements["_"+F+"."+E+"."+L]&&J.elements["_"+F+"."+E+"."+L].nodeName=="INPUT"){A=J.elements["_"+F+"."+E+"."+L];A.parentNode.removeChild(A)}else{if(J.elements["_"+F+"."+E+"."+L]){C=J.elements["_"+F+"."+E+"."+L];H=C.length;for(G=0;G<H;G++){C[0].parentNode.removeChild(C[0])}}}for(G=0;G<=B;G++){if(I[G].value){K=document.createElement("input");K.type="hidden";K.name="_"+F+"."+E+"."+L;K.value=I[G].value;J.appendChild(K)}}trySubmit(J.name,F)}function enableSlaveFields(E,C,A){var D=document.forms[E],B=$A(D.elements);B.map(function(F){if(!((A&&F.type!="hidden"&&(String(F.name).indexOf(C)==0||F.name=="_"+C+".Submit2")&&F.disabled&&F.getAttribute("canEnable"))||(!A&&F.type!="hidden"&&(String(F.name).indexOf(C)==0||F.name=="_"+C+".Submit2")&&!F.disabled))){}else{if(A){F.removeAttribute("canEnable");F.disabled=!A}else{F.setAttribute("canEnable","true");F.disabled=!A}}})}function loadMain(D){var B=parent.document.getElementById("Desktop").contentWindow.document.getElementById("LoadingClass"),A=document.getElementById("Explorer");if(D.contentWindow.document.body.innerHTML!=""){D.style.zIndex=++parent.document.getElementById("Desktop").contentWindow.Ultra.Floating.maxZIndex;D.style.zIndex=parent.document.getElementById("Desktop").contentWindow.document.documentElement.scrollTop=0;D.style.display="block";parent.document.getElementById("Desktop").contentWindow.document.body.style.overflow="hidden";parent.document.getElementById("Desktop").contentWindow.document.getElementById("AllDesktops").style.visibility="hidden";if(B.style.display!="none"){B.style.display="none"}}try{D.contentWindow.document.onclick=A.hide}catch(C){}}function changeBrowseMethod(H,D,I,K,C){var G=document.forms[H],E=G.elements,B=E["_"+D+".Calendar"].value,A=E["_"+D+".CalendarWhen"].value,J=E["_"+D+".BrowseTableClass"].value;if(I!=null){E["_"+D+".Calendar"].value=I}if(I!=null){E["_"+D+".BrowseLimit"].value=""}if(C!=null){E["_"+D+".BrowseTableClass"].value=C}if(K!=null){E["_"+D+".CalendarWhen"].value=K}G.onsubmit();try{E["_"+D+".Calendar"].value=B;E["_"+D+".CalendarWhen"].value=A;E["_"+D+".BrowseTableClass"].value=J}catch(F){}}function cc(B,D,A){var C=$(B).getForm();if(!A){A=B.getAttribute("today")}return changeCalendar(C,D,A)}function changeCalendar(B,C,D,A){B.elements["_"+B.elements._ClassId.value+".Calendar"].value=C;B.elements["_"+B.elements._ClassId.value+".CalendarWhen"].value=D;if(A!=null){B.elements["_"+B.elements._ClassId.value+".BrowseTableClass"].value=A}B.onsubmit()}tip=new Array;tip[0]="Visit Dynamic Drive<br> for DHTML Scripts!";tip[1]="Visit JavaScript Kit for Great<br> Scripts, Tutorials and Forums!";tip[2]="Visit Request Code for FREE JavaScripts!";tip[3]="Click here for some excellent<br>Java applets and tutorials";function showtip(A,C,B){if(!B){B=A.innerHTML}if(document.getElementById){var D=document.getElementById("tooltip");D.innerHTML=B;D.style.top=parseInt(C.pageY+3)+"px";D.style.left=parseInt(C.pageX+3)+"px";D.style.visibility="visible"}}function hidetip(){if(document.getElementById){document.getElementById("tooltip").style.visibility="hidden"}}function noDuplicates(C){var B=C.form.elements[C.name],A;if(B.length&&B.length>1){for(A=0;A<B.length;A++){if(B[A]!=C&&B[A].value==C.value){alert("Já existe um elemento com esse valor. Por favor escolha outro!");C.value=""}}}}Ultra.Calendar=new Object;Ultra.Calendar.showDayRowsAsContained=function(){var A=this.getElementsByTagName("DIV")[0];A.style.visibility="visible";A.style.display="inline";A.style.position="absolute"};Ultra.Calendar.hideDayRowsAsContained=function(){var A=this.getElementsByTagName("DIV")[0];A.style.visibility="hidden"};Ultra.Calendar.showDivDayAsContainer=function(){this.style.position="relative";this.style.overflow="visible";this.firstChild.style.backgroundColor="white";this.firstChild.style.border="1px solid black"};Ultra.Calendar.hideDivDayAsContainer=function(){this.style.position="";this.style.overflow="hidden";this.firstChild.style.backgroundColor="";this.firstChild.style.border=""};Ultra.Calendar.hideDivDay=function(){this.style.visibility="hidden"};var SPECIAL_ATTRIBUTE=["Special Attribute"],NORMAL_ATTRIBUTE=["Normal Attribute"],OVERWRITE=["Overwrite"],WRITEBEFORE=["Write Before"],WRITEAFTER=["Write After"];function setAttribute(D,B,G,F,C){D=$(D);if(!D){return false}var A=D.nodeType===undefined?$A(D):[D],E=F||OVERWRITE;C=C===undefined?";":C;A.each(function(L){var N,K,J,O,I,M,H;if(L.getAttribute(B)){if(L[B]){if(typeof L[B]=="function"){N=SPECIAL_ATTRIBUTE;K=L.getAttribute(B)}else{N=NORMAL_ATTRIBUTE;K=L[B]}}else{N=NORMAL_ATTRIBUTE;K=L.getAttribute(B)}}else{if(L[B]===null){N=SPECIAL_ATTRIBUTE}else{L.setAttribute(B,"void(0)");if(L[B]){if(typeof L[B]=="function"){N=SPECIAL_ATTRIBUTE}else{N=NORMAL_ATTRIBUTE}}else{N=NORMAL_ATTRIBUTE}L.removeAttribute(B)}}if(E==OVERWRITE){if(N==SPECIAL_ATTRIBUTE){J=new Function("event",G);if(moz){L[B]=J.bindAsEventListener(L)}else{L[B]=null;if(!L.listeners){L.listeners={}}B=B.replace(/^on/,"");if(!L.listeners[B]){L.listeners[B]=[];Event.observe(L,B,function(Q){L.listeners[B].each(function(R){if(R.call(L,Q)==false){throw $break}})})}L.listeners[B]=[J]}}if(N==NORMAL_ATTRIBUTE||moz){L.setAttribute(B,G)}}else{if(N==SPECIAL_ATTRIBUTE){try{J=new Function("event",G)}catch(P){alert(new Ultra.Error("Evento "+B+" do campo "+L.getAttribute("description")+" contém erros: "+String(P.description||P)))}O=typeof K=="function"?K:new Function("event",K);if(moz){I;if(E==WRITEBEFORE){I=function(Q){Q=Q?Q:event;return J.call(L,Q)!==false&&O.call(L,Q)!==false}}else{if(E==WRITEAFTER){I=function(Q){Q=Q?Q:event;return O.call(L,Q)!==false&&J.call(L,Q)!==false}}}L[B]=I.bindAsEventListener(L)}else{L[B]=null;if(!L.listeners){L.listeners={}}B=B.replace(/^on/,"");if(!L.listeners[B]){L.listeners[B]=[O];Event.observe(L,B,function(Q){L.listeners[B].each(function(R){if(R.call(L,Q)==false){throw $break}})})}if(E==WRITEBEFORE){L.listeners[B].unshift(J)}else{if(E==WRITEAFTER){L.listeners[B].push(J)}}}}if(N==NORMAL_ATTRIBUTE||moz){M,H=[G,K];if(E==WRITEBEFORE){M=H.join(C)}else{if(E==WRITEAFTER){M=H.reverse().join(C)}}L.setAttribute(B,M)}}});return true}function toggleBoolBrowseVal(A,D,E,B,C){if((B=$(B)).updating){return }new Ultra.ChoiceDialog({title:"Alteração",message:D.Description,choice:{"1":E["1"],"0":E["0"],"":E[""]},onCreate:function(){if(D.NotNull!="0"){this.dropChoice("")}this.getChoiceByValue(D.value).disabled=true},onChoose:function(){D.value=this.choice().value;B.updating=true;var F=B.innerHTML,G=A.PrimaryKeys;G[D.FieldId]=D.value;G._resolvedAction=1;B.update("<img src='/t/default/img/loading.gif' />");new Ultra.Class(A.ClassId).Update(G,{onSuccess:function(){var H=B.up("form");B.up("td").update(this.Field[D.FieldId].resolved);if(H&&C){H.elements["_"+A.ClassId+".Submit"].click()}},onError:function(H){alert("toogglebool: "+H);B.updating=false;B.update(F)}})}}).show()}function tbbv(){return toggleBoolBrowseVal.apply(this,arguments)}function xsSwitch(A){var B=A.firstChild;if(!B.checked){document.cookie="xs=1;path=/";B.checked=true;document.body.setAttribute("xs",1)}else{document.cookie="xs=0;path=/;expire=Sun, 01 Jan 1900 00:00:00 GMT";B.checked=false;document.body.removeAttribute("xs")}}function HighlightEditor(D,E,A){var B=new Number(Math.random());if(!D.id){var C="textarea_"+B.toString();C=C.replace(/\./g,"");D.setAttribute("id",C)}window.open("/Html/Editor/CodeMirror/Window.html?textarea="+D.id+"&mode="+E+"&"+A,"parser_"+C,"toolbar=no,titlebar=no,status=yes,scrollbars=yes,menubar=yes,location=no,resizable=yes,width="+(screen.availWidth-200)+",height="+(screen.availHeight-200))}function ActionsExec(A,B){A(B)}function doPackageEdit(F,C,E,G,B,A,D){Event.stop(F);requestURL("GET","?_ClassId="+C+"&_Level="+E+"&_"+C+".Method=AjaxSuperContext&_PackageId="+G+"&_PackageType="+B+":"+A+"&_PackageEdit=1&_PackageHide="+G+":"+D,null,findParentElement(Event.element(F),"DIV","type","SuperContext"),1)}function howto(B,A){help(B,"Carregando...","","none");requestURL("GET","Class.cgi?_ClassId=Ultra.Class&_Ultra.Class.Method=AjaxSuperContext&_PackageId=*HELP*&_search_inside=1&_HowTo="+A,null,$("div__helper").firstChild)}function CEP2Map(B){var G=B.field(B.getAttribute("-rua")),C=B.field(B.getAttribute("-numero")),E=B.field(B.getAttribute("-city")),A=E?B.form.elements[E.name+".x"]:null,D=B.field(B.getAttribute("-state"));var F=(G?G.value:"")+", "+(C?C.value:"")+" - "+(A?A.value:E?E.getAttribute("resolved")?E.getAttribute("resolved"):(E.currentOption()?E.currentOption().text:""):"")+" - "+(D?D.value:"");HelpMap(F,null,null,null,[F])}function HelpMap(D,C,B,F,E){if(!C){C="14"}if(!B){B="480x480"}if(!F){F="roadmap"}if(!E){E=[D]}var A="http://maps.google.com/maps/api/staticmap?center="+D+"&size="+B+"&maptype="+F+E.map(function(G){return"&markers="+G}).join("&")+"&sensor=false";help(null,"<img src='"+A+"&zoom="+C+"' xurl='"+A+"' xzoom="+C+' onclick=\'this.setAttribute("xzoom", parseInt(this.getAttribute("xzoom"))+1);this.src=this.getAttribute("xurl")+"&zoom="+(this.getAttribute("xzoom"));\' oncontextmenu=\'this.setAttribute("xzoom", parseInt(this.getAttribute("xzoom"))-1);this.src=this.getAttribute("xurl")+"&zoom="+(this.getAttribute("xzoom"));return false;\' >',"","none")}function getVideo(B,A,C){if(!A){A=427}if(!C){C=268}return'<object width="'+A+'" height="'+C+'"><param name="movie" value="http://www.youtube.com/v/'+B+'&hl=pt-br&fs=1&rel=0&autoplay=1&plune"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+B+'&hl=pt-br&fs=1&rel=0&autoplay=1&plune" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+A+'" height="'+C+'"></embed></object>'}var bloq_div__helper=new Array();function help(H,E,D,B,C){var I;var F;if(Object.isHash(E)){D=E.img?E.img.value:"";B=E.out?E.out.value:"";C=E.classe?E.classe.value:"";E=E.html?E.html.value:""}if(typeof C=="undefined"||C==""){C=0}if((bloq_div__helper[C]==1)&&(H&&H.type!="click")){return }if(nav()=="ip"){return }if(!$("div__helper")){var A=document.createElement("div");A.setAttribute("id","div__helper");if(moz){$(A).setStyle({display:"none",position:"fixed",bottom:"1em",left:"auto",right:"1em"})}else{$(A).setStyle({display:"none",position:"absolute",left:"auto",bottom:"auto",right:"1em",opacity:"0.90",Filter:"Alpha(Opacity=90)",background:"#FFFFFF"})}A.setAttribute("class","div__helper");$(A).setStyle({display:"block"});document.body.appendChild(A)}var G=$("div__helper");if((G.getStyle("display")=="block")&&(G.getAttribute("last_event")=="click")&&(H&&H.type!="click")){return }else{if((H!=null)||(H&&H!=""&&typeof H!="undefined"&&H.type!="")){G.setAttribute("last_event",H.type)}else{G.setAttribute("last_event","click")}}F="<span onmouseover=\"$('div__helper').setStyle({display:'block'});\"><table><tr><td>"+E+"</td>"+(((typeof D=="undefined")||(D==""))?"":("<td><img border=0 src='"+D+"'></td>"))+"</tr></table></span><img src=/t/c/img/action/Close.png style='position:absolute;left:-7px;top:-7px' onmouseover=\"$('div__helper').setStyle({display:'block'});\" onclick=\"$('div__helper').setStyle({display:'none'});bloq_div__helper["+C+']=1;">';G.innerHTML=F;if(G.getStyle("display")!="block"){G.setStyle({display:"block"})}if(!moz){var J;if(document.documentElement&&!document.documentElement.scrollTop){J=document.documentElement.clientHeight-G.getHeight()}else{if(document.documentElement&&document.documentElement.scrollTop){J=(document.documentElement.clientHeight+document.documentElement.scrollTop)-G.getHeight()}else{if(document.body&&document.body.scrollTop){J=(document.body.scrollTop+document.body.clientHeight)-G.getHeight()}}}I=(J-11)+"px";$(G).setStyle({bottom:"auto"});$(G).setStyle({top:I})}if((typeof B=="undefined")||(B=="")){if(H&&H.type=="focus"){B="blur"}else{B="mouseout"}}if(H){Event.observe($(Event.element(H)),B,function(){if((G.getStyle("display")=="block")&&(G.getAttribute("last_event")!="click")){G.setStyle({display:"none"})}})}}function reloadForm(D){if(D){var B=Event.element(D);var C=$(B).up("form");if(typeof C=="undefined"||typeof C=="unknow"){C=document.forms[$(B).readAttribute("formname")]}var A=C.elements._ClassId;if(typeof C.elements["_"+A.value+".Reload"]!="undefined"&&typeof C.elements["_"+A.value+".Reload"]!="unknow"){C.elements["_"+A.value+".Reload"].onclick()}else{if(C.name.match(/^Form/)&&document.forms["P"+C.name]){C=document.forms["P"+C.name]}C.onsubmit()}}};