

function tablecloth(cname, col1, col2, col3, col4, col5){
    this.tables = new Array();
    this.trs = {};
    this.clickAction = function(obj){};


    this.start = function(){
        var mode  = 0;
        var color = "";
        var tbl = document.getElementsByTagName("table");
        for (var i=0;i<tbl.length;i++){
            if(tbl[i].className && tbl[i].className==cname){ tables.push(tbl[i]); }
        }
        for (var i=0;i<tables.length;i++){
            tables[i].id = "_tablestripe_autoid_" + i;
            trs[tables[i].id] = tables[i].getElementsByTagName("tr");
            for (var j=0;j<trs[tables[i].id].length;j++){
                var tr = trs[tables[i].id][j];
                tr.row = j;
                if(check1(tr,j)){
                    color = (mode) ? col1 : col2;
                    mode = 1 - mode;
                    tr.bgcolor = color;
                    tr.style.backgroundColor = color;
                    tr.onmouseover = function(){ over(this,this.row); }
                    tr.onmouseout  = function(){ out(this,this.row); }
                }
            }
        }
    };

    this.over = function(obj,row){
        if(check1(obj,row)){ highlightRow(obj,row); }
    };

    this.out = function(obj,row){
        if(check1(obj,row)){ unhighlightRow(obj,row); }
    };


    this.highlightRow = function(obj,row){
        if(obj){
            obj.style.backgroundColor = (check3(obj)) ? col5 : col3;
        }
    };

    this.unhighlightRow = function(obj,row){
        if(obj){
            obj.style.backgroundColor = (check3(obj)) ? col4 : obj.bgcolor;
        }
    };

    this.check1 = function(obj,row){
        if(!obj) return false;
        return (!(obj.className.indexOf("empty") != -1));
    }

    this.check2 = function(obj){
        if(!obj) return false;
        return (!(obj.tagName == "TH"));
    };

    this.check3 = function(obj){
        if(!obj) return false;
        return obj.selected;
    };

    start();
};
