function AtivaEdicaoRegistro(pblnLigar,pobjCamada,pobjBotao){if(pobjCamada){if(pblnLigar){if(gstrNavegador=="IE"){pobjCamada.style.height=mstrAlturaCamadaEdicaoIE;}else{pobjCamada.style.height=mstrAlturaCamadaEdicaoOutros;}pobjCamada.style.visibility="visible";}else{pobjCamada.style.height="1px";pobjCamada.style.visibility="hidden";}}mobjBotaoENTER=pobjBotao;}function AtualizaArray(parrValor,parrArrayDados,pobjGrid,parrArrayColunas,parrArrayColunasOcultas){var intCont;var intMaiorIndice=0;var intPosicao=0;var strId;if(parrValor[0]!=""){intPosicao=BuscaIndice(parrValor[0],parrArrayDados);if(parrValor[1]=='EXCLUIR'&&parrValor[2]==''){parrArrayDados.splice(intPosicao,1);}else{parrArrayDados[intPosicao]=parrValor;}}else{intMaiorIndice=BuscaMaiorIndiceRegistro();parrValor[0]=parseInt(intMaiorIndice,"10")+1;parrArrayDados[parrArrayDados.length]=parrValor}AtualizaOperacao(parrArrayDados);ManipulaGrid(pobjGrid,parrArrayDados,parrArrayColunas);FormataGrid(parrArrayColunas.length,parrArrayColunasOcultas,parrArrayDados,pobjGrid);AtualizaEstilo(parrArrayDados);}function AtualizaEstilo(parrArrayDados){var intLinha;var intColuna;var strId;for(intLinha=0;intLinha<parrArrayDados.length;intLinha++){if(parrArrayDados[intLinha][1]=='SIM'){for(intColuna=0;intColuna<parrArrayDados[intLinha].length;intColuna++){strId='tag48.data.item:'+intLinha+'.item:'+intColuna;if(document.getElementById(strId)){document.getElementById(strId).style.color="#ff0000";}}}}}function AtualizaOperacao(parrArrayDados){var intLinha;var blnExcluir;var blnAlterar;var blnExiste;for(intLinha=0;intLinha<parrArrayDados.length;intLinha++){blnExcluir=(parrArrayDados[intLinha][1]=='SIM')?true:false;blnAlterar=(parrArrayDados[intLinha][2]=='SIM')?true:false;if(blnExcluir){parrArrayDados[intLinha][3]='EXCLUIR';}else{if(blnAlterar){if(blnExiste){parrArrayDados[intLinha][3]='ATUALIZAR';}else{parrArrayDados[intLinha][3]='INCLUIR';}}else{parrArrayDados[intLinha][3]='';}}}}function BuscaIndice(pintValor,parrArrayDados){var intCont;for(intCont=0;intCont<parrArrayDados.length;intCont++){if(marrGridRegistrosData[intCont][0]==pintValor){return intCont;}}return null;}function BuscaMaiorIndiceRegistro(){var intCont;var intMaiorIndice=-1;if(marrGridRegistrosData.length>0){for(intCont=0;intCont<marrGridRegistrosData.length;intCont++){if(marrGridRegistrosData[intCont][0]>intMaiorIndice){intMaiorIndice=marrGridRegistrosData[intCont][0];}}return intMaiorIndice;}else{return-1;}}function CapturaCelula(pstrCelula,pEvento){var intCont;var strCelula=pstrCelula.toString();var intPosicaoID;var intAspas1=0;var intAspas2=0;var strID;var intIndice;intPosicaoID=strCelula.indexOf("id=");intAspas1=intPosicaoID+3;for(intCont=intAspas1+1;intCont<strCelula.length;intCont++){if(strCelula.charAt(intCont)==':'){if(intAspas2>0){intAspas2=intCont;break;}intAspas2=intCont;}}strID=strCelula.substring(intAspas1+1,intAspas2)+":0";intIndice=document.getElementById(strID).innerHTML;mintGridRegistrosLinhaSelecionada=intIndice;}function ConfirmaRegistro(pintIndice,parrArrayDados,pobjGrid,parrArrayColunas,parrArrayColunasOcultas){var intCont;var intIndice=BuscaIndice(pintIndice,parrArrayDados);var arrRegistro=MontaRegistro();if(arrRegistro[1]=='SIM'){arrRegistro[1]='';}else{arrRegistro[1]="";arrRegistro[2]="SIM";}AtualizaArray(arrRegistro,parrArrayDados,pobjGrid,parrArrayColunas,parrArrayColunasOcultas);}function EditarRegistro(pintLinhaSelecionada,parrArrayDados,pobjCamada){if(pintLinhaSelecionada>-1){PreencheEdicaoRegistro(parrArrayDados[BuscaIndice(pintLinhaSelecionada,parrArrayDados)]);AtivaEdicaoRegistro(true,pobjCamada);}else{alert('Selecione um registro para edição!');}}function ExcluiRegistro(parrArrayDados,pobjGrid,parrArrayColunas,parrArrayColunasOcultas){var arrRegistro=MontaRegistro();if(document.getElementById('hidRegistrosIndice').value!=""){arrRegistro[1]="SIM";AtualizaArray(arrRegistro,parrArrayDados,pobjGrid,parrArrayColunas,parrArrayColunasOcultas);}}function FormataGrid(pintNumeroColunas,parrArrayColunasOcultas,parrArrayDados,pobjGrid){var intCont;var intAux;var blnOcultar;var strEstiloAlvo;var strCelulaAlvo;var strColunaAlvo;var strColunaLargura;var obj;pobjGrid.setClass("controls","grid");for(intCont=0;intCont<pintNumeroColunas;intCont++){blnOcultar=false;for(intAux=0;intAux<parrArrayColunasOcultas.length;intAux++){if(parrArrayColunasOcultas[intAux]==intCont){blnOcultar=true;break;}}strEstiloAlvo="active-column-"+intCont;strColunaAlvo="tag48.top.item:"+intCont;strColunaAlvoDiv="tag48.top.item:"+intCont+"/div";for(intAux=0;intAux<parrArrayDados.length;intAux++){strCelulaAlvo="tag48.data.item:"+intAux+".item:"+intCont;if(document.getElementById(strCelulaAlvo)){if(blnOcultar){document.getElementById(strCelulaAlvo).className=document.getElementById(strCelulaAlvo).className.replace(strEstiloAlvo,strEstiloAlvo+"Ocultar");document.getElementById(strCelulaAlvo).className=document.getElementById(strCelulaAlvo).className.replace("active-grid-column","");}else{document.getElementById(strCelulaAlvo).className=document.getElementById(strCelulaAlvo).className.replace(strEstiloAlvo,strEstiloAlvo);}}}if(blnOcultar){document.getElementById(strColunaAlvo).className=document.getElementById(strColunaAlvo).className.replace(strEstiloAlvo,strEstiloAlvo+"Ocultar");}else{document.getElementById(strColunaAlvo).className=document.getElementById(strColunaAlvo).className.replace(strEstiloAlvo,strEstiloAlvo);}for(intAux=0;intAux<document.getElementById(strColunaAlvo).attributes.length;intAux++){if(document.getElementById(strColunaAlvo).attributes[intAux].name.indexOf('onmouse')>-1){document.getElementById(strColunaAlvo).attributes[intAux].value="";}}if(blnOcultar){for(intAux=0;intAux<document.getElementById(strColunaAlvoDiv).attributes.length;intAux++){if(document.getElementById(strColunaAlvoDiv).attributes[intAux].name.indexOf('onmouse')>-1){document.getElementById(strColunaAlvoDiv).attributes[intAux].value="";}}}}}function ManipulaGrid(pobjGrid,parrArrayDados,parrArrayColunas){blnOperacao=0;if(pobjGrid==null){blnOperacao=0;}else{blnOperacao=1;}if(blnOperacao==0){pobjGrid=new Active.Controls.Grid;}pobjGrid.setRowProperty("count",parrArrayDados.length);pobjGrid.setColumnProperty("count",parrArrayColunas.length);pobjGrid.setDataProperty("text",function(i,j){return parrArrayDados[i][j]});pobjGrid.setColumnProperty("text",function(i){return parrArrayColunas[i]});pobjGrid.setRowHeaderWidth("25px");pobjGrid.setColumnHeaderHeight("20px");pobjGrid.setAction("click",function(src){CapturaCelula(src,event)});if(blnOperacao==0){return pobjGrid;}else{pobjGrid.refresh();}}if(!window.Active){var Active={}}if(!Active.System){Active.System={}}if(!Active.HTML){Active.HTML={}}if(!Active.Templates){Active.Templates={}}if(!Active.Formats){Active.Formats={}}if(!Active.HTTP){Active.HTTP={}}if(!Active.Text){Active.Text={}}if(!Active.XML){Active.XML={}}if(!Active.Controls){Active.Controls={}}(function(){if(!window.HTMLElement){return}var element=HTMLElement.prototype;var capture=["click","mousedown","mouseup","mousemove","mouseover","mouseout","doubleclick"];var getClientWidth=function(){return this.offsetWidth-20};var getClientHeight=function(){return this.offsetHeight-20};element.__defineGetter__("clientWidth",getClientWidth);element.__defineGetter__("clientHeight",getClientHeight);var getRuntimeStyle=function(){return this.style};element.__defineGetter__("runtimeStyle",getRuntimeStyle);var cs=ComputedCSSStyleDeclaration.prototype;cs.__defineGetter__("paddingTop",function(){return this.getPropertyValue("padding-top")});var getCurrentStyle=function(){return document.defaultView.getComputedStyle(this,"")};element.__defineGetter__("currentStyle",getCurrentStyle);var setOuterHtml=function(s){var range=this.ownerDocument.createRange();range.setStartBefore(this);var fragment=range.createContextualFragment(s);this.parentNode.replaceChild(fragment,this)};element.__defineSetter__("outerHTML",setOuterHtml)})();Active.System.Object=function(){};Active.System.Object.subclass=function(){var constructor=function(){this.init()};for(var i in this){constructor[i]=this[i]}constructor.prototype=new this();constructor.superclass=this;return constructor};Active.System.Object.handle=function(error){throw(error)};Active.System.Object.create=function(){var obj=this.prototype;obj.clone=function(){if(this._clone.prototype!==this){this._clone=function(){this.init()};this._clone.prototype=this}return new this._clone()};obj._clone=function(){};obj.init=function(){};obj.handle=function(error){throw(error)};obj.timeout=function(handler,delay){var self=this;var wrapper=function(){handler.call(self)};return window.setTimeout(wrapper,delay?delay:0)};obj.toString=function(){return""}};Active.System.Object.create();Active.System.Model=Active.System.Object.subclass();Active.System.Model.create=function(){var obj=this.prototype;var join=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s};obj.defineProperty=function(name,value){var _getProperty=join("get",name);var _setProperty=join("set",name);var _property="_"+name;var getProperty=function(){return this[_property]};this[_setProperty]=function(value){if(typeof value=="function"){this[_getProperty]=value}else{this[_getProperty]=getProperty;this[_property]=value}};this[_setProperty](value)};var get={};var set={};obj.getProperty=function(name,a,b,c){if(!get[name]){get[name]=join("get",name)}return this[get[name]](a,b,c)};obj.setProperty=function(name,value,a,b,c){if(!set[name]){set[name]=join("set",name)}return this[set[name]](value,a,b,c)};obj.isReady=function(){return true}};Active.System.Model.create();Active.System.HTML=Active.System.Object.subclass();Active.System.HTML.create=function(){var obj=this.prototype;obj.setTag=function(tag){this._tag=tag};obj.getTag=function(){return this._tag};obj._tag="div";obj.init=function(){if(this.$owner){return}if(this._parent){return}this._id="tag"+this.all.id++;this.all[this._id]=this};obj.getId=function(){return this._id};obj._id="";obj.all=Active.System.all={id:0};obj.setId=function(id){this._id=id;this.all[this._id]=this};obj.element=function(){var i,docs=this._docs,id=this.getId(),e;for(i=0;i<docs.length;i++){e=docs[i].getElementById(id);if(e){return e}}};obj._docs=[document];obj.getClass=function(name){var param="_"+name+"Class";var value=this[param];return typeof(value)=="function"?value.call(this):value};obj.setClass=function(name,value){var element=this.element();if(element){var v=(typeof(value)=="function")?value.call(this):value;element.className=element.className.replace(new RegExp("(active-"+name+"-\\w+|$)")," active-"+name+"-"+v+" ");if(this.$index!==""){return}}if(this.data){return}var param="_"+name+"Class";if(this[param]==null){this._classes+=" "+name}this[param]=value;this._outerHTML=""};obj.refreshClasses=function(){var element=this.element();if(!element){return}var s="",classes=this._classes.split(" ");for(var i=1;i<classes.length;i++){var name=classes[i];var value=this["_"+name+"Class"];if(typeof(value)=="function"){value=value.call(this)}s+="active-"+name+"-"+value+" "}element.className=s+this.$browser};obj._classes="";obj.getStyle=function(name){var param="_"+name+"Style";var value=this[param];return typeof(value)=="function"?value.call(this):value};obj.setStyle=function(name,value){var element=this.element();if(element){element.style[name]=value}if(this.data){return}var param="_"+name+"Style";if(this[param]==null){this._styles+=" "+name}this[param]=value;this._outerHTML=""};obj._styles="";obj.getAttribute=function(name){try{var param="_"+name+"Attribute";var value=this[param];return typeof(value)=="function"?value.call(this):value}catch(error){this.handle(error)}};obj.setAttribute=function(name,value){try{var param="_"+name+"Attribute";if(typeof this[param]=="undefined"){this._attributes+=" "+name}if(specialAttributes[name]&&(typeof value=="function")){this[param]=function(){return value.call(this)?true:null}}else{this[param]=value}this._outerHTML=""}catch(error){this.handle(error)}};obj._attributes="";var specialAttributes={checked:true,disabled:true,hidefocus:true,readonly:true};obj.getEvent=function(name){try{var param="_"+name+"Event";var value=this[param];return value}catch(error){this.handle(error)}};obj.setEvent=function(name,value){try{var param="_"+name+"Event";if(this[param]==null){this._events+=" "+name}this[param]=value;this._outerHTML=""}catch(error){this.handle(error)}};obj._events="";obj.getContent=function(name){try{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);return ref.getContent(split[2])}else{var param="_"+name+"Content";var value=this[param];if((typeof value=="object")&&(value._parent!=this)){value=value.clone();value._parent=this;value._id=this._id+"/"+name;this[param]=value}return value}}catch(error){this.handle(error)}};obj.setContent=function(name,value){try{if(arguments.length==1){this._content="";if(typeof name=="object"){for(var i in name){if(typeof(i)=="string"){this.setContent(i,name[i])}}}else{this.setContent("html",name)}}else{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);ref.setContent(split[2],value);this._innerHTML="";this._outerHTML=""}else{var param="_"+name+"Content";if(this[param]==null){this._content+=" "+name}if(typeof value=="object"){value._parent=this;value._id=this._id+"/"+name}this[param]=value;this._innerHTML="";this._outerHTML=""}}}catch(error){this.handle(error)}};obj._content="";obj.$index="";var getParamStr=function(i){return"{#"+i+"}"};obj.innerHTML=function(){try{if(this._innerHTML){return this._innerHTML}this._innerParamLength=0;var i,j,name,value,param1,param2,html,item,s="";var content=this._content.split(" ");for(i=1;i<content.length;i++){name=content[i];value=this["_"+name+"Content"];if(typeof(value)=="function"){param=getParamStr(this._innerParamLength++);this[param]=value;s+=param}else if(typeof(value)=="object"){item=value;html=item.outerHTML().replace(/\{id\}/g,"{id}/"+name);for(j=item._outerParamLength-1;j>=0;j--){param1=getParamStr(j);param2=getParamStr(this._innerParamLength+j);if(param1!=param2){html=html.replace(param1,param2)}this[param2]=item[param1]}this._innerParamLength+=item._outerParamLength;s+=html}else{s+=value}}this._innerHTML=s;return s}catch(error){this.handle(error)}};obj.outerHTML=function(){try{if(this._outerHTML){return this._outerHTML}var innerHTML=this.innerHTML();this._outerParamLength=this._innerParamLength;if(!this._tag){return innerHTML}var i,tmp,name,value,param;var html="<"+this._tag+" id=\"{id}\"";tmp="";var classes=this._classes.split(" ");for(i=1;i<classes.length;i++){name=classes[i];value=this["_"+name+"Class"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}tmp+="active-"+name+"-"+value+" "}if(tmp){html+=" class=\""+tmp+this.$browser+"\""}tmp="";var styles=this._styles.split(" ");for(i=1;i<styles.length;i++){name=styles[i];value=this["_"+name+"Style"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}tmp+=name+":"+value+";"}if(tmp){html+=" style=\""+tmp+"\""}tmp="";var attributes=this._attributes.split(" ");for(i=1;i<attributes.length;i++){name=attributes[i];value=this["_"+name+"Attribute"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}else if(specialAttributes[name]&&!value){value=null}if(value!==null){tmp+=" "+name+"=\""+value+"\""}}html+=tmp;tmp="";var events=this._events.split(" ");for(i=1;i<events.length;i++){name=events[i];value=this["_"+name+"Event"];if(typeof(value)=="function"){value="dispatch(event,this)"}tmp+=" "+name+"=\""+value+"\""}html+=tmp;html+=">"+innerHTML+"</"+this._tag+">";this._outerHTML=html;return html}catch(error){this.handle(error)}};obj.toString=function(){try{var i,s=this._outerHTML;if(!s){s=this.outerHTML()}s=s.replace(/\{id\}/g,this.getId());var max=this._outerParamLength;for(i=0;i<max;i++){var param="{#"+i+"}";var value=this[param]();if(value===null){value="";param=specialParams[i];if(!param){param=getSpecialParamStr(i)}}s=s.replace(param,value)}return s}catch(error){this.handle(error)}};var specialParams=[];function getSpecialParamStr(){return(specialParams[i]=new RegExp("[\\w\\x2D]*=?:?\\x22?\\{#"+i+"\\}[;\\x22]?"))}obj.refresh=function(){try{var element=this.element();if(element){element.outerHTML=this.toString()}}catch(error){this.handle(error)}};obj.$browser="";if(window.__defineGetter__){obj.$browser="gecko"}if(navigator.userAgent.match("Opera")){obj.$browser="opera"}if(navigator.userAgent.match("Konqueror")){obj.$browser="khtml"}if(navigator.userAgent.match("KHTML")){obj.$browser="khtml"}};Active.System.HTML.create();var dispatch=function(event,element){var parts=element.id.split("/");var tag=parts[0].split(".");var obj=Active.System.all[tag[0]];var type="_on"+event.type+"Event";var i;for(i=1;i<tag.length;i++){var params=tag[i].split(":");obj=obj.getTemplate.apply(obj,params)}var target=obj;for(i=1;i<parts.length;i++){target=target.getContent(parts[i]);}if(window.HTMLElement){window.event=event}target[type].call(obj,event);if(window.HTMLElement){window.event=null}return};var mouseover=function(element,name){try{element.className+=" "+name}catch(error){}};var mouseout=function(element,name){try{element.className=element.className.replace(RegExp(" "+name,"g"),"")}catch(error){}};Active.System.Template=Active.System.HTML.subclass();Active.System.Template.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;var _pattern=/^(\w+)\W(.+)$/;var join=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s};obj.getProperty=function(name,a,b,c){if(name.match(_pattern)){var getProperty=join("get",RegExp.$1,"property");if(this[getProperty]){return this[getProperty](RegExp.$2,a,b,c)}}};obj.setProperty=function(name,value,a,b,c){if(name.match(_pattern)){var setProperty=join("set",RegExp.$1,"property");if(this[setProperty]){return this[setProperty](RegExp.$2,value,a,b,c)}}};obj.getModel=function(name){var getModel=join("get",name,"model");return this[getModel]()};obj.setModel=function(name,model){var setModel=join("set",name,"model");return this[setModel](model)};obj.defineTemplate=function(name,template){var ref="_"+name+"Template";var get=join("get",name,"template");var set=join("set",name,"template");var getDefault=join("default",name,"template");var name1="."+name;var name2="."+name+":";this[get]=this[getDefault]=function(index){if(typeof(this[ref])=="function"){return this[ref].call(this,index)}if(this[ref].$owner!=this){this[set](this[ref].clone())}if(typeof(index)=="undefined"){this[ref]._id=this._id+name1}else{this[ref]._id=this._id+name2+index}this[ref].$index=index;return this[ref]};obj[get]=function(a,b,c){return this.$owner[get](a,b,c)};obj[set]=function(template){this[ref]=template;if(template){template.$owner=this}};this[set](template)};obj.getTemplate=function(name){if(name.match(_pattern)){var get=join("get",RegExp.$1,"template");arguments[0]=RegExp.$2;var template=this[get]();return template.getTemplate.apply(template,arguments)}else{get=join("get",name,"template");var i,args=[];for(i=1;i<arguments.length;i++){args[i-1]=arguments[i]}return this[get].apply(this,args)}};obj.setTemplate=function(name,template,index){if(name.match(_pattern)){var get=join("get",RegExp.$1,"template");var n=RegExp.$2;this[get]().setTemplate(n,template,index)}else{var set=join("set",name,"template");this[set](template,index)}};obj.getAction=function(name){return this["_"+name+"Action"]};obj.setAction=function(name,value){this["_"+name+"Action"]=value};obj.action=function(name,source,a,b,c){if(typeof source=="undefined"){source=this}var action=this["_"+name+"Action"];if(typeof(action)=="function"){action.call(this,source,a,b,c)}else if(this.$owner){this.$owner.action(name,source,a,b,c)}}};Active.System.Template.create();Active.System.Control=Active.System.Template.subclass();Active.System.Control.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;var _pattern=/^(\w+)\W(.+)$/;var join=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s};obj.setEvent("oncontextmenu","return false");obj.setEvent("onselectstart","return false");obj.defineModel=function(name){var external="_"+name+"Model";var defineProperty=join("define",name,"property");var definePropertyArray=join("define",name,"property","array");var getProperty=join("get",name,"property");var setProperty=join("set",name,"property");var get={};var set={};var getModel=join("get",name,"model");var setModel=join("set",name,"model");var updateModel=join("update",name,"model");this[defineProperty]=function(property,defaultValue){var _getProperty=join("get",name,property);var _setProperty=join("set",name,property);var _property="_"+join(name,property);var getPropertyMethod=function(){return this[_property]};this[_getProperty]=getPropertyMethod;this[_setProperty]=function(value){if(typeof value=="function"){this[_getProperty]=value}else{if(this[_getProperty]!==getPropertyMethod){this[_getProperty]=getPropertyMethod}this[_property]=value}this[updateModel](property)};this[_setProperty](defaultValue)};this[getProperty]=function(property,a,b,c){try{if(this[external]){return this[external].getProperty(property,a,b,c)}if(!get[property]){get[property]=join("get",name,property)}return this[get[property]](a,b,c)}catch(error){return this.handle(error)}};this[setProperty]=function(property,value,a,b,c){try{if(this[external]){return this[external].setProperty(property,value,a,b,c)}if(!set[property]){set[property]=join("set",name,property)}return this[set[property]](value,a,b,c)}catch(error){return this.handle(error)}};_super[getProperty]=function(property,a,b,c){if(this[external]){return this[external].getProperty(property,a,b,c)}return this.$owner[getProperty](property,a,b,c)};_super[setProperty]=function(property,value,a,b,c){if(this[external]){return this[external].setProperty(property,value,a,b,c)}return this.$owner[setProperty](property,value,a,b,c)};this[definePropertyArray]=function(property,defaultValue){var _getProperty=join("get",name,property);var _setProperty=join("set",name,property);var _getArray=join("get",name,property+"s");var _setArray=join("set",name,property+"s");var _array="_"+join(name,property+"s");var _getCount=join("get",name,"count");var _setCount=join("set",name,"count");var getArrayElement=function(index){return this[_array][index]};var getStaticElement=function(){return this[_array]};var getArray=function(){return this[_array].concat()};var getTempArray=function(){var i,a=[],max=this[_getCount]();for(i=0;i<max;i++){a[i]=this[_getProperty](i)}return a};this[_setProperty]=function(value,index){if(typeof value=="function"){this[_getProperty]=value;this[_getArray]=getTempArray}else if(arguments.length==1){this[_array]=value;this[_getProperty]=getStaticElement;this[_getArray]=getTempArray}else{if(this[_getArray]!=getArray){this[_array]=this[_getArray]()}this[_array][index]=value;this[_getProperty]=getArrayElement;this[_getArray]=getArray}this[updateModel](property)};this[_setArray]=function(value){if(typeof value=="function"){this[_getArray]=value}else{this[_array]=value.concat();this[_getProperty]=getArrayElement;this[_getArray]=getArray;this[_setCount](value.length)}this[updateModel](property)};this[_setProperty](defaultValue)};var proxyPrototype=new Active.System.Model;proxyPrototype.getProperty=function(property,a,b,c){return this._target[getProperty](property,a,b,c)};proxyPrototype.setProperty=function(property,value,a,b,c){return this._target[setProperty](property,value,a,b,c)};var proxy=join("_",name,"proxy");this[getModel]=function(){if(this[external]){return this[external]}if(!this[proxy]){this[proxy]=proxyPrototype.clone();this[proxy]._target=this;this[proxy].$owner=this.$owner}return this[proxy]};_super[setModel]=function(model){this[external]=model;if(model&&!model.$owner){model.$owner=this}};_super[getModel]=function(a,b,c){if(this[external]){return this[external]}return this.$owner[getModel](a,b,c)};this[updateModel]=function(){}};obj.defineProperty=function(name,defaultValue){if(name.match(_pattern)){var defineProperty=join("define",RegExp.$1,"property");if(this[defineProperty]){return this[defineProperty](RegExp.$2,defaultValue)}}};obj.definePropertyArray=function(name,defaultValue){if(name.match(_pattern)){var defineArray=join("define",RegExp.$1,"property","array");if(this[defineArray]){return this[defineArray](RegExp.$2,defaultValue)}}}};Active.System.Control.create();Active.HTML.define=function(name,tag,type){if(!tag){tag=name.toLowerCase()}Active.HTML[name]=Active.System.HTML.subclass();Active.HTML[name].create=function(){};Active.HTML[name].prototype.setTag(tag)};Active.HTML.define("DIV");Active.HTML.define("SPAN");Active.HTML.define("IMG");Active.HTML.define("INPUT");Active.HTML.define("BUTTON");Active.HTML.define("TEXTAREA");Active.HTML.define("TABLE");Active.HTML.define("TR");Active.HTML.define("TD");Active.Templates.Status=Active.System.Template.subclass();Active.Templates.Status.create=function(){var obj=this.prototype;obj.setClass("templates","status");var image=new Active.HTML.SPAN;image.setClass("box","image");image.setClass("image",function(){return this.getStatusProperty("image")});obj.setContent("image",image);obj.setContent("text",function(){return this.getStatusProperty("text")})};Active.Templates.Status.create();Active.Templates.Error=Active.System.Template.subclass();Active.Templates.Error.create=function(){var obj=this.prototype;obj.setClass("templates","error");obj.setContent("title","Error:");obj.setContent("text",function(){return this.getErrorProperty("text")})};Active.Templates.Error.create();Active.Templates.Text=Active.System.Template.subclass();Active.Templates.Text.create=function(){var obj=this.prototype;obj.setClass("templates","text");obj.setContent("text",function(){return this.getItemProperty("text")});obj.setEvent("onclick",function(){this.action("click")})};Active.Templates.Text.create();Active.Templates.Link=Active.System.Template.subclass();Active.Templates.Link.create=function(){var obj=this.prototype;obj.setTag("a");obj.setClass("templates","link");obj.setAttribute("href",function(){return this.getItemProperty("link")});var image=new Active.HTML.SPAN;image.setClass("box","image");image.setClass("image",function(){return this.getItemProperty("image")});obj.setContent("image",image);obj.setContent("text",function(){return this.getItemProperty("text")});obj.setEvent("onclick",function(){this.action("click")})};Active.Templates.Link.create();Active.Templates.Item=Active.System.Template.subclass();Active.Templates.Item.create=function(){var obj=this.prototype;obj.setClass("templates","item");obj.setClass("box","normal");var box=new Active.HTML.DIV;var image=new Active.HTML.SPAN;box.setClass("box","item");image.setClass("box","image");image.setClass("image",function(){return this.getItemProperty("image")});obj.setContent("box",box);obj.setContent("box/image",image);obj.setContent("box/text",function(){return this.getItemProperty("text")})};Active.Templates.Item.create();Active.Templates.List=Active.System.Template.subclass();Active.Templates.List.create=function(){var obj=this.prototype;obj.setTag("");obj.defineTemplate("item",new Active.Templates.Text);var getItemProperty=function(property){return this.$owner.getDataProperty(property,this.$index)};var setItemProperty=function(property,value){return this.$owner.setDataProperty(property,value,this.$index)};obj.getItemTemplate=function(index,temp){var template=this.defaultItemTemplate(index);if(!temp){temp=[]}if(!temp.selected){temp.selected=[];var i,values=this.getSelectionProperty("values");for(i=0;i<values.length;i++){temp.selected[values[i]]=true}template.getItemProperty=getItemProperty;template.setItemProperty=setItemProperty;template.setClass("list","item")}if(temp.selected[index]){template=template.clone();template.$index="";template.setClass("selection",true);template.$index=index}return template};var html=function(){var i,result=[],temp=[],items=this.getItemsProperty("values");for(i=0;i<items.length;i++){result[i]=this.getItemTemplate(items[i],temp).toString()}return result.join("")};obj.setContent("html",html)};Active.Templates.List.create();Active.Templates.Row=Active.Templates.List.subclass();Active.Templates.Row.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setTag("div");obj.setClass("templates","row");obj.setClass("grid","row");obj.getDataProperty=function(property,i){return this.$owner.getDataProperty(property,this.$index,i)};obj.setDataProperty=function(property,value,i){return this.$owner.setDataProperty(property,value,this.$index,i)};obj.getItemsProperty=function(property){return this.getColumnProperty(property)};obj.getSelectionProperty=function(property){return this.getDummyProperty(property)};obj.getRowProperty=function(property){return this.$owner.getItemsProperty(property,this.$index)};var getItemProperty=function(property){return this.$owner.getDataProperty(property,this.$index)};var setItemProperty=function(property,value){return this.$owner.setDataProperty(property,value,this.$index)};var getColumnProperty=function(property){return this.$owner.getColumnProperty(property,this.$index)};obj.getItemTemplate=function(i){if(!this._itemTemplates){this._itemTemplates=[]}if(this._itemTemplates[i]){this._itemTemplates[i]._id=this._id+".item:"+i;return this._itemTemplates[i]}if(typeof(i)=="undefined"){return _super.getItemTemplate.call(this)}var template=_super.getItemTemplate.call(this,i).clone();template.$index=i;template.setClass("column",i);this._itemTemplates[i]=template;return template};obj.setItemTemplate=function(template,i){template.getItemProperty=getItemProperty;template.setItemProperty=setItemProperty;template.getColumnProperty=getColumnProperty;template.setClass("row","cell");template.setClass("grid","column");if(typeof(i)=="undefined"){return _super.setItemTemplate.call(this,template);}};var selectRow=function(event){if(event.shiftKey){return this.action("selectRangeOfRows")}if(event.ctrlKey){return this.action("selectMultipleRows")}this.action("selectRow")};obj.setEvent("onclick",selectRow)};Active.Templates.Row.create();Active.Templates.Header=Active.Templates.Item.subclass();Active.Templates.Header.create=function(){var obj=this.prototype;obj.setClass("templates","header");obj.setClass("column",function(){return this.$index});obj.setClass("sort",function(){return this.getSortProperty("index")!=this.$index?"none":this.getSortProperty("direction")});obj.setAttribute("title",function(){return this.getItemProperty("tooltip")});var div=new Active.HTML.DIV;div.setClass("box","resize");div.setEvent("onmousedown",function(){this.action("startColumnResize")});div.setContent("html","&nbsp;");obj.setContent("div",div);obj.setEvent("onmousedown",function(){});var sort=new Active.HTML.SPAN;sort.setClass("box","sort");obj.setContent("box/sort",sort);};Active.Templates.Header.create();Active.Templates.Box=Active.System.Template.subclass();Active.Templates.Box.create=function(){var obj=this.prototype;obj.setClass("templates","box");obj.setClass("box","normal");var box=new Active.HTML.DIV;box.setClass("box","item");obj.setContent("box",box)};Active.Templates.Box.create();Active.Templates.Scroll=Active.System.Template.subclass();Active.Templates.Scroll.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setTag("");var Pane=Active.HTML.DIV;var Box=Active.Templates.Box;var data=new Pane;var top=new Pane;var left=new Pane;var corner=new Box;var fill=new Box;var scrollbars=new Pane;var space=new Pane;data.setClass("scroll","data");top.setClass("scroll","top");left.setClass("scroll","left");corner.setClass("scroll","corner");fill.setClass("scroll","fill");scrollbars.setClass("scroll","bars");space.setClass("scroll","space");obj.setContent("data",data);obj.setContent("top",top);obj.setContent("left",left);obj.setContent("corner",corner);obj.setContent("scrollbars",scrollbars);obj.setContent("data/html",function(){return this.getMainTemplate()});obj.setContent("top/html",function(){return this.getTopTemplate()});obj.setContent("left/html",function(){return this.getLeftTemplate()});obj.setContent("scrollbars/space",space);obj.setContent("top/fill",fill);var scroll=function(){var scrollbars=this.getContent("scrollbars").element();var data=this.getContent("data").element();var top=this.getContent("top").element();var left=this.getContent("left").element();var x=scrollbars.scrollLeft;var y=scrollbars.scrollTop;data.scrollLeft=x;top.scrollLeft=x;data.scrollTop=y;left.scrollTop=y;scrollbars=null;data=null;top=null;left=null};scrollbars.setEvent("onscroll",scroll);var resize=function(){if(this._sizeAdjusted){this._sizeAdjusted=false;this.timeout(adjustSize,100);var data=this.getContent("data").element();var scrollbars=this.getContent("scrollbars").element();var top=this.getContent("top").element();var left=this.getContent("left").element();data.runtimeStyle.width="100%";top.runtimeStyle.width="100%";data.runtimeStyle.height="100%";left.runtimeStyle.height="100%";scrollbars.runtimeStyle.zIndex=1000;data=null;scrollbars=null;top=null;left=null}};scrollbars.setEvent("onresize",resize);obj._sizeAdjusted=true;var adjustSize=function(){var data=this.getContent("data").element();var scrollbars=this.getContent("scrollbars").element();var top=this.getContent("top").element();var left=this.getContent("left").element();var space=this.getContent("scrollbars/space").element();if(data){if(data.scrollHeight){space.runtimeStyle.height=data.scrollHeight>data.offsetHeight?data.scrollHeight:0;space.runtimeStyle.width=data.scrollWidth>data.offsetWidth?data.scrollWidth:0;var y=scrollbars.clientHeight;var x=scrollbars.clientWidth;data.runtimeStyle.width=x;top.runtimeStyle.width=x;data.runtimeStyle.height=y;left.runtimeStyle.height=y;top.scrollLeft=data.scrollLeft;left.scrollTop=data.scrollTop;scrollbars.runtimeStyle.zIndex=0}else{this.timeout(adjustSize,500)}data.className=data.className+""}data=null;scrollbars=null;top=null;left=null;space=null;this._sizeAdjusted=true};obj.setAction("adjustSize",function(){this.timeout(adjustSize,500)});obj.toString=function(){this.timeout(adjustSize);return _super.toString.call(this)}};Active.Templates.Scroll.create();Active.Controls.Grid=Active.System.Control.subclass();Active.Controls.Grid.create=function(){var obj=this.prototype;obj.setClass("controls","grid");obj.defineTemplate("layout",new Active.Templates.Scroll);obj.defineTemplate("main",function(){switch(this.getStatusProperty("code")){case"":return this.getDataTemplate();case"error":return this.getErrorTemplate();default:return this.getStatusTemplate()}});obj.defineTemplate("data",new Active.Templates.List);obj.defineTemplate("left",new Active.Templates.List);obj.defineTemplate("top",new Active.Templates.List);obj.defineTemplate("status",new Active.Templates.Status);obj.defineTemplate("error",new Active.Templates.Error);obj.defineTemplate("row",new Active.System.Template);obj.defineTemplate("column",new Active.System.Template);obj.getColumnTemplate=function(i){return this.getTemplate("data/item/item",i)};obj.setColumnTemplate=function(template,i){this.setTemplate("data/item/item",template,i)};obj.getRowTemplate=function(i){return this.getTemplate("data/item",i)};obj.setRowTemplate=function(template,i){this.setTemplate("data/item",template,i)};obj.setTemplate("data/item",new Active.Templates.Row);obj.setTemplate("left/item",new Active.Templates.Item);obj.setTemplate("top/item",new Active.Templates.Header);obj.defineModel("row");obj.defineRowProperty("count",function(){return this.getDataProperty("count")});obj.defineRowProperty("index",function(i){return i});obj.defineRowProperty("order",function(i){return i});obj.defineRowPropertyArray("text",function(i){return this.getRowOrder(i)+1});obj.defineRowPropertyArray("image","none");obj.defineRowPropertyArray("value",function(i){return i});obj.defineModel("column");obj.defineColumnProperty("count",0);obj.defineColumnProperty("index",function(i){return i});obj.defineColumnProperty("order",function(i){return i});obj.defineColumnPropertyArray("text",function(i){return"Column "+i});obj.defineColumnPropertyArray("image","none");obj.defineColumnPropertyArray("value",function(i){return i});obj.defineColumnPropertyArray("tooltip","");obj.defineModel("data");obj.defineDataProperty("count",0);obj.defineDataProperty("index",function(i){return i});obj.defineDataProperty("text","");obj.defineDataProperty("image","none");obj.defineDataProperty("link","");obj.defineDataProperty("value",function(i,j){var text=""+this.getDataText(i,j);var value=Number(text.replace(/[,%\$]/gi,"").replace(/\((.*)\)/,"-$1"));return isNaN(value)?text.toLowerCase()+" ":value});obj.defineModel("items");obj.defineModel("dummy");obj.defineDummyProperty("count",0);obj.defineDummyPropertyArray("value",-1);obj.defineModel("selection");obj.defineSelectionProperty("index",-1);obj.defineSelectionProperty("multiple",false);obj.defineSelectionProperty("count",0);obj.defineSelectionPropertyArray("value",0);obj.defineModel("sort");obj.defineSortProperty("index",-1);obj.defineSortProperty("direction","none");obj.defineModel("status");obj.defineStatusProperty("code",function(){var data=this.getDataModel();if(!data.isReady()){return"loading"}if(!this.getRowProperty("count")){return"nodata"}return""});obj.defineStatusProperty("text",function(){switch(this.getStatusProperty("code")){case"loading":return"Loading data,please wait...";case"nodata":return"Nenhum registro disponível.";default:return""}});obj.defineStatusProperty("image",function(){switch(this.getStatusProperty("code")){case"loading":return"loading";default:return"none"}});obj.defineModel("error");obj.defineErrorProperty("code",0);obj.defineErrorProperty("text","");obj.getLeftTemplate=function(){var template=this.defaultLeftTemplate();template.setDataModel(this.getRowModel());template.setItemsModel(this.getRowModel());template.setSelectionModel(this.getDummyModel());return template};obj.getTopTemplate=function(){var template=this.defaultTopTemplate();template.setDataModel(this.getColumnModel());template.setItemsModel(this.getColumnModel());template.setSelectionModel(this.getDummyModel());return template};obj.getDataTemplate=function(){var template=this.defaultDataTemplate();template.setDataModel(this.getDataModel());template.setItemsModel(this.getRowModel());return template};obj.setContent(function(){return this.getLayoutTemplate()});obj.setColumnHeaderHeight=function(height){var layout=this.getTemplate("layout");layout.getContent("top").setStyle("height",height);layout.getContent("corner").setStyle("height",height);layout.getContent("left").setStyle("padding-top",height);layout.getContent("data").setStyle("padding-top",height)};obj.setRowHeaderWidth=function(width){var layout=this.getTemplate("layout");layout.getContent("left").setStyle("width",width);layout.getContent("corner").setStyle("width",width);layout.getContent("top").setStyle("padding-left",width);layout.getContent("data").setStyle("padding-left",width)};var setSelectionIndex=obj.setSelectionIndex;obj.setSelectionIndex=function(index){setSelectionIndex.call(this,index);this.setSelectionValues([index]);var row=this.getTemplate("row",index);var data=this.getTemplate("layout").getContent("data");var left=this.getTemplate("layout").getContent("left");var scrollbars=this.getTemplate("layout").getContent("scrollbars");try{var top,padding=parseInt(data.element().currentStyle.paddingTop);if(data.element().scrollTop>row.element().offsetTop-padding){top=row.element().offsetTop-padding;left.element().scrollTop=top;data.element().scrollTop=top;scrollbars.element().scrollTop=top}if(data.element().offsetHeight+data.element().scrollTop<row.element().offsetTop+row.element().offsetHeight){top=row.element().offsetTop+row.element().offsetHeight-data.element().offsetHeight;left.element().scrollTop=top;data.element().scrollTop=top;scrollbars.element().scrollTop=top}}catch(error){}};var setSelectionValues=obj.setSelectionValues;obj.setSelectionValues=function(array){var i,current=this.getSelectionValues();setSelectionValues.call(this,array);for(i=0;i<current.length;i++){this.getRowTemplate(current[i]).refreshClasses()}for(i=0;i<array.length;i++){this.getRowTemplate(array[i]).refreshClasses()}this.action("selectionChanged")};var selectRow=function(src){this.setSelectionProperty("index",src.getItemProperty("index"))};var selectMultipleRows=function(src){if(!this.getSelectionProperty("multiple")){return this.action("selectRow",src)}var index=src.getItemProperty("index");var selection=this.getSelectionProperty("values");for(var i=0;i<selection.length;i++){if(selection[i]==index){selection.splice(i,1);i=-1;break}}if(i!=-1){selection.push(index)}this.setSelectionProperty("values",selection);setSelectionIndex.call(this,index);this.getRowTemplate(index).refreshClasses();this.action("selectionChanged")};var selectRangeOfRows=function(src){if(!this.getSelectionProperty("multiple")){return this.action("selectRow",src)}var previous=this.getSelectionProperty("index");var index=src.getItemProperty("index");var row1=Number(this.getRowProperty("order",previous));var row2=Number(this.getRowProperty("order",index));var start=row1>row2?row2:row1;var count=row1>row2?row1-row2:row2-row1;var i,selection=[];for(i=0;i<=count;i++){selection.push(this.getRowProperty("value",start+i))}this.setSelectionProperty("values",selection);setSelectionIndex.call(this,index);this.getRowTemplate(index).refreshClasses();this.action("selectionChanged")};obj.setAction("selectRow",selectRow);obj.setAction("selectMultipleRows",selectMultipleRows);obj.setAction("selectRangeOfRows",selectRangeOfRows);obj.sort=function(index,direction){var model=this.getModel("row");if(model.sort){return model.sort(index,direction)}var a={};var rows=this.getRowProperty("values");if(direction&&direction!="ascending"){direction="descending"}else{direction="ascending"}if(this.getSortProperty("index")!=index){for(var i=0;i<rows.length;i++){a[rows[i]]=this.getDataProperty("value",rows[i],index)}rows.sort(function(x,y){return a[x]>a[y]?1:(a[x]==a[y]?0:-1)});if(direction=="descending"){rows.reverse()}}else if(this.getSortProperty("direction")!=direction){rows.reverse()}this.setRowProperty("values",rows);this.setSortProperty("index",index);this.setSortProperty("direction",direction)};obj.setAction("columnSort",function(src){var i=src.getItemProperty("index");var d=(this.getSortProperty("index")==i)&&(this.getSortProperty("direction")=="ascending")?"descending":"ascending";window.status="Sorting...";this.sort(i,d);this.refresh();this.timeout(function(){window.status=""})});var _getRowOrder=function(i){return this._rowOrders[i]};var _setRowValues=obj.setRowValues;obj.setRowValues=function(values){_setRowValues.call(this,values);var i,max=values.length,orders=[];for(i=0;i<max;i++){orders[values[i]]=i}this._rowOrders=orders;this.getRowOrder=_getRowOrder};obj._kbSelect=function(delta){var index=this.getSelectionProperty("index");var order=this.getRowProperty("order",index);var count=this.getRowProperty("count");var newOrder=Number(order)+delta;if(newOrder<0){newOrder=0}if(newOrder>count-1){newOrder=count-1}if(delta==-100){newOrder=0}if(delta==100){newOrder=count-1}var newIndex=this.getRowProperty("value",newOrder);this.setSelectionProperty("index",newIndex)};obj.setAction("up",function(){this._kbSelect(-1)});obj.setAction("down",function(){this._kbSelect(+1)});obj.setAction("pageUp",function(){this._kbSelect(-10)});obj.setAction("pageDown",function(){this._kbSelect(+10)});obj.setAction("home",function(){this._kbSelect(-100)});obj.setAction("end",function(){this._kbSelect(+100)});var kbActions={38:"up",40:"down",33:"pageUp",34:"pageDown",36:"home",35:"end"};var onkeydown=function(event){var action=kbActions[event.keyCode];if(action){this.action(action);event.returnValue=false;event.cancelBubble=true}};obj.setEvent("onkeydown",onkeydown);function onmousewheel(event){var scrollbars=this.getTemplate("layout").getContent("scrollbars");var delta=scrollbars.element().offsetHeight*event.wheelDelta/480;scrollbars.element().scrollTop-=delta;event.returnValue=false;event.cancelBubble=true}obj.setEvent("onmousewheel",onmousewheel)};Active.Controls.Grid.create();

