﻿var scrollTimer;
var scrolling = false;
var speechBubble;
var scrollInterval = 30;
var scrollAmount = 2;

function startScrollDown(element) {
    speechBubble = element;
    stopScroll();
    scrolling = true;
    continueScrollDown();
};

function startScrollUp(element) {
    speechBubble = element;
    stopScroll();
    scrolling = true;
    continueScrollUp();
};

function continueScrollDown() {
    if (scrolling)
        scrolltimer = setTimeout(scrollDown, scrollInterval);
}

function continueScrollUp() {
    if (scrolling)
        scrolltimer = setTimeout(scrollUp, scrollInterval);
}

function scrollDown() {
    speechBubble.scrollTop(speechBubble.scrollTop() + scrollAmount);
    continueScrollDown();
}

function scrollUp() {
    speechBubble.scrollTop(speechBubble.scrollTop() - scrollAmount);
    continueScrollUp()
}

function stopScroll() {
    scrolling = false;

}