 // <![CDATA[

var scrollerDiv = function(div, cBorder, controls) {

    this.tPos = 0;
    this.margin = 10;

    this.scrollDiv = document.getElementById(div);
    this.h = this.scrollDiv.offsetHeight ;

    if (document.all) cBorder = 0;

    // Set style to the scrollable layer
    if (/Safari/i.test(navigator.userAgent)) {
        //this.scrollDiv.className = (!usesafari)? 'jsonsafari' : 'json';
        this.scrollDiv.className = 'json';
    }
    else {
        this.scrollDiv.className = 'json';
    }

    this.scrollDiv.style.width    = (this.scrollDiv.parentNode.offsetWidth - (this.margin * 2)) - 5 + 'px';

    // Set overflow to the containing layer
    this.scrollDiv.parentNode.className = 'json';

    // Set clip paramaters
    this.tClip = 0;
    this.wClip = this.scrollDiv.parentNode.offsetWidth - (this.margin * 2) - (cBorder * 2);
    this.bClip = this.scrollDiv.parentNode.offsetHeight - (this.margin * 2) - (cBorder * 2);
    this.hDiv  = this.scrollDiv.offsetHeight;

    if (this.hDiv > this.h) {
        //alert(this.hDiv +  ' ' + this.h)
        document.getElementById('c_up').src = "/img/bg/up.gif";
        document.getElementById('c_down').src = "/img/bg/down.gif";

        document.getElementById(controls).className = 'json';
        this.scrollDiv.style.clip = 'rect('+ this.tClip +'px, '+ this.wClip +'px, '+ this.bClip +'px, 0)';
    }

}

scrollerDiv.prototype = {


    scrollX : function(scrollBy, speed) {

        thisMethod = this;
        this.tClip += scrollBy;
        this.bClip += scrollBy;
        this.tPos -= scrollBy;

        if (this.tClip < 0 || this.bClip > this.hDiv) {
            this.tClip -= scrollBy;
            this.bClip -= scrollBy;
            this.tPos += scrollBy;
        }

        this.scrollDiv.style.clip = 'rect('+ this.tClip +'px, '+ this.wClip +'px, '+ this.bClip +'px, 0)';
        this.scrollDiv.style.top = this.tPos + 'px';
        this.interval = setTimeout(function() { thisMethod.scrollX(scrollBy, speed) }, speed);

    },

    stop   : function() {
        if (this.interval) clearTimeout(this.interval);
    }

};


var scDiv;

function listScroll() {
    scDiv = new scrollerDiv('testo_scroll', 0, 'testo_scroll_controls');
}

addDOMLoadEvent(listScroll);

// ]]>