// JavaScript Document

function autoScroller(contentDivName, speed)
{
    var contentDiv = "#"+contentDivName;
    var scrollSpeed = (speed==null) ? 5 : parseInt(speed);
    
    // double make sure the autoScroller-container has the correct css position and overflow property
    $(contentDiv).parent().css({position:'relative',overflow:'hidden'});
    
    // set contentDiv style
    $(contentDiv).css({position:'absolute',top:0});
    // get contentDiv height
    contentDivHeight = $(contentDiv).height();

// call periodical
   $(contentDiv).everyTime(100, function(i){
        if (parseInt($(this).css('top'))>(contentDivHeight*(-1)+8))
        {
            // move scroller upwards
            offset = parseInt($(this).css('top'))-scrollSpeed+"px";
            $(this).css({'top':offset});
        }
        // reset to original position
        else
        {
            // reset to original position
            offset = parseInt($(this).parent().height())+8+"px";
            $(this).css({'top':offset});
        }
    });
    
    // on mouse over event, pause the scroller
    $(contentDiv).mouseover(function ()
    {
        speed = scrollSpeed;
        scrollSpeed = 0;       
    });
    
    // on mouse out event, start the scroller
    $(contentDiv).mouseout(function ()
    {
        scrollSpeed = speed;
    });
}

//i know... looks ass work, duplicating function... but it worked

function autoScroller2(contentDivName, speed)
{
    var contentDiv2 = "#"+contentDivName;
    var scrollSpeed2 = (speed==null) ? 5 : parseInt(speed);
    
    // double make sure the autoScroller-container has the correct css position and overflow property
    $(contentDiv2).parent().css({position:'relative',overflow:'hidden'});
    
    // set contentDiv style
    $(contentDiv2).css({position:'absolute',top:0});
    // get contentDiv height
    contentDivHeight2 = $(contentDiv2).height();
   // call periodical
   $(contentDiv2).everyTime(100, function(i){
        if (parseInt($(this).css('top'))>(contentDivHeight2*(-1)+8))
        {
            // move scroller upwards
            offset2 = parseInt($(this).css('top'))-scrollSpeed2+"px";
            $(this).css({'top':offset2});
        }
        // reset to original position
        else
        {
            // reset to original position
            offset2 = parseInt($(this).parent().height())+8+"px";
            $(this).css({'top':offset2});
        }
    });
    
    // on mouse over event, pause the scroller
    $(contentDiv2).mouseover(function ()
    {
        speed = scrollSpeed2;
        scrollSpeed = 0;       
    });
    
    // on mouse out event, start the scroller
    $(contentDiv).mouseout(function ()
    {
        scrollSpeed2 = speed;
    });
}

