/*
 作者:汤晓华
 copyright 2009
 */
/**
 * 获取滚动条信息（返回[top,left]）
 */
function getScrollInfo(){
    var scrollTop = 0;
    var scrollLeft = 0;
    var scrollInfo = [0, 0];
    
    if (document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop;
        scrollLeft = document.documentElement.scrollLeft;
    }
    else 
        if (document.body) {
            scrollTop = document.documentElement.scrollTop;
            scrollLeft = document.documentElement.scrollLeft;
        }
    scrollInfo = [scrollTop, scrollLeft];
    return scrollInfo;
}

/**
 * 显示面板
 */
function showPanel(){
    var bottomDiv = $("#bottomDiv");
    var _window = $(window);
    var winHeight = _window.height();
    var winWidth = _window.width();
    bottomDiv.css("top", getScrollInfo()[0]);
    bottomDiv.css("left", getScrollInfo()[1] + 10);
    bottomDiv.css("width", winWidth - 24);
}

//状态栏滚动事件绑定触发函数
$(window).scroll(function(){
    showPanel();
});

//窗口太小发生改变时触发函数
$(window).resize(function(){
    showPanel();
});


/**
 * 动态显示信息
 * @param {Object} index
 * @param {Object} speed
 */
function showMsg(index, speed){
    if (index >= data.length) {
        index = 0;
    }
    var content = $("#bD_content");
    content.html("<a href='" + data[index].url + "'>" + data[index].content + "</a>");
    $("#bD_content").animate({
        right: 500,
        opacity: "show"
    }, speed - 1000, function(){
        setTimeout(function(){
            $("#bD_content").animate({
                right: 500,
                opacity: "hide"
            }, speed - speed / 2 - 500, function(){
                showMsg(index + 1, speed);
            });
            
        }, speed - 1000);
    });
}

/**
 * 文档加载完毕后执行函数
 */
$(document).ready(function(){
    //初始化面板
    showPanel();
    //初始化数据显示 显示第0条（也就是第一条） 切换熟读大约 3000毫秒 3秒 自己根据实际情况调节
    showMsg(0, 3000);
});
