﻿//自动定时切换容器
function AutoChangeWin(containerId, time) {
    var index = 0;
    var allowPause = false;
    var _time = 2000;

    {
        if (time != null) {
            _time = time;
        }
    }

    function Process() {
        if (allowPause == false) {
            var objs = document.getElementById(containerId).childNodes;

            if (objs != null && objs.length > 0) {
                for (var i = 0; i < objs.length; i++) {
                    objs[i].style.display = "none";
                }

                objs[index].style.display = "";


                index++;

                if (index >= objs.length) {
                    index = 0;
                }
            }
        }

        setTimeout(Process, _time);
    }

    function Start() {
        Process();
    }

    function Pause() {
        allowPause = true;
    }

    function Resume() {
        allowPause = false;
    }

    this.Run = function() {
        document.getElementById(containerId).onmouseover = function() {
            Pause();
        }
        document.getElementById(containerId).onmouseout = function() {
            Resume();
        }
        Start();
    }
}