
var xmlhttp = new Array();

function ajaxload(url, params, id, onComplete){
 //object = {url,params,onStart,onComplete}
 id = id ? id : randstr() ;
 xmlhttp[id]='';
 
 if(window.XMLHttpRequest){ xmlhttp[id] = new XMLHttpRequest();}
 else if(window.ActiveXObject){ xmlhttp[id] = new ActiveXObject("Microsoft.XMLHTTP");}

 xmlhttp[id].onreadystatechange = function(){
  if (xmlhttp[id].readyState==4 && (xmlhttp[id].status==200 || window.location.href.indexOf("http")==-1)){
   if(id && document.getElementById(id)){ document.getElementById(id).innerHTML = xmlhttp[id].responseText;}
   if(onComplete){setTimeout(onComplete,10);};
   }
  }
 xmlhttp[id].open('POST', url, true);
 xmlhttp[id].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlhttp[id].send(params);
 }
 
function ajaxeval(url, params){
 id = randstr() ;
 xmlhttp[id]='';
 
 if(window.XMLHttpRequest){ xmlhttp[id] = new XMLHttpRequest();}
 else if(window.ActiveXObject){ xmlhttp[id] = new ActiveXObject("Microsoft.XMLHTTP");}

 xmlhttp[id].onreadystatechange = function(){
  if (xmlhttp[id].readyState==4 && (xmlhttp[id].status==200 || window.location.href.indexOf("http")==-1)){
   var json = eval(xmlhttp[id].responseText);
   }
  }
 xmlhttp[id].open('POST', url, true);
 xmlhttp[id].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 xmlhttp[id].send(params);
 }

function randstr(len,chars){
 var chars = typeof(chars)=='undefined' || !chars || chars=='' ? "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz" : chars ;
 if(!len){len = 8;};
 var randomstring = '';
 for(var i=0; i<len; i++){
  var rnum = Math.floor(Math.random() * chars.length);
  randomstring += chars.substring(rnum,rnum+1);
  }
 return randomstring;
 }