﻿$(document).ready(function() {

    var index = 0;
    var begin = 0;

    var ItemCount = $("#answeroftheday >li").length - 1;

    $("#answeroftheday >li").each(function() {
        $(this).hide();
        if (index == begin) {
            $(this).show();
        }
        begin++;
    });

    $("#answerup").click(function() {
        if (index > 0) {
            index--;
        }
        else {
            index = 0;
        }
        ShowItem();
    });

    $("#answerdown").click(function() {
        if (index < ItemCount) {
            index++;
        }
        else {
            index = ItemCount;
        }
        ShowItem();
    });

    function ShowItem() {
        begin = 0;
        $("#answeroftheday >li").each(function() {
            $(this).hide();
            if (index == begin) {
                $(this).show();
            }
            begin++;
        });
    }
});

