kAjax={
  error:0,
  
  errorFnc:function(e){
    
  },
  
  request:function(url,myfunc,obj){
    kAjax.error=0;
    var http_request=false;
    if(window.XMLHttpRequest){
      http_request=new XMLHttpRequest();
      if(http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
    }else if(window.ActiveXObject){
      try{ 
        http_request=new ActiveXObject("Msxml2.XMLHTTP");
      }catch(e){
        try{ http_request=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
      }
    }
    if(!http_request) return false;
    http_request.onreadystatechange=function(){ 
      if(http_request.readyState==4){
        if(http_request.status==200){ if(myfunc!=null) myfunc(http_request,obj); }
        else{ kAjax.error=1; kAjax.errorFnc(http_request.status); }
      } 
    };
    http_request.open('GET',url,true);
    http_request.send(null);
  },
  
  eval: function(json){
    var d;
    if(json=="") json="[]";
    eval("d="+json+";");
    return d;
  }
};

kAjaxSubmit={
  frame: function(c,to){
    var n = 'f' + Math.floor(Math.random() * 99999);
    var d = document.getElementById(to);
    d.innerHTML = '<iframe style="display:none;" src="about:blank" id="'+n+'" name="'+n+'" onload="kAjaxSubmit.loaded(\''+n+'\',\''+to+'\')"></iframe>';
    if(c && typeof(c.after)=='function') document.getElementById(n).onComplete=c.after;
    return n;
  },

  form: function(f,name){
    f.setAttribute('target', name);
  },

  submit: function(f,to,c){
    kAjaxSubmit.form(f, kAjaxSubmit.frame(c,to));
    var doSubmit=true;
    if(c && typeof(c.before)=='function') doSubmit=c.before();
    if(doSubmit==null || doSubmit==true) f.submit();
  },
  
  loaded: function(id,to){
    var i = document.getElementById(id);
    if(i.contentDocument) var d=i.contentDocument;
    else if(i.contentWindow) var d=i.contentWindow.document;
    else var d=window.frames[id].document;
          
    if(d.location.href=="about:blank") return;
    if(typeof(i.onComplete)=='function') i.onComplete(d.body.innerHTML);
  }

};    

