function addArticleToBasket(artno) {
    document.myForm.addArticle.value = artno;
    document.myForm.scrollPos.value = document.getElementById("scrollDiv").scrollTop;
    document.myForm.submit();
}

function hooverLine(elem, artno) {
    document.getElementById("artno_" + artno).style.backgroundColor = "#D0D0D0";
    document.getElementById("text_" + artno).style.backgroundColor = "#D0D0D0";
    document.getElementById("price_" + artno).style.backgroundColor = "#D0D0D0";
    elem.style.cursor = "pointer";
}

function unhooverLine(elem, artno) {
    document.getElementById("artno_" + artno).style.backgroundColor = "#FFFFFF";
    document.getElementById("text_" + artno).style.backgroundColor = "#FFFFFF";
    document.getElementById("price_" + artno).style.backgroundColor = "#FFFFFF";
    elem.style.cursor = "normal";
}

var movementPerStep = 1;
var timeBetweenSteps = 40;
var offset = 0;
var container;
var repetitions;
var timer;
var startPosition;

// FUNCTIONS \\

function stopMovement() {
    window.clearInterval(timer);
}
function startMovement() {
    timer = window.setInterval("moveLeft();", timeBetweenSteps);
}

function mod(a, b) {
    if (a < 0) {
        return -((-a) % b - b);
    } else {
        return a % b;
    }
}

function moveLeft() {

    for (var i = 0; i < repetitions; i++) {

        container.childNodes[i].style.left = (parseInt(container.childNodes[i].style.left) - movementPerStep) + "px";
        if (parseInt(container.childNodes[i].style.left) < -container.childNodes[i].offsetWidth) {
            previous = mod(i - 1, container.childNodes.length);
            container.childNodes[i].style.left = (
                    parseInt(container.childNodes[previous].style.left)
                            + container.childNodes[previous].offsetWidth
                    ) + "px";
        }

    }

}

function appendTextContainer() {

    newNode = document.createElement("div");
    newNode.innerHTML = completeNewsText;
    with (newNode.style) {
        position = "absolute";
        display = "inline";
        left = (startPosition + offset) + "px";
        whiteSpace = "nowrap";
    }
    container.appendChild(newNode);
    offset += newNode.offsetWidth;

}

function getZIndex(node) {

    zIndex = null;
    currentNode = node;
    while (currentNode != document.body && zIndex == null) {
        if (currentNode.style && currentNode.style.zIndex) {
            zIndex = parseInt(currentNode.style.zIndex);
        }
        currentNode = currentNode.parentNode;
    }

    if (zIndex == null) {
        return 0;
    } else {
        return zIndex;
    }
}
