var clickPosition = "1", overPosition = "";

function showDiv() {
    var strNewsUrl = "news/news.aspx?Type=";
    var docComposite = document.getElementById("linkComposite").style;
    var docNews = document.getElementById("linkNews").style;
    var docSystem = document.getElementById("linkSystem").style;

    if (clickPosition == "1") {
        docComposite.display = "block";
        docNews.display = "none";
        docSystem.display = "none"; 
    }else if (clickPosition == "2") {
        docComposite.display = "none";
        docNews.display = "block";
        docSystem.display = "none"; 
    }else if (clickPosition == "3") {
        docComposite.display = "none";
        docNews.display = "none";
        docSystem.display = "block"; 
    }
    swapImage();
}
    
function SetClickPosition(clickPositionParm) {
    clickPosition = clickPositionParm;
    showDiv();
}

function SetOverPosition(overPositionParm) {
    overPosition = overPositionParm;
    swapImage();
}
    
function swapImage() {
    var strClick="";
    var strOver="";
    var strCase="";
        
    //組按鈕按下的位置的字串，如001....
    for (i=1; i<=3; i++) {
        if (i == clickPosition) {
            strClick = strClick + "1";
        }else {
            strClick = strClick + "0";
        }
    }
        
    //組游標移動到的位置的字串，如001....
    for (i=1; i<=3; i++) {
        if (i == overPosition) {
            strOver = strOver + "1";
        }else {
            strOver = strOver + "0";
        }
    }

    strCase = strClick | strOver;   //做位元運算OR

    var strMoreUrl = "news/news.aspx?Type=";
    var docComposite = document.getElementById("tabComposite");
    var docNews = document.getElementById("tabNews");
    var docSystem = document.getElementById("tabSystem");
    var docMore = document.getElementById("aMore");
    var strUrl = "images/home/center/news/";

    switch (strCase) {
        case 1:     //001代表按下按鈕的位置，是在第3個按鈕，變紅色
            docComposite.src = strUrl + "news_02_01.gif";
            docNews.src = strUrl + "news_03_01.gif";
            docSystem.src = strUrl + "news_04_02.gif";
            docMore.href = strMoreUrl + "System";
            break;
        case 10:    //010
            docComposite.src = strUrl + "news_02_01.gif";
            docNews.src = strUrl + "news_03_02.gif";
            docSystem.src = strUrl + "news_04_01.gif";
            docMore.href = strMoreUrl + "News";
            break;
        case 11:    //011
            docComposite.src = strUrl + "news_02_01.gif";
            docNews.src = strUrl + "news_03_02.gif";
            docSystem.src = strUrl + "news_04_02.gif";
            break;
        case 100:   //100
            docComposite.src = strUrl + "news_02_02.gif";
            docNews.src = strUrl + "news_03_01.gif";
            docSystem.src = strUrl + "news_04_01.gif";
            docMore.href = strMoreUrl + "News"; //註：因真女神無「綜合」頁面，故點選「更多」按鈕時跳至最新消息列表
            break;
        case 101:   //101
            docComposite.src = strUrl + "news_02_02.gif";
            docNews.src = strUrl + "news_03_01.gif";
            docSystem.src = strUrl + "news_04_02.gif";
            break;
        case 110:   //110
            docComposite.src = strUrl + "news_02_02.gif";
            docNews.src = strUrl + "news_03_02.gif";
            docSystem.src = strUrl + "news_04_01.gif";
            break;
    }
}

$(function() {
    $.getScript("/js/ToolTip.js");
});