var G_IS_DISPLAY = 1; //设置是否显示面板 1 表示显示，0表示不显示。
var G_MARQUEE_TIMER = null;
function $(id){
    return document.getElementById(id);
}
function sLog(str){
  parent.logForClick(str);
}
function getBrowserInfo(){
    var userAgent = navigator.userAgent.toLowerCase();
    var env = null;
    return (env = userAgent.match(/msie ([\d.]+)/)) ? {browser:"MSIE", version:env[1]} :
    (env = userAgent.match(/firefox\/([\d.]+)/)) ? {browser:"FireFox", version:env[1]} :
    (env = userAgent.match(/opera.([\d.]+)/)) ? {browser:"Opera", version:env[1]} :
    (env = userAgent.match(/version\/([\d.]+).*safari/)) ? {browser:"Safari", version:env[1]} :
    (env = userAgent.match(/chrome\/([\d.]+)/)) ? {browser:"Chrome", version:env[1]} :
    {browser:"Unknown", version:0};
}
function dealxm(){
    if(1 == G_IS_DISPLAY){
        var info = getBrowserInfo();
        var todayHead = parent.document.getElementById("_today_head");
        var previewWin = parent.document.getElementById("_preview_win");
        var ifrNBA = parent.document.getElementById("_ifr_nba");
        var matchList = $("nba_match_list");
        var matchListPanel = $("matchListPanel");
        var livingPanel = $("livingPanel");
        var items = matchList.getElementsByTagName("li");
        var itemsSize = items.length;
        matchList.style.width = (itemsSize * 235) + "px";
        if(null != livingPanel){
            matchListPanel.style.width = ((itemsSize * 235) + 245) + "px";
            if(parseInt(info.version, 10) >= 7){
                livingPanel.style.backgroundColor = "white";
            }
        }
        if(todayHead){
            todayHead.style.marginBottom = "61px";
            previewWin.style.marginBottom = "61px";
            ifrNBA.width = 960;
            ifrNBA.height = 45;
        }
    }
}
function marquee(){
    var pNode = $("nba_match_list");
    var firstNode = pNode.firstChild;
    var intvId = null;
    var marginLeft = firstNode.style.marginLeft || 0;
    var iMarginLeft = parseInt(marginLeft, 10);
    var offsetPos = 0;
    var cloneFirsNode = null;
    intvId = setInterval(function(){
        offsetPos += 5;
        if(offsetPos > 245){
            clearInterval(intvId);
            firstNode.style.marginLeft = "-245px";
            cloneFirsNode = firstNode.cloneNode(true);
            pNode.removeChild(firstNode);
            cloneFirsNode.style.marginLeft = "0px";
            pNode.appendChild(cloneFirsNode);
            return;
        }
        firstNode.style.marginLeft = (iMarginLeft-offsetPos) + "px";
    }, 20);
}
if(1==G_IS_DISPLAY){
    G_MARQUEE_TIMER = setInterval("marquee()", 6000);
}