function opretREQ(){
      try{
         req = new XMLHttpRequest();
      }
      catch(e){
         try{
            req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
         }
         catch(e){
            try{
               req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
               req = false;
            }
         }
      }
      return req;
}

function anmodGET(url, query, mitreq){
   mitRand = parseInt(Math.random()*99999999);
   geturl = url+'?'+query+'&rand='+mitRand;
   req.open("GET", geturl,true);
   //req.open("GET", "libtest.php",true);
   req.send(null);
}

function anmodPOST(url, query, req){
   req.open("POST", url, true);
   req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
   req.send(query);
}

function doCallback(callback, item){
   eval(callback + '(item)');
}

function doAjax(url, query, callback, reqtype, getxml, vent){
   var mitreq = opretREQ();
   mitreq.onreadystatechange = function(){
      if(mitreq.readyState == 4){
         if(mitreq.status == 200){
            var item = mitreq.responseText;
            if(getxml == 1){
               item = mitreq.responseXML;
            }
            doCallback(callback, item);
         }
            document.getElementById("loading").className = 'loading-invisible';
      }else{
         if(vent){
            document.getElementById("loading").className = 'loading-visible';
         }
      }
   }
   if(reqtype == 'post'){
      anmodPOST(url, query, mitreq);
   }else{
      anmodGET(url, query, mitreq);
   }
}


