﻿//Author 王文涛
//Createdate 05-12-22
//Updatedate 07-4-11

function   utf8(wide)   {  
      var   c,   s;  
      var   enc   =   "";  
      var   i   =   0;  
      while(i<wide.length)   {  
          c=   wide.charCodeAt(i++);  
          //   handle   UTF-16   surrogates  
          if   (c>=0xDC00   &&   c<0xE000)   continue;  
          if   (c>=0xD800   &&   c<0xDC00)   {  
              if   (i>=wide.length)   continue;  
              s=   wide.charCodeAt(i++);  
              if   (s<0xDC00   ||   c>=0xDE00)   continue;  
              c=   ((c-0xD800)<<10)+(s-0xDC00)+0x10000;  
          }  
          //   output   value  
          if   (c<0x80)   enc   +=   String.fromCharCode(c);  
          else   if   (c<0x800)   enc   +=   String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));  
          else   if   (c<0x10000)   enc   +=   String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));  
          else   enc   +=   String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));  
      }  
      return   enc;  
  }  
   
  var   hexchars   =   "0123456789ABCDEF";  
   
  function   toHex(n)   {  
      return   hexchars.charAt(n>>4)+hexchars.charAt(n   &   0xF);  
  }  
   
  var   okURIchars   =   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";  
   
  function   encodeURIComponentNew(s)   {  
      var   s   =   utf8(s);  
      var   c;  
      var   enc   =   "";  
      for   (var   i=   0;   i<s.length;   i++)   {  
          if   (okURIchars.indexOf(s.charAt(i))==-1)  
              enc   +=   "%"+toHex(s.charCodeAt(i));  
          else  
              enc   +=   s.charAt(i);  
      }  
      return   enc;  
  }  
  



function CreateXmlHttp() 
{ 
        var A=null; 
        try 
        { 
        A=new ActiveXObject("Msxml2.XMLHTTP") 
        } catch(e) { 
        try 
        { 
        A=new ActiveXObject("Microsoft.XMLHTTP") 
        } catch(oc) { 
        A=null 
        } 
        } 
        if ( !A && typeof XMLHttpRequest != "undefined" ) 
        { 
        A=new XMLHttpRequest() 
        } 
        return A 
} 

//

function GetHtmlPart(filename,eid)
{
    var Bao = createXMLHttpRequest();
    Bao.onreadystatechange = function(){getready(eid,Bao)};
    Bao.open("GET","/"+filename,true);
    Bao.send(null);
}

function GetUrlRequest(filename,eid)
{
    var Bao = createXMLHttpRequest();
    Bao.onreadystatechange = function(){getready(eid,Bao)};
    Bao.open("GET","/userdefapp/common/GetAjaxData.aspx?controlpath="+filename,true);
    Bao.send(null);
}

function GetAspx(url,eid)
{
    var Bao = createXMLHttpRequest();
    Bao.onreadystatechange = function(){getready(eid,Bao)};
    Bao.open("GET","/userdefapp/"+url,true);
    Bao.send(null);
}

//发送数据请求
//obj 参数
function PostAspx(url,obj,eid)
{
    if(obj==null) obj='';
    var Bao = createXMLHttpRequest();
    Bao.onreadystatechange = function(){getready(eid,Bao)};
    Bao.open("POST","/userdefapp/"+url,true);
    Bao.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    Bao.send(obj);
}

function ReturnHtmlPart(filename)
{
    var Bao = createXMLHttpRequest();
    Bao.open("GET","/"+filename,false);
    Bao.send(null);
    return Bao.responseText;
}

function getready(AjaxElementID,obj)
{
        if(obj.readyState<4)
        {
            document.getElementById(AjaxElementID).innerHTML="数据传送中...";
        }
     else if(obj.readyState==4)
     {
          if(obj.status==200)
          {
             document.getElementById(AjaxElementID).innerHTML=obj.responseText;
          }
          else
          {
            document.getElementById(AjaxElementID).innerHTML="抱歉，数据处理失败。";
          }
     }
    
}



//从远程URL中读出所需数据
function GetAjaxData(url)
{
    var Bao = createXMLHttpRequest();
    Bao.open("GET",url,false);
    Bao.send(null);
    return Bao.responseText;
}

//POST方式从远程URL中读出所需数据
function PostAjaxData(url,obj)
{
    var Bao = createXMLHttpRequest();
    Bao.open("POST",url,false);
   Bao.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    Bao.send(obj);
    return Bao.responseText;
}

function createXMLHttpRequest()
{
    var xmlHttpRequest=null;
   if(window.ActiveXObject)
  {
    try {
                 xmlHttpRequest = new ActiveXObject("Msxml3.XMLHTTP");
        } catch (e) {
    try {
                 xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
   try {
                xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}}}
  }else if(window.XMLHttpRequest)
 {
          xmlHttpRequest=new XMLHttpRequest();
          if (xmlHttpRequest.overrideMimeType)
                  xmlHttpRequest.overrideMimeType('text/xml');
 }
 return xmlHttpRequest
}

function jb() 
{ 
var A=null; 
try 
{ 
A=new ActiveXObject("Msxml2.XMLHTTP") 
} catch(e) { 
try 
{ 
A=new ActiveXObject("Microsoft.XMLHTTP") 
} catch(oc) { 
A=null 
} 
} 
if ( !A && typeof XMLHttpRequest != "undefined" ) 
{ 
A=new XMLHttpRequest() 
} 
return A 
} 


function resetNetPolicePosition(){
    var obj = document.getElementById("netPolice");
    if (obj) {
        obj.style.width=document.body.scrollWidth + "px";
        obj.style.overflow = "hidden";
        //obj.style.top = document.body.clentHeight - obj.clientHeight + "px";
    }
}
window.onload = function () {
    resetNetPolicePosition();
    window.setInterval("resetNetPolicePosition()", 10);
}