﻿var _currentIndex = 0;
var _prevIndex = 1;
var _nbSlide = 0;
var _lastIndex;
var timeout1;
var up = true;


function InitSlide(duration) {
    var chkList = document.getElementsByTagName("div");
    var _first = true;
    for (var i = 0; i < chkList.length; i++) {

        if (chkList[i].id == "divSlide") {
            if (_first) {
                
                _first = false;
            }
            _nbSlide++;
            _lastIndex = i;
        }
    }

    timeout1 = setInterval("NextSlide()", duration);
}

function NextSlide() {

    var chkList = document.getElementsByTagName("div");

    if (up) {
        _currentIndex++;
    }
    else {
        _currentIndex--;
    }

    _slideIndex = 0;

    for (var i = 0; i < chkList.length; i++) {

        if (chkList[i].id == "divSlide") {

            _slideIndex++;

            if (_currentIndex >= _nbSlide) {
                up = false;
                _slideIndex--;
            }
            if (_currentIndex == 0) {
                up = true;
            }
            if (_slideIndex == _currentIndex) {
                if (up) {

                    //Effect.SlideUp(chkList[i]);
                    Effect.Squish(chkList[i]);
                }
                else {
                    Effect.Grow(chkList[i]);
                }

//                if (_currentIndex % 2) {
//                    timeout1 = null;
//                    timeout1 = setInterval("NextSlide()", 11000);
//                }
//                else {
//                    timeout1 = null;
//                    timeout1 = setInterval("NextSlide()", 3000);
//                }
                
                return;

            }

        }
    }

}

