﻿(function ($) {
    $(document).ready(function () {
        $('#NewsContainer .btn_Back_News').bind('click', function () {
            ShowNextNews();
        });
        $('#NewsContainer .btn_Next_News').bind('click', function () {
            ShowBackNews();
        });
    });

    var currentNews = 0;
    var newsCount = 0;

    function ShowNews() {
        newsCount = $("#NewsContainer > div").size();
        for (var i = 0; i < newsCount; i++) {
            $("#NewsContainer > div:eq(" + i + ")").hide();
        }
        $("#NewsContainer > div:eq(" + currentNews + ")").show();
    }

    function ShowNextNews() {
        currentNews++;
        if (currentNews >= newsCount) {
            currentNews = 0;
        }
        ShowNews();
    }
    function ShowBackNews() {
        currentNews--;
        if (currentNews < 0) {
            currentNews = newsCount-1;
        }
        ShowNews();
    }

    ShowNews();

    setInterval(ShowNextNews, 10000);

})(jQuery);
