/* The tAJAX template */ /* base 64 encoding nodig voor de libary */ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ; function isset(varname) { if(typeof( window[ varname ] ) != "undefined") return true; else return false; } function encode64(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while (i < input.length); return output; } function decode64(inp) { var out = ""; //This is the output var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded var i = 0; //Position counter // remove all characters that are not A-Z, a-z, 0-9, +, /, or = var base64test = /[^A-Za-z0-9\+\/\=]/g; if (base64test.exec(inp)) { //Do some error checking alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" + "Expect errors in decoding."); } inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { //Here�s the decode loop. //Grab 4 bytes of encoded content. enc1 = keyStr.indexOf(inp.charAt(i++)); enc2 = keyStr.indexOf(inp.charAt(i++)); enc3 = keyStr.indexOf(inp.charAt(i++)); enc4 = keyStr.indexOf(inp.charAt(i++)); //Heres the decode part. There�s really only one way to do it. chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; //Start to output decoded content out = out + String.fromCharCode(chr1); if (enc3 != 64) { out = out + String.fromCharCode(chr2); } if (enc4 != 64) { out = out + String.fromCharCode(chr3); } //now clean out the variables used chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = ""; } while (i < inp.length); //finish off the loop //Now return the decoded values. return out; } /* wat hulp functietjes*/ function getFirstAncestorByClassName(target,className) { var parent = target; while (parent = parent.parentNode) { if (hasClassName(parent,className)) { return parent; } } return null; } /* een eval functie om de functie uit te voeren*/ function readyhandle(tclass) { eval('t = '+tclass); t.ready(); } var xhttppageencoding=''; function TAjax() { this.Debug =0; this.Version ='1'; this.xmlhttp=false; this.Sourcefile='empty.html'; this.onReadyresponsecommand = 'this.doExecute(this.xmlhttp.responseText)'; this.onFailresponsecommand = 'this.ReportFail(this.xmlhttp.responseText)'; this.cn=''; this.doctosend=''; //if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') { // this.xmlhttp = new XMLHttpRequest(); //} if (window.XMLHttpRequest) { // Non-IE browsers this.xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } // alert("text/html; charset="+this.getCharset()+""); } TAjax.prototype.getCharset = function() { if(xhttppageencoding=='') { //head = window.document.firstChild.firstChild.innerHTML heads = document.getElementsByTagName('head'); head = heads[0].innerHTML; start = head.indexOf('charset=')+8 stop1 = head.indexOf('"', start) stop2 = head.indexOf('>', start) stop3 = head.indexOf("'", start) stop = head.length if (stop1 < stop && stop1 > 0) stop = stop1 if (stop2 < stop && stop2 > 0) stop = stop2 if (stop3 < stop && stop3 > 0) stop = stop3 xhttppageencoding = head.substr(start, stop-start) } else { } return xhttppageencoding; } TAjax.prototype.doRequest = function() { var url url = this.Sourcefile; //alert(this.cn+'->'+url); this.xmlhttp.open("GET", url,true); eval('this.xmlhttp.onreadystatechange= function() {\nreadyhandle(\''+this.cn+'\');\n }'); this.xmlhttp.send(null); } TAjax.prototype.doPost = function() { var url url = this.Sourcefile; //alert(this.cn+'->'+url); this.xmlhttp.open("POST", url,true); eval('this.xmlhttp.onreadystatechange= function() {\nreadyhandle(\''+this.cn+'\');\n }'); this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.getCharset()); this.xmlhttp.send(this.doctosend); } TAjax.prototype.ready = function() { if (this.xmlhttp.readyState==4) { eval(this.onReadyresponsecommand); } } TAjax.prototype.doExecute = function(source) { eval(source); } TAjax.prototype.ReportFail = function(source) { if(this.Debug==1) { alert('Request failed:'+this.xmlhttp.getAllResponseHeaders()+'\n===========\n'+source); } } function deleteresponse(nr) { if(TA[nr].deleted!='yes') { delete(TA[nr].xmlhttp); TA[nr].deleted='yes'; } } function getresponse(nr) { if(typeof TA[nr]=='object') { TA[nr].doctosend=''; if(typeof env== "undefined") { setTimeout('deleteresponse('+nr+')',2000); } return TA[nr].xmlhttp.responseText; } else { return ''; } } function getresponsexml(nr) { if(typeof TA[nr]=='object') { TA[nr].doctosend=''; if(typeof env == "undefined") { setTimeout('deleteresponse('+nr+')',2000); } return TA[nr].xmlhttp.responseXML; } else { return ''; } } if(typeof loaderbar=='object'){loaderbar.loadedfile('ajax.js');} //[PACKSEP]