﻿//设置背景色
function setbackColor(ctr,bgcolor)
{
    ctr.style.backgroundColor = bgcolor;
}

//為string對象增加Contain方法
String.prototype.contain = function(ContainStr)
{
    return this.indexOf(ContainStr)>-1;
}

//设置此页面为首页
function SetDefaultPage(ctr)
{
    ctr.style.behavior='url(#default#homepage)';
    ctr.setHomePage('http://www.ChineseDailyNews.com');
    return false;
}

//設置地區信息
function chanageDistrict(ctr,dataShowCtr)
{
    SwitchSelectShow(dataShowCtr,false);
    dataShowCtr.value = ctr.innerText;
    
    var expireDate = new Date();
    expireDate.setFullYear(expireDate.getFullYear()+100);
    document.cookie = "District=" +  ctr.attributes["Did"].value + ";path=/;expires=" + expireDate.toGMTString();
    document.cookie = "District=" +  ctr.attributes["Did"].value + ";path=/;domain=ChineseDailyNews.com;expires=" + expireDate.toGMTString();
    
    LocaToIndexPage();
}

var bodyonClickInfo = 0;
function SwitchSelectShow(ctr,isShow)
{
    //window.event.cancelBubble = true;
    if(isShow)
    {       
        ctr.style.visibility = "visible"; 
        
        if(bodyonClickInfo==0)
        {
            bodyonClickInfo=1;
            //document.body.onclick = function(){ctr.style.visibility = "hidden";}
            if(document.all && window.ActiveXObject && !window.opera)
            {                
                ctr.onmouseleave = function(){SwitchSelectShow(ctr,false);};
            }
            else
            {
                ctr.addEventListener("mouseout",function(){SwitchSelectShow(ctr,false);},false);
            }
        }
              
    }
    else
    {
        ctr.style.visibility = "hidden";
    }
}

//回到首页
function LocaToIndexPage()
{
    window.top.location.href = "/index.aspx";
}

//繁体转换为简体
function t2s()
{
    document.body.innerHTML=Simplized(document.body.innerHTML);
}

//简体转换为繁体
function s2t()
{
    document.body.innerHTML=Traditionalized(document.body.innerHTML);
}