﻿var Direction = "Next";
var minIndex = 0;
var currentIndex = 0;

function ShowNews(Direction) {
    if (Direction == "Next") { 
        if (currentIndex < maxIndex-1) 
            currentIndex++; 
        else 
            currentIndex = maxIndex-1; 
        var obj = document.getElementById(controlName + 'DIV' + currentIndex);
        var prevObj = document.getElementById(controlName + 'DIV' + (currentIndex - 1));
        prevObj.style.display = 'none';
        obj.style.display = 'block'; 
    } 
    
    if (Direction == "Prev") { 
        if (currentIndex > 0) 
            currentIndex--; 
        else 
            currentIndex = 0; 
        
        var obj = document.getElementById(controlName + 'DIV' + currentIndex);
        var prevObj = document.getElementById(controlName + 'DIV' + (currentIndex + 1));
        obj.style.display = 'block';
        prevObj.style.display = 'none';
    }
}

function CheckDirection() { 
    if (currentIndex == 0) { 
        Direction = 'Next'; 
    } 
    if (currentIndex == maxIndex - 1) { 
        Direction='Prev'; 
    } 
    
    ShowNews(Direction);
} 

setInterval('CheckDirection()',8000); 
