﻿var waitShow;

function ShowRank(e)
{
    waitShow = setTimeout("ChangeRank('" + e.id + "')",300);
}

function ShowDaysRank(e)
{
    waitShow = setTimeout("ChangeDaysRank('" + e.id + "')",300);
}

function ShowCommend(e)
{
   waitShow = setTimeout("ChangeCommend('" + e.id + "')",300);
}

function ChangeRank(id)
{
    var e = document.getElementById(id);
    if(e.className=="weekhot1")
    {
        return;
    }
    else
    {
        //初始化排行状态 
        document.getElementById("Rank_News").style.display="none";
        document.getElementById("Rank_Favorite").style.display="none";
        document.getElementById("Rank_Sport").style.display="none";

        document.getElementById("div_Rank_Favorite").className ="weekhot2";
        document.getElementById("div_Rank_News").className ="weekhot2";
        document.getElementById("div_Rank_Sport").className ="weekhot2";
        
        document.getElementById("Photo_Rank_Favorite").style.display="none";
        document.getElementById("Photo_Rank_News").style.display="none";
        document.getElementById("Photo_Rank_Sport").style.display="none";
        
        document.getElementById("a_Rank_Favorite").className ="black";
        document.getElementById("a_Rank_News").className ="black";
        document.getElementById("a_Rank_Sport").className ="black";
        
        e.className ="weekhot1";
        document.getElementById(e.id.replace("div_","")).style.display = "block";
        document.getElementById(e.id.replace("div_","Photo_")).style.display = "block";
        document.getElementById(e.id.replace("div_","a_")).className = "textti";
     }
}

function ChangeDaysRank(id)
{
    var e = document.getElementById(id);
    if(e.className=="weekhot1")
    {
        return;
    }
    else
    {
        document.getElementById("Rank_Day").style.display="none";
        document.getElementById("Rank_Week").style.display="none";
       
        document.getElementById("div_Rank_Day").className ="weekhot2";
        document.getElementById("div_Rank_Week").className ="weekhot2";

        document.getElementById("a_Rank_Day").className ="black";
        document.getElementById("a_Rank_Week").className ="black";
        
        e.className ="weekhot1";
        document.getElementById(e.id.replace("div_","")).style.display = "block";
        document.getElementById(e.id.replace("div_","a_")).className = "textti";
     }
}

function ChangeCommend(id)
{
    var e = document.getElementById(id);
    if(e.className=="weekhot1")
    {
        return;
    }
    else
    {      
        document.getElementById("Commend_Common").style.display="none";
        
        document.getElementById("Photo_Commend_Photo").style.display="none";
        document.getElementById("Photo_Commend_Common").style.display="none";
   
        document.getElementById("div_Commend_Photo").className ="weekhot2";
        document.getElementById("div_Commend_Common").className ="weekhot2";

        document.getElementById("a_Commend_Photo").className ="black";
        document.getElementById("a_Commend_Common").className ="black";
        
        e.className ="weekhot1";
        try
        {
            document.getElementById(e.id.replace("div_","")).style.display = "block";
        }
        catch(ex)
        { } 
        document.getElementById(e.id.replace("div_","Photo_")).style.display = "block";
        document.getElementById(e.id.replace("div_","a_")).className = "textti";
     }
}

function copyToClipBoard()
{
    var s = window.document.title;
	copy_clip( s + "\n" + window.location.href);
	alert("你已复制链接及标题，请粘贴到QQ/MSN等发给好友!");
}

function copy_clip(meintext)
{
    if (window.clipboardData) 
    {
        window.clipboardData.setData("Text", meintext);
    }
    else if (window.netscape) 
    { 
          try 
          { 
              netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
          } 
          catch (e) 
          { 
              alert("复制功能被浏览器拒绝，未能将以下信息复制到剪贴板：\n" + meintext + "\r\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
              return false;
          }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return false;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return false;
        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=meintext;
        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;
}