
if(typeof(Artres)=="undefined"){Artres={};}

Artres.JsonRequest = {
  init: function(url, params) {
    this.url    = url;
    this.params = $H(params);
  },
 
  send: function() {
    var script;
    var head = $$("head")[0];
    function sweep() {
      setTimeout(function() { 
        head.removeChild(script)
        script.onerror = script.onload = null;
      }, 5000);
    }
 
    head.appendChild(script = Object.extend(this.createScript(), {
      onerror: sweep,
      onload: sweep
    }));
  },
  createScript: function() {
    return Object.extend(document.createElement("script"), {
      src:  this.url + "?" + this.params.toQueryString(),
      type: "text/javascript"
    });
  }
};