String.prototype.trim = function()
{ return this.replace(/(^\s*)|(\s*$)/g, "");}
/**//*
url-loading object and a request queue built on top of it
*/

/**//* namespacing object */
var net=new Object();

net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;


/**//*--- content loader object for cross-browser requests ---*/
net.ContentLoader=function(url,onload,onerror,method,params,contentType){
  this.req=null;
  this.onload=onload;
  this.onerror=(onerror) ? onerror : this.defaultError;
  this.loadXMLDoc(url,method,params,contentType);
}

net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){
  if (!method){
    method="GET";
  }
  if (!contentType && method=="POST"){
   contentType='application/x-www-form-urlencoded;charset=GBK';
	//contentType='application/x-www-form-urlencoded';
  }
  if (window.XMLHttpRequest){
    this.req=new XMLHttpRequest();
  } else if (window.ActiveXObject){
  
	  	//add try catch;
		 	try {
			    this.req = new ActiveXObject("Msxml2.XMLHTTP");
				}catch (e1){
						try {
							this.req = new ActiveXObject("Microsoft.XMLHTTP");					
							} catch (e2){
					}
			 }
    //this.req=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (this.req){
    try{
      var loader=this;
      this.req.onreadystatechange=function(){
        net.ContentLoader.onReadyState.call(loader);
      }
      this.req.open(method,url,true);
      if (contentType){
        this.req.setRequestHeader('Content-Type', contentType);
      }
      this.req.send(params);
    }catch (err){
      this.onerror.call(this);
    }
  }
}


net.ContentLoader.onReadyState=function(){
  var req=this.req;
  var ready=req.readyState;
  if (ready==net.READY_STATE_COMPLETE){
    var httpStatus=req.status;
    if (httpStatus==200 || httpStatus==0){
      this.onload.call(this);
    }else{
      this.onerror.call(this);
    }
  }
}

net.ContentLoader.prototype.defaultError=function(){
  alert("error fetching data!"
    +"\n\nreadyState:"+this.req.readyState
    +"\nstatus: "+this.req.status
    +"\nheaders: "+this.req.getAllResponseHeaders());
}



/****************************************************************
//下面是未采用net.js封装的xmlhttp应用;如果用到xmlhttp的地方较多采用net.js较好
****************************************************************/
/*
function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
} 
function postmessage(thisform)
{
	//return true;
	
　//获取接受返回信息层
　//var msg = $("msg");

　//获取表单对象和用户信息值

　//接收表单的URL地址
	var url=thisform.action;

    
　//需要POST的值，把每个变量都通过&来联接
var params="";    
    for(var i=0;i<thisform.elements.length;i++){//encodeURIComponent
     params+=(thisform.elements[i].name+"="+encodeURIComponent(thisform.elements[i].value.trim()));	
     if(i!=(thisform.elements.length-1))params+="&";
    }  

　//实例化Ajax
　var ajax = InitAjax();
　
　//通过Post方式打开连接
　ajax.open("POST", url, true); 

　//定义传输的文件HTTP头信息
　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=GBK"); 

　//发送POST数据
  params=(params);
　ajax.send(params);

　//获取执行状态
　ajax.onreadystatechange = function() { 
　　//如果执行状态成功，那么就把返回信息写到指定的层里
　　if (ajax.readyState == 4 && ajax.status == 200) { 
　　　alert(ajax.responseText); 
　　} 
　} 
  return false;
} 
*/