var $xml_http=new Array();var $xh_id=1;
function ajax_init(){
   $xh=false;
   if(window.XMLHttpRequest) $xh=new XMLHttpRequest();
   if(!$xh && window.ActiveXObject) $xh=new ActiveXObject("Microsoft.XMLHTTP");
   if(!$xh) return false;
	 $xml_http[$xh_id]=$xh;
   $xh_id++;
	 return $xh_id-1;
}
function ajax_do($res_id,$url,$handler,$method,$params,$target){
   if(!$xml_http[$res_id]) return false;
   $xml_http[$res_id].open($method,$url,true);
   $xml_http[$res_id].onreadystatechange=function(){
	    if ($xml_http[$res_id].readyState==4 && $xml_http[$res_id].status==200) $handler($xml_http[$res_id],$target);
	 }
   if($method=='POST'){
      $xml_http[$res_id].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      $xml_http[$res_id].setRequestHeader("Content-length",$params.length);
      $xml_http[$res_id].setRequestHeader("Connection", "close");
      $xml_http[$res_id].send($params);
			return true;
   }else{
	    $send='';
			if(window.XMLHttpRequest) $send=null;
      $xml_http[$res_id].send($send);
      return true;
   }
   return false;
}
