﻿

//--------------- Scroll news -----------------------------------//

var theTop = 120;
var theHeight = 120;
var allowTomove = true;
var firstRun = true;

function scrollNews(newsDiv, toMove) {
    if (firstRun) {
        $('#' + newsDiv).hover(function () { allowTomove = false; });
        $('#' + newsDiv).mouseleave(function () { allowTomove = true; });
        firstRun = true;
    }
    if (allowTomove) {
        theDiv = document.getElementById(newsDiv);
        if (theDiv == null) { return; }
        if (document.layers) {
            theDiv.top = theTop - toMove;
        }
        else {
            theDiv.style.top = theTop - toMove + 'px';
        }
        if ((theTop + theHeight - toMove) < (theTop - theHeight - 100)) {
            toMove = 0;
            if (document.layers) {
                theDiv.top = theTop - toMove;
            }
            else {
                theDiv.style.top = theTop + 'px';
            }
        }
        toMove = (toMove + 1);
    }
    setTimeout("scrollNews('" + newsDiv + "'," + toMove + ")", 50);

}
//---------------End Scroll news -----------------------------------//


$(document).ready(function () {

    if (document.getElementById('scrollnews')) {
        scrollNews('scrollnews', theHeight - 50);
    }

});
