var progressBar; if (document.all) { navigator.userAgent.toLowerCase().indexOf('msie 5') != -1 ? is_ie5 = true : is_ie5 = false; is_ie = true; is_moz1_6 = false; is_mozilla = false; is_ns4 = false; } else if (document.getElementById) { navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false; is_ie = false; is_ie5 = false; is_mozilla = true; is_ns4 = false; } else if (document.layers) { is_ie = false; is_ie5 = false is_moz1_6 = false; is_mozilla = false; is_ns4 = true; } /****************************************** Connector Class *************************************************/ // Constructor function cConnector() { this.requests = new Array(); this.oxmlhttp = null; this.isVisibleBar = false; this.tid = 0; this.progressBar = null; this.oldX = 0; this.oldY = 0; this.updateVersion = ""; } cConnector.prototype.buildBar = function() { var div = document.getElementById('divProgressBar'); if(! div) { div = document.createElement("DIV"); div.style.visibility = "hidden"; div.style.width = "103px"; div.id = 'divProgressBar'; div.align = "center"; div.innerHTML = '  '+get_lang('loading')+'... '; div.style.background = "#cc4444"; div.style.position = 'fixed'; div.style.top = '0px'; div.style.right = '0px'; document.body.appendChild(div); if(is_ie) { var elem = document.all[div.id]; elem.style.position="absolute"; var root = document.body; var posX = elem.offsetLeft-root.scrollLeft; var posY = elem.offsetTop-root.scrollTop; root.onscroll = function() { elem.style.right = '0px'; elem.style.top = (posY + root.scrollTop) + "px"; }; } } } cConnector.prototype.hideProgressBar = function () { var div = document.getElementById('divProgressBar'); div.style.visibility = 'hidden'; this.isVisibleBar = false; } cConnector.prototype.showProgressBar = function(){ var div = document.getElementById('divProgressBar'); if (! div){ connector.buildBar(); connector.showProgressBar(); return; } div.style.visibility = 'visible'; this.isVisibleBar = true; } function XMLTools() { this.path = ""; } var connector = new cConnector(); function _xml() { var a = false; if ( document.implementation.createDocument ) a = document.implementation.createDocument("", "", null); else if ( ActiveXObject ) a = new ActiveXObject("Msxml2.DOMDocument"); if ( arguments.length == 1 && typeof arguments[0] == 'string' ) a.appendChild(a.createElement(arguments[0])); return a; } XMLTools.prototype = { "__DEBUG__" : false, "__DEFAULT_URI__" : 'inc/controller.php?action=', "__HTTP__" : null, "__MODE__" : 'X', "__RETURN_MODE_DEFAULT__" : 'JSON', "__RETURN_MODE__" : false, "__THREADS__" : [], "http" : function() { try { this.__HTTP__ = new XMLHttpRequest(); this.__HTTP__.overrideMimeType('text/xml'); } catch (e) { try { this.__HTTP__ = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e1) { try { this.__HTTP__ = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e2) { this.__HTTP__ = null; } } } }, "request" : function(pTarget, pMethod, pHandler, pData) { if ( typeof pHandler != 'function' || this.__THREADS__[pTarget] ) return false; connector.showProgressBar(); var __this = this; var __pTarget = pTarget this.http(); var __HTTP__ = this.__HTTP__; this.__THREADS__[pTarget] = pHandler; var __handler = function () { try { if ( __HTTP__.readyState == 4 ) { switch ( __HTTP__.status ) { case 200: var data = ( __this.__MODE__ == 'X' ) ? __HTTP__.responseXML : __HTTP__.responseText; var handler = __this.__THREADS__[__pTarget]; delete __this.__THREADS__[__pTarget]; handler(data, __pTarget); break; /* [case : status 200] */ case 404: alert('Page Not Found!'); break; /* [case : status 404] */ default: } } } catch(e) { if ( __this.__DEBUG__ ) alert("request : #2\n\n" + e) } } try { var target = this.__DEFAULT_URI__ + pTarget; if ( this.__RETURN_MODE__ ) { target += '&returnMode=' + this.__RETURN_MODE__; this.__RETURN_MODE__ = false; } else target += '&returnMode=' + this.__RETURN_MODE_DEFAULT__; if ( pMethod == 'POST' ) { __HTTP__.open("POST", target, true); __HTTP__.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); __HTTP__.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate'); __HTTP__.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0'); __HTTP__.setRequestHeader('Pragma', 'no-cache'); __HTTP__.onreadystatechange = __handler; pData = ( pData ) ? pData : null ; } else { __HTTP__.open("GET", target, true); __HTTP__.onreadystatechange = __handler; pData = null; } __HTTP__.send(pData); } catch(e) { if ( this.__DEBUG__ ) alert("request : #1\n\n" + e) } setTimeout('connector.hideProgressBar()',100); return true; }, "load" : function( pFile ) { connector.showProgressBar(); var data = null; if ( document.implementation.createDocument ) data = document.implementation.createDocument("", "", null); else data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument"); data.async = false; data.load(pFile); setTimeout('connector.hideProgressBar()',100); return data; }, "ParseXmlXsl" : function( _xmlDoc, xslForm ) { var xslWin = false //if( !xslWin ) xslWin = this.load(this.path + 'xsl/' + xslForm + '?' + Date.parse(new Date)); var a = document.createElement('div'); if ( window.ActiveXObject ) { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(_xmlDoc); } else { var parser = new DOMParser(); var xmlDoc = parser.parseFromString( _xmlDoc, "text/xml"); } a.innerHTML = this.transform(xmlDoc,xslForm ); return a; }, "transform" : function( pXML, pXSL ) { try { var fragment = null; if ( window.XSLTProcessor ) { var xslProc = new XSLTProcessor(); xslProc.importStylesheet(pXSL); fragment = xslProc.transformToFragment(pXML, document); // para retornar valor igual ao ie. var aux = document.createElement("div"); aux.appendChild(fragment); fragment = aux.innerHTML; } else { var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate"); xslTemplate.stylesheet = pXSL; var myXslProc = xslTemplate.createProcessor(); myXslProc.input = pXML; myXslProc.transform(); fragment = myXslProc.output; } return fragment; }catch(e) { alert("transform\n\n" + e + "\n\n" + e.description); } } }; function cExecuteForm(url, form, handler){ connector.showProgressBar(); var iframe_el = document.getElementById('nullFrame'); if (!iframe_el) { iframe_el = document.createElement('IFRAME'); iframe_el.id = "nullFrame"; } iframe_el.style.width = "0px"; iframe_el.style.height = "0px"; iframe_el.style.border = '0px'; iframe_el.name = "nullFrame"; iframe = document.body.appendChild(iframe_el); iframe_el.setAttribute('onload', 'javascript:'+handler+'()'); form.target = "nullFrame"; form.submit(); } function cExecute(requestURL,handler,methmd){ var AjaxRequest = function () { Ajax = false; if (window.XMLHttpRequest) //Gecko Ajax = new XMLHttpRequest(); else if (window.ActiveXObject) //Other nav. try { Ajax = new ActiveXObject("Msxml12.XMLHTTP"); } catch (e) { Ajax = new ActiveXObject("Microsoft.XMLHTTP"); } } var responseRequest = function (){ if (Ajax.readyState == 4) if (Ajax.status == 200) handler(Ajax.responseText); else alert("Erro temporario de conexão"); } AjaxRequest(); if (!Ajax){ alert("Erro ao conectar-se"); return; } Ajax.onreadystatechange = responseRequest; if (typeof(method) == 'undefined') method = 'GET'; Ajax.open(method, requestURL, true); Ajax.send(null); } var XMLTools = new XMLTools(); var xtools = new XTools;