//判断iE
    var userAgent = navigator.userAgent.toLowerCase();
    var is_opera = (userAgent.indexOf('opera') != -1);
    var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
    var is_webtv = (userAgent.indexOf('webtv') != -1);
    var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
    var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
    var is_ie7 = ((is_ie) && (userAgent.indexOf('msie 7.') != -1));
    var is_moz = ((navigator.product == 'Gecko') && (!is_saf));
    var is_kon = (userAgent.indexOf('konqueror') != -1);
    var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
    var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
    var is_mac = (userAgent.indexOf('mac') != -1);
//取得字符串的字节长度
function strlen(str)
{
	var i=0,len=0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255 || str.charCodeAt(i)<0)
		{len+=2;}
		else
		{len++;}
	}
	return len;
}
//写字版复制粘贴
function copyToClipboard(txt) {  
    if(window.clipboardData)  
    {  
        window.clipboardData.clearData();  
        window.clipboardData.setData("Text", txt);  
    }  
    else if(navigator.userAgent.indexOf("Opera") != -1)  
    {  
        window.location = txt;  
    }  
    else if (window.netscape)  
    {  
        try {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
        }  
        catch (e)  
        {  
            alert("!!被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");  
        }  
        var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);  
        if (!clip)  
            return;  
        var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);  
        if (!trans)  
            return;  
        trans.addDataFlavor("text/unicode");  
        var str = new Object();  
        var len = new Object();  
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);  
        var copytext = txt;  
        str.data = copytext;  
        trans.setTransferData("text/unicode",str,copytext.length*2);  
        var clipid = Components.interfaces.nsIClipboard;  
        if (!clip)  
            return false;  
        clip.setData(trans,null,clipid.kGlobalClipboard);  
        }  
    return true;  
}

//
function Confirm(n) {return window.confirm (n)}
function afirm(n) {return window.confirm (n)}
function Trim(s){
	return s.replace(/(^\s*)|(\s*$)/g, "");
}
function checknumber(data)
{
  var datastr = data;
  if (datastr.search(/\D/gi) != -1)
	  {return false;}
  if (datastr.search(/\S/gi) == -1)
	  {return false;}
  return true;
}
function $(s){ return document.getElementById(s);}
function gname(name){return document.getElementsByTagName?document.getElementsByTagName(name):new Array()}
function hide(s){$(s).style.display=$(s).style.display=="none"?"":"none";}
//判断输入的内容不能为空
function checkcoAndsn(form)
{
    var inputs =form.getElementsByTagName("INPUT");
    var textarea =form.getElementsByTagName("TEXTAREA");
    var objary =new Array();   
    for(i=0;i<textarea.length;i++)
    {   
        if(textarea[i].title=="必填"&&textarea[i].value=="")
        {
            textarea[i].focus();
            textarea[i].value="内容不能为空";
            textarea[i].select();
           objary.push(textarea[i]);
        } 
    }
    for(i=0;i<inputs.length;i++)
    {   
        if(inputs[i].title=="必填"&&inputs[i].value=="")
        {
            inputs[i].focus();
            inputs[i].value="内容不能为空";
            inputs[i].select();
            objary.push(inputs[i]);
        }
       if(inputs[i].title=="必填整数"&&(inputs[i].value==""||checknumber(inputs[i].value)==false))
        {
            inputs[i].focus();
            inputs[i].value="必填整数";
            inputs[i].select();
            objary.push(inputs[i]);
        }
    }
      if(objary.length==0)
            return true;
      else 
        return false;
}
function oAjax( url ,callback)
{
    try{
        this.HttpRequest = null;
        this.Debug  = false;
        this.Url = url;
        this.ContentType = "text/xml;charset=gb2312";
        this.HttpRequest = this.createXMLHttpRequest();
        this.yibu=true;
        if(callback==null)
            yibu=false;
        if ( this.HttpRequest == null )
        {
            this._debug("XMLHttpRequest create failure!");
            return;
        }

        var xhReq = this.HttpRequest;
        if(callback!=null){
        xhReq.onreadystatechange = function (){
                    oAjax._OnReadyStateChange( xhReq,callback );
            }
         }

    } catch(e){
       this._debug( "unknow err: " + e.message );
    }
}

/*
 * Get URL resource
 */
oAjax.prototype.Get = function() {

    this.SetContentType( "text/html;charset=gb2312" );
    this._get();
}

/*
 * Post data to the server
 */
oAjax.prototype.Post = function( arrKey, arrValue ) {

    var data = '';
    this.SetContentType( "application/x-www-form-urlencoded;charset=gb2312" );
    for( i = 0; i < arrKey.length; i ++)
    {
        data += "&" + escape(arrKey[i]) + "=" + escape(arrValue[i]);
		//data += "&" + arrKey[i] + "=" + arrValue[i];
    }
	//document.write(data);
    data = data.replace(/^&/g, "");
    this._post(data);
}

/*
 * Initialization for oAjax class
 */
oAjax.prototype.Init = function() {
    // initialization
}

/*
 * Change URL for request
 */
oAjax.prototype.SetUrl = function( url ) {
    this.Url = url;
}

/*
 * Set content type for HTTP header before sending request
 */
oAjax.prototype.SetContentType = function( type ) {
    this.ContentType = type;
}

oAjax.prototype.createXMLHttpRequest = function() {

    try { return new ActiveXObject("Msxml2.XMLHTTP");    } catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
    try { return new XMLHttpRequest();                   } catch(e) {}
    return null;
}

/*
 * Debug information for testing
 */
oAjax.prototype._debug = function(message) {

    if ( this.Debug )
    {
        alert(message);
    }
}

/*
 * Process message and data from server
 */
oAjax._OnReadyStateChange = function( xreq, callback ){

    if ( xreq == null )
    {
        return;    }
    
    /*Status is completed, then process result */
    if ( xreq.readyState == 4)
    {
        // OK        
        if ( xreq.status == 200 )
        {
			//alert(xreq.responseText);
          	callback (this.ArrayValue(xreq.responseXML) );
        }else{
//	
		document.write (xreq.responseText);
		}
    } else {
        // Others
    }
}
oAjax.prototype.GetResponseTxt=function(HttpMethod,data)
{
    this._debug( 'Send Request ' + HttpMethod + data );
    
    if ( this.HttpRequest != null )
    {
        this.HttpRequest.open(HttpMethod, this.Url, false);

        if ( this.ContentType != null )
        {
            //  <FORM> MIME type: application/x-www-form-urlencoded
            this.HttpRequest.setRequestHeader("Content-Type", this.ContentType);
        }
        this.HttpRequest.send(data);
        return this.HttpRequest.responseText;
    }
    return null;
}
oAjax.prototype.GetResponseArray=function(HttpMethod,data)
{
    this._debug( 'Send Request ' + HttpMethod + data );
    
    if ( this.HttpRequest != null )
    {
        this.HttpRequest.open(HttpMethod, this.Url, false);

        if ( this.ContentType != null )
        {
            //  <FORM> MIME type: application/x-www-form-urlencoded
            this.HttpRequest.setRequestHeader("Content-Type", this.ContentType);
        }
        this.HttpRequest.send(data);
        var array = new Array();
        var i = 0;
        var response = this.HttpRequest.responseXML.getElementsByTagName('Response')[0];
	    var element = response.firstChild;
	    array[i] = element.firstChild.nodeValue;
	    while ( element = element.nextSibling )
	    {
		    i ++;
		    array[i] = element.firstChild.nodeValue;
		}
	    return array;
    }
    return null;
}
oAjax.prototype._SendRequest = function(HttpMethod, data){

    this._debug( 'Send Request ' + HttpMethod + data );
    
    if ( this.HttpRequest != null )
    {
        this.HttpRequest.open(HttpMethod, this.Url, this.yibu);

        if ( this.ContentType != null )
        {
            //  <FORM> MIME type: application/x-www-form-urlencoded
            this.HttpRequest.setRequestHeader("Content-Type", this.ContentType);
        }
        this.HttpRequest.send(data);
        return true;
    }
    return false;
}

/* Send GET request to server */
oAjax.prototype._get = function () {

    this._debug( 'GET' );
    return this._SendRequest("GET", null);
}

/* Send POST request and data to server */
oAjax.prototype._post = function (data) {

    this._debug( 'POST' );
    return this._SendRequest("POST", data);
}

oAjax.ArrayValue = function ( xmlobj ) {
    var array = new Array();
    var i = 0;
    var response = xmlobj.getElementsByTagName('Response')[0];
	var element = response.firstChild;
	array[i] = element.firstChild.nodeValue;
	while ( element = element.nextSibling )
	{
		i ++;
		array[i] = element.firstChild.nodeValue;
		}
	return array;
}