var loadedScripts = new Array(); var ajax_loaders_count = 0; var ajax_loaders = new Array(); Function.prototype.bind = function(object) { var method = this return function() { return method.apply(object, arguments) } } var ajax_request = function () {}; ajax_request.prototype = { req : null, target : null, url : null, callback : null, settings : { }, ajax_request: function () { }, getTransport : function () { this.req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); }, get : function (what,where) { if(this.target = document.getElementById(where)) { this.getTransport(); this.req.onreadystatechange = this.complete.bind(this); this.req.open("GET",what,true); this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); this.req.send(null); ajax_loaders_count++; this.updateIndicator(); } }, getByCallback : function(what,callback) { this.callback = callback; this.getTransport(); this.req.onreadystatechange = this.jsonCallback.bind(this); this.req.open("GET",what,true); this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); this.req.send(null); ajax_loaders_count++; this.updateIndicator(); }, postByCallback : function(what,callback,data) { this.callback = callback; this.getTransport(); this.req.onreadystatechange = this.jsonCallback.bind(this); this.req.open("POST",what,true); this.req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); this.req.send(data); ajax_loaders_count++; this.updateIndicator(); }, post : function (what,where,data) { if(this.target = document.getElementById(where)) { this.getTransport(); this.req.onreadystatechange = this.complete.bind(this); this.req.open("POST",what,true); this.req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); this.req.send(data); ajax_loaders_count++; this.updateIndicator(); } }, complete : function () { if(this.req.readyState == 4) { if(this.target) { this.target.innerHTML = ' '; this.target.innerHTML = this.req.responseText; this.processScripts(); } this.clean(); ajax_loaders_count--; this.updateIndicator(); } }, jsonCallback : function () { if(this.req.readyState == 4) { var obj = new Function("","return " + this.req.responseText); var myObj = null; if(myObj = obj()) { this.callback(myObj); } this.clean(); ajax_loaders_count--; this.updateIndicator(); } }, processScripts: function () { var scripts = this.target.getElementsByTagName('script'); var i=0; for(i=0;i'; span.getElementsByTagName('script')[0].src = scripts[i].getAttribute('src'); loadedScripts[scripts[i].getAttribute('src')] = 1; } else { eval(scripts[i].text); } } }, updateIndicator : function () { var ind = null; if(ind = document.getElementById('loadingIndicator')) { if(ajax_loaders_count > 0) { ind.style.display = ''; } else { ind.style.display = 'none'; } } }, clean : function() { this.req.onreadystatechange = function () {}; this.req = null; }, setForm : function(formel) { var _sFormData = ''; var oForm = formel; var oElement, elName, elValue; // iterate over the form elements collection to construct the // label-value pairs. for (var i=0; i