<!--
//xmlhttp和xmldom对象
var DooneXHTTP = null;
var DooneXDOM = null;
var DooneContainer = null;
var DooneShowError = false;
var DooneShowWait = false;
var DooneErrCon = "";
var DooneErrDisplay = "下载数据失败";
var DooneWaitDisplay = "正在下载数据...";

//获取指定ID的元素
function $(eid){
	return document.getElementById(eid);
}

//gcontainer 是保存下载完成的内容的容器
//mShowError 是否提示错误信息
//DooneShowWait 是否提示等待信息
//mErrCon 服务器返回什么字符串视为错误
//mErrDisplay 发生错误时显示的信息
//mWaitDisplay 等待时提示信息
//默认调用 DooneAjax('divid',false,false,'','','')

function DooneAjax(gcontainer,mShowError,mShowWait,mErrCon,mErrDisplay,mWaitDisplay){

DooneContainer = gcontainer;
DooneShowError = mShowError;
DooneShowWait = mShowWait;
if(mErrCon!="") DooneErrCon = mErrCon;
if(mErrDisplay!="") DooneErrDisplay = mErrDisplay;
if(mErrDisplay=="x") DooneErrDisplay = "";
if(mWaitDisplay!="") DooneWaitDisplay = mWaitDisplay;


//post或get发送数据的键值对
this.keys = Array();
this.values = Array();
this.keyCount = -1;

//http请求头
this.rkeys = Array();
this.rvalues = Array();
this.rkeyCount = -1;

//请求头类型
this.rtype = 'text';

//初始化xmlhttp
if(window.ActiveXObject){//IE6、IE5
   try { DooneXHTTP = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }
   if (DooneXHTTP == null) try { DooneXHTTP = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }
}
else{
	 DooneXHTTP = new XMLHttpRequest();
}

//增加一个POST或GET键值对
this.AddKey = function(skey,svalue){
	this.keyCount++;
	this.keys[this.keyCount] = skey;
	this.values[this.keyCount] = escape(svalue);
};

//增加一个Http请求头键值对
this.AddHead = function(skey,svalue){
	this.rkeyCount++;
	this.rkeys[this.rkeyCount] = skey;
	this.rvalues[this.rkeyCount] = svalue;
};

//清除当前对象的哈希表参数
this.ClearSet = function(){
	this.keyCount = -1;
	this.keys = Array();
	this.values = Array();
	this.rkeyCount = -1;
	this.rkeys = Array();
	this.rvalues = Array();
};


DooneXHTTP.onreadystatechange = function(){
	//在IE6中不管阻断或异步模式都会执行这个事件的
	if(DooneXHTTP.readyState == 4){
    if(DooneXHTTP.status == 200){
       if(DooneXHTTP.responseText!=DooneErrCon && DooneXHTTP.responseText!=''){
         DooneContainer.innerHTML = DooneXHTTP.responseText;
       }else{
       	 if(DooneShowError) DooneContainer.innerHTML = DooneErrDisplay;
       }
       DooneXHTTP = null;
    }else{ if(DooneShowError) DooneContainer.innerHTML = DooneErrDisplay; }
  }else{ if(DooneShowWait) DooneContainer.innerHTML = DooneWaitDisplay; }
};

//检测阻断模式的状态
this.BarrageStat = function(){
	if(DooneXHTTP==null) return;
	if(typeof(DooneXHTTP.status)!=undefined && DooneXHTTP.status == 200)
  {
     if(DooneXHTTP.responseText!=DooneErrCon && DooneXHTTP.responseText!=''){
         DooneContainer.innerHTML = DooneXHTTP.responseText;
     }else{
       	if(DooneShowError) DooneContainer.innerHTML = DooneErrDisplay;
     }
  }
};

//发送http请求头
this.SendHead = function(){
	if(this.rkeyCount!=-1){ //发送用户自行设定的请求头
  	for(;i<=this.rkeyCount;i++){
  		DooneXHTTP.setRequestHeader(this.rkeys[i],this.rvalues[i]); 
  	}
  }
　if(this.rtype=='binary'){
  	DooneXHTTP.setRequestHeader("Content-Type","multipart/form-data");
  }else{
  	DooneXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  }
};

//用Post方式发送数据
this.SendPost = function(purl){
	var pdata = "";
	var i=0;
	this.state = 0;
	DooneXHTTP.open("POST", purl, true); 
	this.SendHead();
  if(this.keyCount!=-1){ //post数据
  	for(;i<=this.keyCount;i++){
  		if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
  		else pdata += "&"+this.keys[i]+'='+this.values[i];
  	}
  }
  DooneXHTTP.send(pdata);
};

//用GET方式发送数据
this.SendGet = function(purl){
	var gkey = "";
	var i=0;
	this.state = 0;
	if(this.keyCount!=-1){ //get参数
  	for(;i<=this.keyCount;i++){
  		if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
  		else gkey += "&"+this.keys[i]+'='+this.values[i];
  	}
  	if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
  	else  purl = purl + '&' + gkey;
  }
	DooneXHTTP.open("GET", purl, true); 
	this.SendHead();
  DooneXHTTP.send(null);
};

//用GET方式发送数据，阻塞模式
this.SendGet2 = function(purl){
	var gkey = "";
	var i=0;
	this.state = 0;
	if(this.keyCount!=-1){ //get参数
  	for(;i<=this.keyCount;i++){
  		if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
  		else gkey += "&"+this.keys[i]+'='+this.values[i];
  	}
  	if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
  	else  purl = purl + '&' + gkey;
  }
	DooneXHTTP.open("GET", purl, false); 
	this.SendHead();
  DooneXHTTP.send(null);
  //firefox中直接检测XHTTP状态
  this.BarrageStat();
};

//用Post方式发送数据
this.SendPost2 = function(purl){
	var pdata = "";
	var i=0;
	this.state = 0;
	DooneXHTTP.open("POST", purl, false); 
	this.SendHead();
  if(this.keyCount!=-1){ //post数据
  	for(;i<=this.keyCount;i++){
  		if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
  		else pdata += "&"+this.keys[i]+'='+this.values[i];
  	}
  }
  DooneXHTTP.send(pdata);
  //firefox中直接检测XHTTP状态
  this.BarrageStat();
};


} // End Class DooneAjax

//初始化xmldom
function InitXDom(){
  if(DooneXDOM!=null) return;
  var obj = null;
  if (typeof(DOMParser) != "undefined") { // Gecko、Mozilla、Firefox
    var parser = new DOMParser();
    obj = parser.parseFromString(xmlText, "text/xml");
  } else { // IE
    try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }
    if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
  }
  DooneXDOM = obj;
};

-->
