﻿$(document).ready(function() {
    var currentItem = 0;
    var numberOfItems = $("#newsContent li").length;
    var paddingBottom = 10;
    var banimate = false;
    $("#newsArea").css("overflow", "hidden");

    $("#down").click(function() {
        if (currentItem != (numberOfItems - 1) && banimate == false) {
            banimate = true;
            var height = $("#newsContent li:eq(" + currentItem + ")").height() + paddingBottom;
            window.status = height + ":" + currentItem;
            var marginTop = parseInt($("#newsContent").css("margin-top"), 10);
            height = height * -1;
            $("#newsContent").animate({
                marginTop: marginTop + height
            }, 500, "linear", animateComplete);

            currentItem++;
        }
    });

    $("#up").click(function() {
        if (currentItem != 0 && banimate == false) {
            banimate = true;
            var height = $("#newsContent li:eq(" + (currentItem - 1) + ")").height() + paddingBottom;
            window.status = height + ":" + currentItem;
            var marginTop = parseInt($("#newsContent").css("margin-top"), 10);
            $("#newsContent").animate({
                marginTop: marginTop + height
            }, 500, "linear", animateComplete);
            currentItem--;
        }
    });

    function animateComplete() {
        banimate = false;
    }
});
	