var marked_row = new Array;

function sCl(theRow, theRowNum, theAction, thePointerClass, theMarkClass, notStayHighlighted, styleUsual, styleAlternating, alternatingActive, stylePremiumUsual, stylePremiumAlternating, sortedCell, tabid, markid)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerClass == '' && theMarkClass == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var newClass     = null;
    var cellsPerRow  = theCells.length;
    var c			 = null;

	if (typeof(theCells[cellsPerRow-1].className) == 'undefined') {
		return false;
	}

	if (theAction == 'c') {
		if(notStayHighlighted == 1)
	    {
			var c_r = marked_row.length / cellsPerRow;
			var trs = document.getElementById(tabid).rows.length;
			for(var j = 0; j < trs; j++)
	    	{
				if(theRowNum == j)
				{
					if(document.getElementById(markid))
					{
						document.getElementById(markid).value = theRowNum;
					}
				}
				var daClass = styleUsual;
				var daPremiumClass = stylePremiumUsual;
				if(j % 2 == 0 && alternatingActive == true)
				{
					var daClass = styleAlternating;
					var daPremiumClass = stylePremiumAlternating;
				}
	    		if(document.getElementById(tabid).rows[j])
    			{
	    			var cell = document.getElementById(tabid).rows[j].getElementsByTagName('td');
	    			var cpr = cell.length;
	    			for (c = 0; c < cpr; c++)
		    		{
		    			if(c == (sortedCell - 1) && sortedCell > 0 && daPremiumClass != '')
		    			{
		    				cell[c].className = daPremiumClass;
		    			}
		    			else
		    			{
		    				cell[c].className = daClass;
		    			}
	    			}
	    		}
	    	}
	    }
		if (theCells[cellsPerRow-1].className == theMarkClass) {
			for (c = 0; c < cellsPerRow; c++) {
			if (theCells[c].className != "locked") {
			 theCells[c].className = marked_row[theRowNum * cellsPerRow + c];
			}
			}
		} else {
			newClass              = theMarkClass;
			for (c = 0; c < cellsPerRow; c++) {
			if (theCells[c].className != "locked") {
			 theCells[c].className = newClass;
			}
			}
		}
	}
	else if (theAction == 'ov') {
	    if (theCells[cellsPerRow-1].className == theMarkClass) {
			return false;
		}
		newClass              = thePointerClass;
	    for (c = 0; c < cellsPerRow; c++) {
 		if (theCells[c].className != "locked") {
		 marked_row[theRowNum * cellsPerRow + c] = theCells[c].className;
		 theCells[c].className = newClass;
		}
		}

	}
	else if (theAction == 'out') {
	    if (theCells[cellsPerRow-1].className == theMarkClass) {
			return false;
		}
	    for (c = 0; c < cellsPerRow; c++) {
		if (theCells[c].className != "locked") {
 		 theCells[c].className = marked_row[theRowNum * cellsPerRow + c];
		}
		}
	}


    return true;
} // end of the 'sCl()' function
