function Div(exp1, exp2)
{
    var n1 = Math.round(exp1); //四舍五入
    var n2 = Math.round(exp2); //四舍五入
    
    var rslt = n1 / n2; //除
    
    if (rslt >= 0)
    {
        rslt = Math.floor(rslt); //返回值为小于等于其数值参数的最大整数值。
    }
    else
    {
        rslt = Math.ceil(rslt); //返回值为大于等于其数字参数的最小整数。
    }
    
    return rslt;
}
function UrlEncoding(str)
{  
    var i,temp,p,q;  
    var result="";  
    for(i=0;i<str.length;i++)
    {  
        temp = str.charCodeAt(i);
        if(temp >= 0xFF)
        {     
            execScript("ascCode=asc(\""+str.charAt(i)+"\")", "vbscript"); 
            Hight8 = Div((ascCode  & 0xFF00),0xFF);
            Low8 = ascCode & 0xFF;
            result = result + "%" + Hight8.toString(16) +  "%" + Low8.toString(16); 
        }
        else
        {     
            result+=str.charAt(i);    
        }   
    }  
    return result; 
}

function setActiveStyleSheet(title) { 
  var i, a, main; 
  if (title) { 
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) { 
  if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) { 
  a.disabled = true; 
  if(a.getAttribute('title') == title) a.disabled = false; 
  } 
  } 
  } 
  var username="";
  if (json.user!='Default')
  {
    username=json.user; 
    var postdata = "f=setcolor&userno="+username+"&v=" + title;
    startRequest('POST', 'save.aspx ',postdata);
  }
  } 
  function getActiveStyleSheet() { 
  var i, a; 
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) { 
  if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title'); 
  } 
  return null; 
} 

function News_Window(theURL,winName,features) {
window.open(theURL,winName,features);
}

function Cookie() {
 var self = this;
 var trim = function(str){
  return str.replace(/(^\s*)|(\s*$)/g, ""); 
 }
 
 var init = function(){
  var allcookies = document.cookie;
  if (allcookies == "") return;
  var cookies = allcookies.split(';');
  for(var i=0; i < cookies.length; i++)  // Break each pair into an array
   cookies[i] = cookies[i].split('=');
  for(var i = 0; i < cookies.length; i++) {
   self[trim(cookies[i][0])] = decodeURIComponent(cookies[i][1]);
  }
 }
 
 init();
 
 this.save = function(daysToLive, path, domain, secure){
  var dt = (new Date()).getTime() + daysToLive * 24 * 60 * 60 * 1000;
  for(var prop in this) {
   if (typeof this[prop] == 'function')
    continue;
   
   var cookie = "";
   cookie = prop + '=' + encodeURIComponent(this[prop]);
   
   if (daysToLive || daysToLive == 0) cookie += ";expires=" + new Date(dt).toUTCString(); 
   if (path) cookie += ";path=" + path;
   if (domain) cookie += "; domain=" + domain;
   if (secure) cookie += ";secure";
   document.cookie = cookie;
  }
 }
 
 this.remove = function(path, domain, secure){
  self.save(0, path, domain, secure); 

  for(var prop in this) {
   if (typeof this[prop] != 'function')
    delete this[prop];
  }
 }
}

function SetHome()
{
  var cookie = new Cookie("ua");
  cookie.ua=json.user;
  cookie.save(365);
}
function ClearHome()
{
  var cookie = new Cookie("ua");
  cookie.remove();
  alert("恢复默认成功!");
}