
function scroller ( basediv, divcount ){
    this.basediv = basediv;
    this.divcount = divcount;
    this.tracediv = 'trace';
    this.debug = 0;
    this.current = 0;
    
    
    this.setup = function() {
        for (var i = 0; i < this.divcount; i++){
            var div = document.getElementById( this.basediv + i );
            if ( i == this.current){
                this.warn( i + ' on');
                div.style.display = 'block';
            }
            else {
                this.warn( i + ' off');
                div.style.display = 'none';
            }
        }
    }
    
    this.select = function (elem){
        var c_div = document.getElementById( this.basediv + this.current );
            
        var attributes = {
            left: { to: -760 },
            opacity: { from: 100, to: 10 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
        
        this.current = elem;

        var n_div = document.getElementById( this.basediv + this.current );
        n_div.style.display = 'block';
        n_div.style.left = '760px';
        
        var attributes = {
            left: { to: 0 },
            opacity: { from: 10, to: 100 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
    }
    
    this.next = function() {

        var c_div = document.getElementById( this.basediv + this.current );
            
        var attributes = {
            left: { to: -760 },
            opacity: { from: 100, to: 10 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
        
        if ( (this.current + 1) > (this.divcount - 1) ){
            this.current = 0;
        }
        else {
            this.current++;
        }
        var n_div = document.getElementById( this.basediv + this.current );
        n_div.style.display = 'block';
        n_div.style.left = '760px';
        
        var attributes = {
            left: { to: 0 },
            opacity: { from: 10, to: 100 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
            

    }
    
    this.back = function() {
        var c_div = document.getElementById( this.basediv + this.current );
            
        var attributes = {
            left: { to: 760 },
            opacity: { from: 100, to: 10 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
        
        if ( (this.current - 1) < 0 ){
            this.current = this.divcount - 1;
        }
        else {
            this.current--;
        }
        var n_div = document.getElementById( this.basediv + this.current );
        n_div.style.display = 'block';
        n_div.style.left = '-760px';
        
        var attributes = {
            left: { to: 0 },
            opacity: { from: 10, to: 100 }
        };
        var anim = new YAHOO.util.Anim( this.basediv + this.current, attributes, 1, YAHOO.util.Easing.easeOut);
        anim.animate();
        
    }
    
    this.stageleft = function ( div, by ) {
        var amount = by + 5;
        div.style.left = eval("parseInt(div.style.left) + amount") + 'px';


    }
    
    this.stageright = function ( div, by ) {
        var amount = by - 5;
        div.style.left = parseInt(div.style.left) - div.style.left + 'px';
    }
    
    this.debuginit = function (){
        //document.write('<div id="trace"></div>');
        
        // Setup debug window
        var debugdiv = document.createElement('div');
        debugdiv.setAttribute('id', this.tracediv);
        debugdiv.innerHTML = "Debug window\n" + this.x('-', 80) + "\n";
        document.body.appendChild( debugdiv );
    }
    
    this.warn = function( msg ) {
        if (this.debug > 0 ) {
            document.getElementById( this.tracediv ).innerHTML += msg + "\n";
        }
    }
    
    this.x = function (v,i){
        var vv = '';
        for(var ii = 0; ii < i; ii++){
            vv += v;
        }
        return(vv);
    }
    
    if (this.debug > 0 ) this.debuginit() ;
    
    this.setup();
}