(function($) {
    $.fn.qednews = function() {
        return this.each(function() {
            var me = this,
            scrollerlist = $('ul.qed_news_postlist', this),
            totalheight = scrollerlist.height(),
            windowheight = $('#qed_news_window', this).height(), movedistance = 100, moving = false;
            var next = $('#qed_news_next', me);
            $('#qed_news_next', me).click(function() { return moveNews(false) });
            $('#qed_news_prev', me).click(function() { return moveNews(true) });


            function moveNews(isUp) {
                //check for max
                if (!moving) {
                    var theTop = scrollerlist.position().top,
                        toMove = isUp ? Math.min(movedistance, (0 - theTop)) : Math.min(movedistance, (totalheight - windowheight + theTop));
                        
                    if (toMove > 0) {
                        moving = true;
                        toMove = (isUp) ? { top: (theTop + toMove) + "px"} : { top: (theTop - toMove) + "px" };
                        scrollerlist.animate(toMove, 'linear', function() { moving = false; })
                    }
                }
                return false;
            }
        });
    };
})(jQuery);
jQuery(function() {
jQuery('div.qed_news').qednews();
});