
xmlhttp = new Array();

function ajaxload(url, params, id, oncomplete)
{
  if(!id){id=randstr();};
  xmlhttp[id]='';
  // code for Mozilla, etc.
  if (window.XMLHttpRequest)
    {
    xmlhttp[id]=new XMLHttpRequest()
    }
  // code for IE
  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(getElem(id)){getElem(id).innerHTML = xmlhttp[id].responseText;}
        if(oncomplete){setTimeout(oncomplete,100);};
    }
  }
  xmlhttp[id].open('POST', url, true)
  xmlhttp[id].setRequestHeader('Content-Type','application/x-www-form-urlencoded')
  xmlhttp[id].send(params)
}

function randstr(len,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;
}