﻿(function($) {
    $.fn.vScroll = function(options) {
    var defaults = { speed: 500, upID: "#up-arrow", downID: "#bottom-arrow" };
    var options = $.extend(defaults, options);
    return this.each(function() {
        obj = $(this); obj.css("overflow", "hidden");
        obj.children().each(function(intIndex)
        { $(this).addClass("vscroll-" + intIndex); });
        var itemCount = 0;
        $(options.downID).click(function() {
            var nextCount = itemCount + 1;
            if ($('.vscroll-' + nextCount).length) {
                var divH = $('.vscroll-' + itemCount).outerHeight(); 
                itemCount++;
                $("#vscroller").animate({ top: "-=" + 500 + "px" }, options.speed);
            } 
        });
        $(options.upID).click(function() {
            var prevCount = itemCount - 1;
            if ($('.vscroll-' + prevCount).length) {
                itemCount--;
                var divH = $('.vscroll-' + itemCount).outerHeight();
                $("#vscroller").animate({ top: "+=" + 500 + "px" }, options.speed);
            } 
        }); 
        obj.children().wrapAll("<div style='position: relative; top: 0' id='vscroller'></div>"); }); }; })(jQuery);
