function connection() { var obj = null; var extra_handler = null; var idle = false; var c = this; try{ if(_BROWSER['firefox']) obj = new XMLHttpRequest(); else obj = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Unable to estabilish real-time connection."); return 0; } this.post = function (url,data,async) { //if(idle) return (window.status="Connection is idle"); //idle = true; obj.open("POST",url,async); AssignProcedure(); obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;'); obj.setRequestHeader("Cache-Control","no-cache"); obj.send(data); } AssignProcedure = function () { if(_BROWSER['firefox']){ obj.onload = function () { try{ switch(obj.readyState) { case 4:idle = false; } if(extra_handler) extra_handler(obj); }catch(e){} } obj.onerror = function(){ window.status = "Connection: Unexpected status."; } } else obj.onreadystatechange = function () { try{ switch(obj.readyState) { case 4: idle = false; } if(extra_handler) extra_handler(obj,c); }catch(e){} } } this.x_handler = function(handler) { extra_handler = handler; } this.get = function (url,async) { if(idle) return (window.status="Connection is idle"); idle = true; obj.open("GET",url,async); AssignProcedure(); obj.setRequestHeader("Cache-Control","no-cache"); obj.send(null); } this.abort = function(){ obj.abort(); } this.obj = obj; this.getheader = function(name){ return obj.getRequestHeader(name); } this.setheader = function(name,value){ return obj.setRequestHeader(name,value); } }