// JavaScript Document
//qyajax
function qyajax(container)
{
var qyXHTTP=null;  //xmlhttp
var qyErrorMsg="下载数据失败";  //Ϣ
var qyWaitMsg="正在下载数据，请等待...";   //ȴϢ
///ʼXMLHTTP
if(window.ActiveXObject) //IE5+
{
   try
   {
	   qyXHTTP=new ActiveXObject("Msxml2.XMLHTTP");
   } 
   catch(e){}
   if(qyXHTTP==null)
   {
	   try
	   {
		   qyXHTTP=new ActiveXObject("Microsoft.XMLHTTP");
	   }catch(e){}
   }
}
else//other
{
	qyXHTTP=new XMLHttpRequest();
}
qyXHTTP.onreadystatechange=function(){
	if(qyXHTTP.readyState==4)
	{
		if(qyXHTTP.status==200)
		{
	         document.getElementById(container).innerHTML=qyXHTTP.responseText;	
		}else
		{
			 document.getElementById(container).innerHTML=qyErrorMsg;
		}
	}else
	{
		document.getElementById(container).innerHTML=qyWaitMsg;	
	}
};
//ģʽ״̬
this.BarrageStat = function(){
	if(qyXHTTP==null) return;
	if(typeof(qyXHTTP.status)!=undefined && qyXHTTP.status == 200)
  {
     if(qyXHTTP.responseText!=DedeErrCon){
         document.getElementById(container).innerHTML = qyXHTTP.responseText;
     }else
	 {
		 document.getElementById(container).innerHTML = qyErrorMsg;
     }
  }
};
//ͷ
this.headtype="text"; //ͷͣĬΪtext,ѡΪbinary
this.sendHead=function()
{
	if(this.headtype=="binary") //
	{
		 qyXHTTP.setRequestHeader("Content-Type","multipart/form-data");
	}
	else
	{
	     qyXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	}
};
//postget͵Ĳֵ
this.sendkeys=Array();
this.sendvalues=Array();
this.sendcount=-1;
//һPOSTGET
this.AddSend=function(key,value)
{
	this.sendcount++;
	this.sendkeys[this.sendcount]=key;
	this.sendvalues[this.sendcount]=value;
};
//ݼֵ
this.clearSend=function()
{
	this.sendkeys=Array();
	this.sendvalues=Array();
	this.sendcount=-1;
};
//GETʽ
this.sendGet=function(geturl)
{
	this.state=0;
	var postdata="";
	var i=0;
	if(this.sendcount!=-1)
	{
	    for(i;i<=this.sendcount;i++)
		{
			if(postdata=="")
			{
			    postdata=this.sendkeys[i]+"="+this.sendvalues[i];	
			}
			else
			{
				postdata+="&"+this.sendkeys[i]+"="+this.sendvalues[i];	
			}
		}
		if(geturl.indexOf("?")==-1)
		{
		    geturl+="?"+postdata;
		}
		else
		{
		    geturl+="&"+postdata;	
		}
	}
	qyXHTTP.open("GET",geturl,true);
	this.sendHead();
	qyXHTTP.send(null);
};
//GETʽݣģʽ
this.sendGet2=function(geturl)
{
	this.state=0;
	var postdata="";
	var i=0;
	if(this.sendcount!=-1)
	{
	    for(i;i<=this.sendcount;i++)
		{
			if(postdata=="")
			{
			    postdata=this.sendkeys[i]+"="+this.sendvalues[i];	
			}
			else
			{
				postdata+="&"+this.sendkeys[i]+"="+this.sendvalues[i];	
			}
		}
		if(geturl.indexOf("?")==-1)
		{
		    geturl+="?"+postdata;
		}
		else
		{
		    geturl+="&"+postdata;	
		}
	}
	qyXHTTP.open("GET",geturl,true);
	this.sendHead();
	qyXHTTP.send(null);
	this.BarrageSta();
};
//POSTʽ
this.sendPost=function(posturl)
{
	this.state=0;
	var postdata="";
	var i=0;
	if(this.sendcount!=-1)
	{
	    for(i;i<=this.sendcount;i++)
		{
			if(postdata=="")
			{
			    postdata=this.sendkeys[i]+"="+this.sendvalues[i];	
			}
			else
			{
				postdata+="&"+this.sendkeys[i]+"="+this.sendvalues[i];	
			}
		}
	}
	qyXHTTP.open("POST",geturl,true);
	this.sendHead();
	qyXHTTP.send(postdata);
};
//POSTʽ  ģʽ
this.sendPost2=function(posturl)
{
	this.state=0;
	var postdata="";
	var i=0;
	if(this.sendcount!=-1)
	{
	    for(i;i<=this.sendcount;i++)
		{
			if(postdata=="")
			{
			    postdata=this.sendkeys[i]+"="+this.sendvalues[i];	
			}
			else
			{
				postdata+="&"+this.sendkeys[i]+"="+this.sendvalues[i];	
			}
		}
	}
	qyXHTTP.open("POST",geturl,true);
	this.sendHead();
	qyXHTTP.send(postdata);
	this.BarrageSta();
};
//end function
}
