var timeout2 = 5000;  //切换时间
var timeout3 = 10000; //mouse over 后切换时间
var now_content = 1;
var total_content = 6;
var way = 1;
var start_content = Math.round(Math.random() * (total_content - 1)) + 1; //除广告为第一显示外
var timeAnim = new Array();
var nowNum = 1;
function init() {
    for (var i = 0; i < 6; i++) {
        document.getElementById('divhl0' + (i+1)).style.width = "154px";
    }
}

function content_mouse(num) {
    if (num != nowNum) {
        var n = nowNum;
        if (timeAnim[n])
            clearInterval(timeAnim[n])
        timeAnim[n] = setInterval(function() { anim(n, "-"); }, 10);
        nowNum = num;
        //window.clearInterval(theTimer2);
        //    for (var i = 1; i <= total_content; i++) {
        //        document.getElementById('divhl0' + i).style.display = 'none';
        //    }
        document.getElementById('divhl0' + num).style.width = "0px";
        document.getElementById('divhl0' + num).style.display = 'block';
        if (timeAnim[num])
            clearInterval(timeAnim[num])
        timeAnim[num] = setInterval(function() { anim(num, "+"); }, 10);
        //theTimer2 = setTimeout('change_content()', timeout3);
    }
}

function anim(num, type) {
    var obj = document.getElementById('divhl0' + num);
    var w = parseInt(obj.style.width)
    if (type == "+") {
        w += 20;
        if (w > 154) {
            obj.style.width = "154px";
            clearInterval(timeAnim[num]);
        }
        else {
            obj.style.width = w + "px";
        }
    } else {
        w -= 20;
        if (w < 0) {
            obj.style.width = "0px";
            obj.style.display = 'none';
            clearInterval(timeAnim[num]);
        }
        else {
            obj.style.width = w + "px";
        }
    }    
}

window.attachEvent("onload", init);
//function change_content() {

//    for (var i = 1; i <= total_content; i++) {
//        document.getElementById('divhl0' + i).style.display = 'none';
//    }
//    document.getElementById('divhl0' + now_content).style.display = 'block';
//    if (way) now_content++;
//    else now_content--;
//    if (now_content > total_content) { now_content = total_content - 1; way = 0; }
//    else if (now_content == 0) { now_content = 1; way = 1; }
//    theTimer2 = setTimeout('change_content()', timeout2);
//}
//theTimer2 = setTimeout(function() { now_content = 1; change_content(); }, timeout2);
