function trimString(str)
{   
    str = str.replace(/\s+$|^\s+/g,"");
    return str;
}
/********************************** Integer *************************************/
/**
*校验字符串是否为整型
*返回值：
*如果为空，定义校验通过，      返回true
*如果字串全部为数字，校验通过，返回true
*如果校验不通过，              返回false     参考提示信息：输入域必须为数字！
*/
function checkIsInteger(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    if(/^(\-?)(\d+)$/.test(str))
        return true;
    else
        return false;
}//~~~
/**
*只允许输入1234567890
*/
function checkNumber(String) 
{ 
    var Letters = "1234567890"; 
    var i; 
    var c; 
    for( i = 0; i < String.length; i ++ ) 
    { 
        c = String.charAt( i ); 
        if (Letters.indexOf( c ) ==-1) 
        { 
            return false; 
        } 
    } 
    return true; 
} 
/**
*校验字符串是否为数字或26个英文字母
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为数字或26个英文字母，校验通过，         返回true
*如果字串为非数字或26个英文字母，             返回false    参考提示信息：必须为英文字母！
*/
function checkIsEnglishOrNumber(str)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^[a-zA-Z0-9]+$/;/*/[^a-zA-Z]/g*/;
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~~
/********************************** chinese ***************************************/
/**
*校验字符串是否为中文
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为中文，校验通过，         返回true
*如果字串为非中文，             返回false    参考提示信息：必须为中文！
*/
function checkIsChinese(str)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi;
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~~

/**
*校验字符串是否为只允许为英文、数字和汉字的混合
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为英文、数字和汉字的混合，校验通过，         返回true
*如果字串为非英文、数字和汉字的混合，             返回false    参考提示信息：必须为中文！
*/
function checkIsChineseOrEnglishOrNumber(str)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^(\w|[\u4E00-\u9FA5])*$/;
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~

function checkMenuName(str)//检查菜单
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^(\w|[\u4E00-\u9FA5]|[(]|[)])*$/;
    if (pattern.test(str))
        return true;
    else
        return false;
}//~~

/**校验菜单元素专用
*校验字符串是否为只允许为英文、数字和汉字的混合
*返回值：
*如果为空，定义校验通过，           返回true
*如果字串为英文、数字和汉字的混合，校验通过，         返回true
*如果字串为非英文、数字和汉字的混合，             返回false    参考提示信息：必须为中文！
*/
function checkMenuElement(str)
{
    //如果值为空，通过校验
    if (str == "")
        return true;
    var pattern = /^(\w|[\u4E00-\u9FA5]|[+]|[(]|[)])*$/;
    if (pattern.test(str))
        return true;
    else
        return false;
}//
function checkEmail(value)
{
    //var resss=new RegExp("^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
    //var resss=new RegExp("^\w+([-+.]\w+)*@{1}\w+([-.]\w+)*\.[a-zA-Z]{2,3}$");
     var resss = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    if(!resss.test(value))
    {
        return false;        
    }
    return true;
}

function externallinks()
{
    if (!document.getElementsByTagName) return;
        var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++)
    {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}
window.onload = externallinks;

function getcon(con)
{
    return document.getElementById(con);
}

function show(bg,msg,sendhead,sendvalue,msgw,msgh)
{
    bg.style.visibility="visible";
    msg.style.visibility="visible";
    msg.style.left = ((document.documentElement.clientWidth)/2 - msgw + document.documentElement.scrollLeft) + "px";
    msg.style.top = ((document.documentElement.clientHeight)/2 - msgh + document.documentElement.scrollTop) + "px";
    sendhead.innerHTML=sendvalue;
}

//function showOut(id)
//{
//    var msg="<div id=\"msg\" style=\"position:absolute;z-index:2;background-color:#D0EAFB;width:350px;height:215px;visibility:hidden; border:1px solid #086EAE;\" class=\"float_layer_mode2\">";
//    msg+="<div id=\"sendhead\" class=\"float_layer_mode\"></div>";
//    msg+="<div class=\"mg5\">";
//    msg+="标题：<input id=\"title\" type=\"text\" maxlength=\"50\" onkeyup=\"keylength(this,'num1',50);\"/>(<label id=\"num1\">0</label>/50)";
//    
//    msg+="<br />";
//    msg+="<textarea id=\"content\" cols=\"38\" rows=\"6\" onkeyup=\"keylength(this,'num2',2000);\"></textarea>";
//    msg+="<br /><br />";
//    msg+="<label id=\"num2\">0</label>/2000";
//    msg+="<input type=\"button\" value=\"发送\" onclick=\"sendMessage('" + id + "');\"/>&nbsp;<input type=\"button\" value=\"取消\" onclick=\"hide(getcon('bg'),getcon('msg'),getcon('title'),getcon('content'));\" />";
//    msg+="</div>";
//    msg+="</div>";
//    getcon("dialog").innerHTML=msg;
//    var bg=getcon("bg");
//    var msg=getcon("msg");
//    var sendhead=getcon("sendhead");
//    
//    bg.style.visibility="visible";
//    msg.style.visibility="visible";

//    msg.style.left = ((document.documentElement.clientWidth)/2-200 + document.documentElement.scrollLeft) + "px";
//    msg.style.top = ((document.documentElement.clientHeight)/2-100 + document.documentElement.scrollTop) + "px";
////    getcon("sendhead").innerHTML=sendvalue;
//}

function hide(bg,msg,mytitle,mycontent)
{
    bg.style.visibility="hidden";
    msg.style.visibility="hidden";
    mytitle.value="";
    mycontent.value="";
    keylength(mytitle,'num1',50);
    keylength(mycontent,'num2',2000);
}

function ie_or_fire(bg)
{
    var exp=navigator.userAgent.toLowerCase();
    if(exp.indexOf("msie")!=-1)
        bg.style.filter="alpha(opacity=50)";
    else if(exp.indexOf("firefox")!=-1)
        bg.style.opacity= 0.5;
}

function messagehide(bg,errormessage)
{
    bg.style.visibility="hidden";
    errormessage.style.visibility="hidden";
}

function keylength(con,num,max_num)
{
    if(con.value.length>max_num)
    {
        var max_value=con.value.substring(0,max_num);
        con.value = max_value;
        getcon(num).innerHTML = max_num;
    }
    else
        getcon(num).innerHTML=con.value.length;
}


function hiddenMenu(menu)
{
     menu.style.visibility='hidden';
}

//select
function SelectAll(tableid,rowid,cbdelete)
{
    var i=0;
    var s="";
    while(true)
    {
        if(i<10)
            s = tableid + rowid + "0" + i + cbdelete;
        else
            s = tableid + rowid + i + cbdelete;
        var chk = document.getElementById(s);
        if(null==chk)
            break;
        chk.checked = true;
        i++;
    }
}

function CancelAllSelect(tableid,rowid,cbdelete)
{
    var i=0;
    var s="";
    while(true)
    {
        if(i<10)
            s = tableid + rowid + "0" + i + cbdelete;
        else
            s = tableid + rowid + i + cbdelete;
        var chk = document.getElementById(s);
        if(null==chk)
            break;
        chk.checked = false;
        i++;
    }
}

function checkboxValidate(tableid,rowid,cbdelete)
{
    var i=0;
    var s="";
    while(true)
    {
        if(i<10)
            s = tableid + rowid + "0" + i + cbdelete;
        else
            s = tableid + rowid + i + cbdelete;
        var chk = document.getElementById(s);
        if(null==chk)
            break;
        if(chk.checked)
            return true;
        i++;
    }
    return false;
}

function setid(id,nickname)
{
    getcon("uid").value = id;
    getcon("nickname").value = nickname;
}

//enter ignore
function enter(evt)
{
  if(evt.keyCode=='13')
  {
        //evt.returnValue= false;
	//alert("1");
	return false;
  }
return true;
}
function getFCK(id)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    var oDOM = oEditor.EditorDocument;
    var iLength;
    if ( document.all)
    {
	    iLength = oDOM.body.innerText;
    }
    else					
    {
	    var r = oDOM.createRange();
	    r.selectNodeContents(oDOM.body);
	    iLength = r.toString();
    }
    if (iLength.replace(/\s+$|^\s+/g,"") == "")
    {
        if (alt!=null)
            alert(alt)
        else
            alert("请输入内容！");
        return false;
    }
}
function checkFCK(id,alt)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    var oDOM = oEditor.EditorDocument;
    var iLength;
    if ( document.all)
    {
	    iLength = oDOM.body.innerText;
    }
    else					
    {
	    var r = oDOM.createRange();
	    r.selectNodeContents(oDOM.body);
	    iLength = r.toString();
    }
    if (iLength.replace(/\s+$|^\s+/g,"") == "")
    {
        if (alt!=null)
            alert(alt)
        else
            alert("请输入内容！");
        return false;
    }
    
    return true;
}
function FCK_Length(id)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    var oDOM = oEditor.EditorDocument;
    var iLength;
    if ( document.all)
    {
	    iLength = oDOM.body.innerText;
    }
    else					
    {
	    var r = oDOM.createRange();
	    r.selectNodeContents(oDOM.body);
	    iLength = r.toString();
    }
    return iLength.replace(/\s+$|^\s+/g,"").replace(/[^\x00-\xff]/g,"xx").length;
}

function nullFCK(id)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    oEditor.SetHTML("");
}

function setFCK(id,value)
{
    var oEditor = FCKeditorAPI.GetInstance(id) ;
    oEditor.SetHTML(value);
}

/*  ajax start */
function getActiveXObject()
{
    var xhttp;
    var exp=navigator.userAgent.toLowerCase();
    if(exp.indexOf("msie")!=-1)
        xhttp = new ActiveXObject("MSXML2.XMLHTTP");
    else if(exp.indexOf("firefox")!=-1)
        xhttp = new XMLHttpRequest();
    return xhttp;
}

function getHTML(container,url,pram)
{
    new Ajax.Updater(container,url,pram,{onFailure:reportError});
}

function getReqHTML(container,url)
{
    var oHttpReq = getActiveXObject();
    oHttpReq.open("post",url,false);
    oHttpReq.send("");
    var result = oHttpReq.responseText;
    getcon(container).innerHTML = result;
}
/*  ajax end */

function reportError(request)
{
    location.href="/404.htm";
}

/* -------------设置加载中 开始------------- */
function setLoading(objName)
{
    //con.innerHTML="<img alt=\"loading\" src=\"/images/loading2.gif\" />数据加载中.....";
    var divList=null;
    if (typeof objName == "string")
        divList = document.getElementById(objName);
    else
        divList = objName;
    divList.innerHTML = "<img src='/images/System/loading.gif' alt='正在载入...'/>";
}
function clearLoading(objName)
{    
    var divList=null;
    if (typeof objName == "string")
        divList = document.getElementById(objName);
    else
        divList = objName
    divList.innerHTML = "";
}
/* -------------设置加载中 结束------------- */

function getHTMLFCK(id)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    var content = oEditor.GetXHTML(true);
    return content;
}

function checkHTMLFCK(id)
{
    var oEditor = FCKeditorAPI.GetInstance(id);
    var content = oEditor.GetXHTML(true);
    if(content==null || content.value=="")
        return false;
    return true;
}

function browseType()
{
    var exp=navigator.userAgent.toLowerCase();
    if(exp.indexOf("msie")!=-1)
        return "ie";
    else if(exp.indexOf("firefox")!=-1)
        return "ff";
    else
        return "";
}

function encodeurl(key)
{
    var e = window.encodeURIComponent ? encodeURIComponent : escape;
    return e(key);
}



function isObject(strObj)
{
    /*try{   
        var t=document.getElementById(strObj).innerHTML; 
        return true;
    }
    catch(e){
        return false;
    } */
    if (typeof strObj == "string")
        return false;
    else
        return true;
}
function browseType()
{
    var exp=navigator.userAgent.toLowerCase();
    if(exp.indexOf("msie")!=-1)
        return "ie";
    else if(exp.indexOf("firefox")!=-1)
        return "ff";
    else
        return "";
}

function checkDate(str)
{
    var reg = ""; 
    var r = str.search(/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/);
    if(r==-1)
        return false;
    return true;
}
function isNumber(oNum) 
{ 
  if(!oNum) return false; 
  var strP=/^\d+(\.\d+)?$/; 
  if(!strP.test(oNum)) return false; 
  try{ 
        if(parseFloat(oNum)!=oNum) return false; 
  } 
  catch(ex) 
  { 
        return false; 
  } 
  return true; 
}
function isFloat(val_num)//判断是否为float型数据
{
  var checkOK = "0123456789.";
  var checkStr = val_num;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  var n=0;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if(ch==checkOK.charAt(10))
    {
       n++;//判断该字符串中有几个点
    }
    for (j = 0;  j < checkOK.length;  j++)
   if (ch == checkOK.charAt(j))
        break;

    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
 if(n>1)//如果字符串中点的个数>1的,错误
 {
  allValid=false;
  break;
 }
  }
  if (!allValid)
  {
    return (false);
  }
  return (true);
}

//它格式化成N位小数据
function FormatNumber(srcStr,nAfterDot){
　　var srcStr,nAfterDot;
　　var resultStr,nTen;
　　srcStr = ""+srcStr+"";
　　strLen = srcStr.length;
　　dotPos = srcStr.indexOf(".",0);
　　if (dotPos == -1){
　　　　resultStr = srcStr+".";
　　　　for (i=0;i<nAfterDot;i++){
　　　　　　resultStr = resultStr+"0";
　　　　}
　　　　return resultStr;
　　}
　　else{
　　　　if ((strLen - dotPos - 1) >= nAfterDot){
　　　　　　nAfter = dotPos + nAfterDot + 1;
　　　　　　nTen =1;
　　　　　　for(j=0;j<nAfterDot;j++){
　　　　　　　　nTen = nTen*10;
　　　　　　}
　　　　　　resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
　　　　　　return resultStr;
　　　　}
　　　　else{
　　　　　　resultStr = srcStr;
　　　　　　for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
　　　　　　　　resultStr = resultStr+"0";
　　　　　　}
　　　　　　return resultStr;
　　　　}
　　}
} 

function getQuery(name,obj,defaultValue)   
{   
      var   reg   =   new   RegExp("(^|&)"+   name   +"=([^&]*)(&|$)");   
      var   r   =   obj.location.search.substr(1).match(reg);   
      var dv = null;
      if (defaultValue!=null)
        dv = defaultValue;
      if   (r!=null)   return   unescape(r[2]);   return   dv;   
} 

String.prototype.trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
//取得字符串长度，汉字为2;
String.prototype.len = function()
{ 
    this.replace(/[^\x00-\xff]/g,"xx").length;  
}    
function date_compare(asstartdate,asenddate)
{//计算两个字符(yyyy-mm-dd)的日期相隔天数
    var mistart = Date.parse(asstartdate.replace(/\-/g, '/'));
    var miend = Date.parse(asenddate.replace(/\-/g, '/'));
    result = (miend-mistart)/(1000*24*3600);
    return result;
}
function   getToday()   
  {   
      var   D   =   new   Date();   
      var   y   =   D.getFullYear();   
      var   m   =   (D.getMonth()   +   1)+"";   m   =   ("00"+m).substr(m.length);   
      var   d   =   D.getDate()   +"";   d   =   ("00"+d).substr(d.length);   
      return(y   +"-"+   m   +"-"+   d);   
  }
//----------图片按比例缩放
function DrawImage(ImgD,iwidth,iheight)
{
    //参数(图片,允许的宽度,允许的高度)
    var flag=false;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
    //调用：<img src="images/toplogo.gif" onload="javascript:DrawImage(this,100,100)">
} 

//-----------------------------------ddl--------------------------------- 
function ddlBind(dt,ddlName,defaultValue,tField,vField)
{
    ddlRemove(ddlName);
    
    if (tField == null)
        tField = "name";
    if (vField == null)
        vField = "id";  
    
    var ddl = document.getElementById(ddlName);  
    if(defaultValue!=null)
    {
        //ddl.options.add(new Option(defaultValue,"0"));
        var node1=document.createElement('option');
        node1.id = 'opt1';
        node1.value = "0";
        node1.innerHTML = defaultValue;
        ddl.appendChild(node1);
    }
    if (dt!=null)
    {
        for(var i=0;i < dt.Rows.length;i++)
        {
            //var name=dt.Rows[i].name;
            //var id=dt.Rows[i].id;                        
            var name = eval("dt.Rows[" + i + "]." + tField);
            var id = eval("dt.Rows[" + i + "]." + vField);
            var node=document.createElement('option');
            //node.id = 'opt';
            node.value = id;
            node.innerHTML = name;
            ddl.appendChild(node);
            
        }
        //if(dt.Rows.length>0)
            
    }        
        try
        {
            ddl.onchange();
        }
        catch(e)
        {
        }
}
function ddlAdd(element,text,value)
{
    var ddl;
    if (typeof element == 'string')
      ddl = document.getElementById(element);
    else
      ddl = element;
      
    if(browseType()=='ie')
    {
        ddl.options.add(new Option(text,value));
    }
    else
    {
        var node=document.createElement('option');
        node.id = 'opt';
        node.value = value;
        node.innerHTML = text;
        ddl.appendChild(node);
    }         
}
function ddlRemove(ddlName)
{
	var ddl = document.getElementById(ddlName); 
	ddl.length=0; 
}
function selectDelOption(oSel)
{   // 删除option
    if (oSel.selectedIndex>=0) {
       oSel.remove(oSel.selectedIndex);
    } else {
       
    };
}
function searchDdlByValue(lb, lb_value)        
{//查找值
    var lb_count = lb.length;
    for (var i = 0; i < lb_count; i++)
    {
        if (lb.options[i].value == lb_value)
        {
            //lb.SelectedIndex=i;
            return true;
        }
    }
    return false;
}

/*$("#ddl option[@value=192]").attr("selected", true);*/
function setDdlByValue(obj,lb_value)
{//选定值
    var lb;
    if (typeof obj == "string")
        lb = document.getElementById(obj);
    else
        lb = obj;
    var lb_count = lb.length;
    for (var i = 0; i < lb_count; i++)
    {
        if (lb.options[i].value == lb_value)
        {            
            //lb.options[i].selected=true;
            lb.selectedIndex = i;
            break;
        }
    }
    try
    {
        lb.onchange();
    }
    catch(e)
    {
    
    }   
}
//end-ddl

function ddlBindByList(list,element,tField,vField,defaultText,defaultValue)
{  
    var ddl;
    if (typeof element == 'string')
      ddl = document.getElementById(element);
    else
      ddl = element;
 
    ddl.length=0;
    if (defaultText!=null&&defaultValue!=null)
    {       
        var node1=document.createElement('option');
        node1.id = 'opt1';
        node1.innerHTML = defaultText;
        node1.value = defaultValue;        
        ddl.appendChild(node1);
    }
    else if (defaultText!=null)
    {
        var node1=document.createElement('option');
        node1.id = 'opt1';
        node1.innerHTML = defaultText;
        node1.value = "0";        
        ddl.appendChild(node1);
    }
    
    if (tField == null)
        tField = "Name";
    if (vField == null)
        vField = "ID";  

    if (list!=null)
    {
        for(var i=0;i < list.length;i++)
        {
            var t = list[i][tField];
            var v = list[i][vField];
            var node=document.createElement('option');            
            node.innerHTML = t;
            node.value = v;
            ddl.appendChild(node);
        }   
    }       
    try
    {
        ddl.onchange();
    }
    catch(e)
    {
    
    }        
}
/* HTML 编码解码 */
function   HTMLEnCode(str)   
  {   
        var   s   =   "";   
        if   (str.length   ==   0)   return   "";   
        s   =   str.replace(/&/g,   "&gt;");   
        s   =   s.replace(/</g,       "&lt;");   
        s   =   s.replace(/>/g,       "&gt;");   
        s   =   s.replace(/   /g,       "&nbsp;");   
        s   =   s.replace(/\'/g,     "&#39;");   
        s   =   s.replace(/\"/g,     "&quot;");   
        s   =   s.replace(/\n/g,     "<br>");   
        return   s;   
  }   
  function   HTMLDeCode(str)   
  {   
        var   s   =   "";   
        if   (str.length   ==   0)   return   "";   
        s   =   str.replace(/&gt;/g,   "&");   
        s   =   s.replace(/&lt;/g,       "<");   
        s   =   s.replace(/&gt;/g,       ">");   
        s   =   s.replace(/&nbsp;/g,       "   ");   
        s   =   s.replace(/&#39;/g,     "\'");   
        s   =   s.replace(/&quot;/g,     "\"");   
        s   =   s.replace(/<br>/g,     "\n");   
        return   s;   
  }   
/* 复制到粘贴板，支持各种浏览器 */
function copyToClipboard(txt) {   
      if(window.clipboardData) {   
              window.clipboardData.clearData();   
              window.clipboardData.setData("Text", txt);
           return true;  
      } else if(navigator.userAgent.indexOf("Opera") != -1) {   
           window.location = txt;   
      } else if (window.netscape) {   
           try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   


           } catch (e) {   
                alert("如果您正在使用FireFox！\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);   //本文来自:http://www.87717.com 
           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;
      }   
}
/*如果不支持的用flash来复制*/
function copy_clip(text2copy) 
{
    
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text",text2copy);
	} 
	else 
	{
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) 
		{
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		
		var divinfo = '<embed src="/js/_clipboard.swf" FlashVars="clipboard='+ text2copy +'" width="0" height="0" type="application/x-shockwave-flash"></embed>';//这里是关键
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
	return true;
}  
//取得对象位置
function getPosition(obj)
{
    var o = null;
    if (typeof obj == 'string')
      o = document.getElementById(obj);
    else
      o = obj;
      
    var x=y=0;
    do{
        x+=o.offsetLeft;
        y+=o.offsetTop;
    }
    while (o=o.offsetParent);
    return {"x":x,"y":y};
}
/* 兼容IE7，firefox的添加到收藏夹 */
function addfavorite(title,url)
{
    if (url==null)
        url = location.href;
    if (document.all) {
        window.external.addFavorite(url,title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    }
}

/*---------------------现在时间:2007年9月11日星期二下午4:25:07-------------------------------------------
<body onload="showTime()">
<span  id=liveclock  style=width:  109px;  height:  15px>  
</span>
*/
function  showTime()
{	if(!document.layers&&!document.all)
	return
	
	today=new Date();
	function initArray(){
	   this.length=initArray.arguments.length
	   for(var i=0;i<this.length;i++)
	   this[i+1]=initArray.arguments[i]  
   }
   var d=new initArray(
     "星期日",
     "星期一",
     "星期二",
     "星期三",
     "星期四",
     "星期五",
     "星期六");	
	
	var  hours=today.getHours()
	var  minutes=today.getMinutes()
	var  seconds=today.getSeconds()
	var  dn="上午"
	if(hours>12){dn="下午"
	hours=hours-12
	}if(hours==0)
	hours=12
	if(minutes<=9)
	minutes="0"+minutes
	if(seconds<=9)
	seconds="0"+seconds
	//change  font  size  here  to  your  desire
	myclock="<font    color=blue>现在时间：" + today.getYear() + "年" + (today.getMonth()+1) + "月" + today.getDate() + "日" + "" + dn + hours+":"+minutes+":"+seconds+" " + d[today.getDay()+1]+"</font>";
	if(document.layers){
	document.layers.liveclock.document.write(myclock)
	document.layers.liveclock.document.close()
	}else  if(document.all)
	liveclock.innerHTML=myclock
	setTimeout("showTime()",1000)
}
//-----------------------------------------------------------------------------


