    function debug(msg) {
        return;
        
        document.getElementById('debug').innerHTML += msg + "<br>";
    }
    function clearTO() {
        clearTimeout(toid);
    }
    var toid;
    function slide(eltid, byleft) {
        var elt = document.getElementById(eltid);
        if(!elt) { debug("bad id... [" + eltid + "]"); return;}
        var dest = getLeft(elt) + byleft;
        slide_to(eltid, dest);
    }
    
    function getLeft(elt) {
        /*if(elt.style) {        
            var str = elt.style.left;
            if(str) {
                var m = str.match('^(\-?[0-9]+).*');
                if(m) {
                    return parseInt(m[1]);
                }
            }
        }*/
        return elt.offsetLeft;
    }
    var SLIDE_TO_INTERVAL = document.all/* is IE */ ? 100 : 50;
    var SLIDE_TO_INC = 50;
    function slide_to(eltid, left) {
        clearTO();
        var elt = document.getElementById(eltid);
        if(!elt) { debug("bad id... [" + eltid + "]"); return;}
        
        var inc = SLIDE_TO_INC;
        var atleft = getLeft(elt);
        debug("&nbsp;&nbsp;&nbsp;&nbsp;" + atleft + " &lt;?&gt;" + left);        
        var dest;
        if(Math.abs(left - atleft) <= inc ) {            
            elt.style.left = left + "px";
        }
        else if(atleft < left) {
            dest = (atleft + inc);
        }
        else if(atleft > left) {
            dest = (atleft - inc);
        }        
        else {
            return;
        }
        debug(dest);
        if(!dest) {return; }
        elt.style.left = dest + "px";
        var call = "slide_to('" + eltid + "', " + left + ")";
        debug('calling: ' + call);
        toid = setTimeout(call, SLIDE_TO_INTERVAL);
    }
    
    function move_to(eltid, left) {
        clearTO();
        var elt = document.getElementById(eltid);
        if(!elt) { debug("bad id... [" + eltid + "]"); return;}
        var atleft = getLeft(elt);
        elt.style.left = left + "px";
    }
//----------------------------------------------------------------

    function clearScrollCall() {
        //clearTO();
        clearTimeout(scroll_mousedown_id);
    }
    function control_state() {
       
        var tbl = document.getElementById('scrollme');
        var px = 0 - tbl.rows[0].cells[col_ind].offsetLeft;
        var parent_w = tbl.parentNode.offsetWidth;
        var tbl_w = tbl.offsetWidth;
        
        if( col_ind >= tbl.rows[0].cells.length -3) {
            document.getElementById('scroll_left').style.color=DEAD_COLOR;
            document.getElementById('scroll_left').style.cursor='default';
            
        }
        else {
            if(document.getElementById('scroll_left').style.color == DEAD_COLOR) {
                document.getElementById('scroll_left').style.color=NORMAL_COLOR;
                document.getElementById('scroll_left').style.cursor='pointer';
            }
        }
        
        if(col_ind <= 0) {
            document.getElementById('scroll_right').style.color = DEAD_COLOR;
            document.getElementById('scroll_right').style.cursor='default';
        }
        else {
            if(document.getElementById('scroll_right').style.color == DEAD_COLOR) {
                document.getElementById('scroll_right').style.color = NORMAL_COLOR;            
                document.getElementById('scroll_right').style.cursor='pointer';
            }
        }
    }
    
    var col_ind = 0;
    var DEAD_COLOR = "black";
    var HOVER_COLOR = "limegreen";
    //~ var NORMAL_COLOR = "#00A500";
    var NORMAL_COLOR = "white";
    
    var scroll_mousedown_id;
    function getPixelsFromColumn(tblid, col) {
        var tbl = document.getElementById(tblid);
        return tbl.rows[0].cells[col].offsetLeft;
    }
    function scroll_mousedown(inc) {
        //var px = (left + inc*30);
        col_ind -=inc;
        if(col_ind <= 0) {
            clearScrollCall();
            col_ind = 0; 
        }
        
        var tbl = document.getElementById('scrollme');        
        if(col_ind >= tbl.rows[0].cells.length -2) {
            col_ind = tbl.rows[0].cells.length -3;
            clearScrollCall();
            return;
        }
        var px = 0 - getPixelsFromColumn(tbl.id, col_ind);
        
        var parent_w = tbl.parentNode.offsetWidth;
        var tbl_w = tbl.offsetWidth;
        /*if(px + tbl_w < parent_w) {
            clearScrollCall();
            col_ind += inc;
            return;
        }*/
        slide_to('scrollme',px);
        control_state();
        scroll_mousedown_id = setTimeout("scroll_mousedown(" + inc + ")", SLIDE_TO_INTERVAL *5);
    }
    function hover_scroll(eltid) {
        var elt = document.getElementById(eltid);
        if(elt.style.color != DEAD_COLOR) { 
            elt.style.color = HOVER_COLOR;
        }
    }
    function nohover_scroll(eltid) {
        var elt = document.getElementById(eltid);
        debug(elt);
        if(elt.style.color != DEAD_COLOR) { 
            elt.style.color = NORMAL_COLOR;
        }
    }
