/* // XML Loading Function // Author: Lomanto, Paulo H. // Last Change: 2005-12-27 // Current Version: 1.08 // Last Revisions // 1.08: self.xml now is not required (for simple GET operations) // 1.07: Added support for IE 5.0 and Safari // Checks if get or post file exists */ var xml = function() { var self = this; this.file = null; this.ret = null; this.xmli = null; this.xmlDoc = null; this.transf = null; this.debug = false; this.returnType = 'xml'; var xmlhttp = null; this.load = _load; function _load() { if (self.file && self.ret) { try { self.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e1) { try { self.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { if (!self.xmlhttp && typeof XMLHttpRequest!='undefined') { self.xmlhttp = new XMLHttpRequest(); } } } if (self.xmlhttp != null) { self.xmlhttp.onreadystatechange = _testReadyStateSend; if (this.transf == null){ this.transf = 'GET'; } self.xmlhttp.open(self.transf,self.file,true); if (this.transf == 'POST'){ self.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } self.xmlhttp.send(self.xmli); } } else { return false; } } function _testReadyStateSend() { if (self.xmlhttp.readyState == 4) { if (self.xmlhttp.status == '200') { _evalInternalGet(); } else { //alert('Página não encontrada'); return false; } } } function _evalReturn() { var retFunc = ''; if (typeof(self.ret) == 'function') { eval('new self.ret'); } } function _evalInternalGet() { self.xmlDoc = (self.returnType == 'xml' ? self.xmlhttp.responseXML : self.xmlhttp.responseText); if (self.debug){ var container = document.getElementsByTagName("BODY"); if (container.length > 0){ var newDiv = document.createElement("DIV"); newDiv.setAttribute("style", "position:absolute; width:640; left:150; top:300; background: #FFFFFF; border: 2px solid #000000"); var txt = document.createTextNode(self.xmlhttp.responseText); newDiv.appendChild(txt); container[0].appendChild(newDiv); } } _evalReturn(); } }