var UserAgent=navigator.userAgent.toLowerCase(),Browser={version:(UserAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],MobileSafari:!!UserAgent.match(/Apple.*Mobile.*Safari/),Safari:/webkit/.test(UserAgent),Opera:/opera/.test(UserAgent),IE:/msie/.test(UserAgent)&&!/opera/.test(UserAgent),Mozilla:/mozilla/.test(UserAgent)&&!/(compatible|webkit)/.test(UserAgent)}; function recursiveDelete(a){var b=a.childNodes.length;if(b>0)for(var c=0;c<b;c++){recursiveDelete(a.childNodes[c]);try{a.parentNode.removeChild(a)}catch(d){}}else try{a.parentNode.removeChild(a)}catch(f){}} var Menu={ativo:null,show:function(a,b){location.href="../"+b;return false}},DOM={_callback:[],_isReady:false,_push:function(a){DOM._callback.push(a)},_pop:function(){var a,b;a=0;for(b=DOM._callback.length;a<b;a++)DOM._callback[a]()},Ready:function(a){DOM._push(a);if(!DOM._isReady)if(Browser.Mozilla)document.addEventListener("DOMContentLoaded",DOM._pop,false);else if(Browser.IE&&window==top)(function(){try{document.documentElement.doScroll("left")}catch(b){setTimeout(arguments.callee,0);return}DOM._pop()})(); else window.onload=DOM._pop;DOM._isReady=true}},Seletor={query:function(a){var b=[];Array.prototype.push.apply(b,Seletor.makeList(a));return b},makeList:function(a){var b=[];if(a!=null){var c=a.length;if(c==null||a.split||a.setInterval||a.call)b[0]=a;else for(;c;)b[--c]=a[c]}return b},apply:function(a,b){for(var c=0,d=a.length;c<d;c++)b.call(a[c])},push:function(a,b){var c=null,d=b.length;for(c=0;c<d;c++)a.push(b.pop())}},Context={}; Context.Item=function(a,b){var c=document.createElement("li");c.appendChild(document.createTextNode(a));c.onmouseover=function(){this.className="selected"};c.onmouseout=function(){this.className=""};this.make=function(){var d=this;if(b!=null&&b!=undefined)c.onclick=c.onmousedown=function(f){f=Event.getMouseButton(f);this.className="";if(f==1)try{Context.Stack.clear()}finally{try{b.call(d)}catch(e){alert(e)}}}};this.getItem=function(){return c}}; Context.Group=function(){var a=document.createElement("ul");a.className="group";var b=[];this.getGroup=function(){return a};this.addMenu=function(c,d){c=new Context.Item(c,d);b.push(c);return c.getItem()};this.make=function(){for(var c=0;c<b.length;c++){var d=b[c];d.make.call(this);a.appendChild(d.getItem())}}}; Context.Menu=function(){var a=null,b=true,c=[];this.create=function(d){d=Event.getMouseLocation(d);Context.Stack.removeLast();a=document.createElement("div");a.className="x-context";a.style.position="absolute";a.style.top=d.y+"px";a.style.left=d.x+"px";document.body.appendChild(a);d=null;for(var f=0;f<c.length;f++){d=c[f];d.make.call(this);a.appendChild(d.getGroup())}};this.createGroup=function(d){d=new Context.Group(d);if(b){HTMLElement.addClass(d.getGroup(),"firstGroup");b=false}c.push(d);return d}; this.deletar=function(){var d=false;try{document.body.removeChild(a);delete a;a=null;d=true}catch(f){d=false}return d}};Context.Stack={trInContext:null,menu:null,removeLast:function(){try{Context.Stack.clear()}catch(a){}},clear:function(){Context.Stack.menu.deletar()}}; var Selecionar={lastClicked:[],removeClickedFlag:true,clear:function(a){HTMLElement.removeClass(a,"x-onContext");HTMLElement.removeClass(a,"isChecked");Selecionar.getCbox(a).checked=false},clearAll:function(a){var b=null,c=Selecionar.lastClicked.length;try{for(b=0;b<c;b++)Selecionar.clear(a[Selecionar.lastClicked[b]])}catch(d){}},getCbox:function(a){return a.getElementsByTagName("input")[0]},active:function(a,b){HTMLElement.addClass(a,"x-onContext");HTMLElement.addClass(a,"isChecked");Selecionar.getCbox(a).checked= true;Selecionar.lastClicked.push(b)},setAction:function(a,b,c){var d=a[b],f=Selecionar.getCbox(d);d.style.cursor="default";if(Browser.IE)d.onselectstart=function(){return false};else d.onmousedown=function(){return false};d.oncontextmenu=d.onclick=f.onclick=function(e){var h=Event.getModifiers(e),j=false,g=false;if(h=="100")j=true;else if(h=="001")g=true;if(this.nodeName.toLowerCase()=="tr"){if(g)Selecionar.removeClickedFlag=false;else if(j&&Selecionar.lastClicked.length>0){h=Selecionar.lastClicked.pop(); g=null;Selecionar.clearAll(a);if(b>h)for(g=h;g<=b;g++)Selecionar.active(a[g],g);else for(g=h;g>=b;g--)Selecionar.active(a[g],g)}if(!j){e=Event.fix(e);if(Selecionar.removeClickedFlag&&(e.type.toLowerCase()!="contextmenu"||!HTMLElement.haveClass(this,"isChecked")))Selecionar.clearAll(a);if(HTMLElement.haveClass(this,"isChecked"))e.type.toLowerCase()!="contextmenu"&&Selecionar.clear(this);else Selecionar.active(this,b);Selecionar.removeClickedFlag=true}}else if(!j)Selecionar.removeClickedFlag=false; Context.Stack.menu=c;if(e.type.toLowerCase()=="contextmenu"){Context.Stack.removeLast();Context.Stack.trInContext=this;c.create.call(this,e);return false}};document.onclick=function(){Context.Stack.removeLast()};d.onmouseover=function(){HTMLElement.addClass(this,"x-onContext")};d.onmouseout=function(){HTMLElement.haveClass(this,"isChecked")||HTMLElement.removeClass(this,"x-onContext")}},selectAllFlag:false,Install:function(a,b,c){var d=0;Seletor.apply(a,function(){(function(f){Selecionar.setAction(a, f,b)})(d);d++});Seletor.apply(c,function(){this.onclick=function(){if(Selecionar.selectAllFlag)Selecionar.clearAll(a);else for(var f=0,e=a.length;f<e;f++)Selecionar.active(a[f],f);Context.Stack.removeLast();Selecionar.selectAllFlag=!Selecionar.selectAllFlag;f=0;for(e=c.length;f<e;f++)if(c[f].nodeName.toLowerCase()=="input"&&c[f].getAttribute("type").toLowerCase()=="checkbox")c[f].checked=Selecionar.selectAllFlag}})}},HTMLElement={haveClass:function(a,b){return(new RegExp("(^|\\s+)"+b+"(\\s+|$)","g")).test(a.className)}, addClass:function(a,b){HTMLElement.haveClass(a,b)||(a.className+=(a.className?" ":"")+b)},removeClass:function(a,b){a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},getStyle:function(a,b){var c=null;try{c=document.defaultView.getComputedStyle(a,null)[b]}catch(d){try{c=a.currentStyle[b]}catch(f){c=a.style[b]}}return c},setStyle:function(a,b,c){if(b=="opacity")if(Browser.IE){c=parseInt(c*100);c="alpha(opacity="+c+")";b="filter"}a.style[b]= c},getElementPosition:function(a){function b(k){c(Number(HTMLElement.getStyle(k,"borderLeftWidth")),Number(HTMLElement.getStyle(k,"borderTopWidth")))}function c(k,n){d+=parseInt(k,10)||0;f+=parseInt(n,10)||0}var d=0,f=0,e;if(a!=null&&a!=undefined){var h=a.parentNode,j=a,g=a.offsetParent;e=a.ownerDocument;var m=Browser.Safari&&parseInt(Browser.version)<522&&!/adobeair/i.test(UserAgent),l=HTMLElement.getStyle(a,"position")=="fixed";if(a.getBoundingClientRect){a=a.getBoundingClientRect();c(a.left+Math.max(e.documentElement.scrollLeft, e.body.scrollLeft),a.top+Math.max(e.documentElement.scrollTop,e.body.scrollTop));c(-e.documentElement.clientLeft,-e.documentElement.clientTop)}else{for(c(a.offsetLeft,a.offsetTop);g;){c(g.offsetLeft,g.offsetTop);if(Browser.Mozilla&&!/^t(able|d|h)$/i.test(g.tagName)||Browser.Safari&&!m)b(g);if(!l&&HTMLElement.getStyle(g,"position")=="fixed")l=true;j=/^body$/i.test(g.tagName)?j:g;g=g.offsetParent}for(;h&&h.tagName&&!/^body|html$/i.test(h.tagName);){/^inline|table.*$/i.test(HTMLElement.getStyle(h,"display"))|| c(-h.scrollLeft,-h.scrollTop);Browser.Mozilla&&HTMLElement.getStyle(h,"overflow")!="visible"&&b(h);h=h.parentNode}if(m&&(l||HTMLElement.getStyle(j,"position")=="absolute")||Browser.Mozilla&&HTMLElement.getStyle(j,"position")!="absolute")c(-e.body.offsetLeft,-e.body.offsetTop);l&&c(Math.max(e.documentElement.scrollLeft,e.body.scrollLeft),Math.max(e.documentElement.scrollTop,e.body.scrollTop))}e={y:f,x:d}}return e}},Event={fix:function(a){try{if(!a)throw"Evento recebido n\u00e3o suportado pelo Browser"; }catch(b){a=null;try{a=window.event}catch(c){a=null}}finally{return a}},getMouseButton:function(a){a=Event.fix(a);var b=0;return b=!a.which&&a.button?a.button&1?1:a.button&2?3:a.button&4?2:0:a.which},getScroll:function(){var a=document.documentElement,b=document.body;return{x:(a&&a.scrollLeft||b&&b.scrollLeft||0)-(a.clientLeft||0),y:(a&&a.scrollTop||b&&b.scrollTop||0)-(a.clientTop||0)}},getMousePosition:function(a){a=Event.fix(a);return{x:a.clientX,y:a.clientY}},getMouseLocation:function(a){a=Event.getMousePosition(a); var b=Event.getScroll();return{x:b.x+a.x,y:b.y+a.y}},getModifiers:function(a){a=Event.fix(a);return(a.shiftKey?"1":"0")+(a.altKey?"1":"0")+(a.ctrlKey?"1":"0")},register:function(a,b,c){var d=a["on"+b];a["on"+b]=d!=null&&d!=undefined?function(){d.call();c.call()}:function(){c.call()}}},Action={getCheckedBox:function(a){var b=null,c=null;if(a==undefined||a==null)a=document.formList;b=Seletor.query(a["context[]"]);total=b.length;for(i=0;i<total;i++)if(b[i].checked==true){c=b[i];break}return c},inserir:function(a){location.href= a==undefined||a==null?"edit.php":a},editar:function(a,b){var c=null;c=null;if(b==undefined||b==null)b=document.formList;c=Action.getCheckedBox(b);if(c==null){alert("Selecione algum item para editar");return false}else c=c.value;location.href=a==undefined||a==null?"edit.php?id="+c:a+"&id="+c},deletar:function(a,b,c){if(b==undefined||b==null)b=document.formList;if(Action.getCheckedBox(b)==null){alert("Selecione algum item para deletar");return false}if(c==undefined||c==null)c="Tem certeza que deseja deletar os itens selecionados?"; if(confirm(c)){if(a==undefined||a==null)a="delete.php";b.action=a;b.submit()}else return false}};function Dialog(a,b,c){var d=document.createElement("div");d.className="x-dialog "+b;d.innerHTML=a;document.body.appendChild(d);c||(c=7E3);setTimeout(function(){d.style.display="none";document.body.removeChild(d)},c)};
