// scroller di iframes in JavaScript

// Soluzione adattata di Damon Bonesi, 2009

var oMyTimer = null;

function MyIFrameScroller(MyIFrameName, Action)
{
    var MyIntervalTime = 50;
    var oMyIframe = window.frames[MyIFrameName];

    switch (Action)
    {
        case "Up"    :
        case "Down"    :
            oMyTimer = setInterval("ScrollFrame('" + MyIFrameName + "', '" + Action + "')", MyIntervalTime);
            break;
        case "Stop"    :
            if (oMyTimer != null)
            {
                clearInterval(oMyTimer);
                oMyTimer = null;
            }
            break;
        case "Reset"    :
            ScrollFrame(MyIFrameName, Action)
            break;
        default    :
            break;
    }
}

function ScrollFrame(MyIFrameName, Action)
{
	var oMyIframe = window.frames[MyIFrameName];
    var nScrollUnit = 3;
 
    switch (Action)
    {
        case "Reset"    :
            oMyIframe.scroll(0, 0);
            break;
        case "Up"    :
            oMyIframe.scrollBy(0, -nScrollUnit);
            break;
        case "Down"    :
            oMyIframe.scrollBy(0, nScrollUnit);
            break;
        default    :
            break;
    }
}


// Chiamare questa funzione tipo MyIFrameScroller(MyIFrameName, "Up") o MyIFrameScroller(MyIFrameName, "Down") e poi MyIFrameScroller(MyIFrameName, "Stop")
