/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background Class
 * @param   string    the Class to use for mouseover
 * @param   string    the Class to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
var marked_row = new Array;
	function _setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerClass, theMarkClass){
	    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;
	    }
	
	    
	    
	    // 3. Gets the current Class...
	    var rowCellsCnt  = theCells.length;
	    var domDetect    = null;
	    var currentClass = null;
	    var newClass     = null;
	    
	    
	    currentClass = theCells[0].className;
	    // 3.1 ... with DOM compatible browsers except Opera that does not return
	    //         valid values with "getAttribute"
	    /*
	    if (typeof(window.opera) == 'undefined'
	        && typeof(theCells[0].getAttribute) != 'undefined') {
	        theCells[0].getAttribute('class');
	        domDetect    = true;
	    }
	    // 3.2 ... with other browsers
	    else {
	        currentClass = theCells[0].style.backgroundClass;
	        domDetect    = false;
	    } // end 3

	    // 3.3 ... Opera changes Classs set via HTML to rgb(r,g,b) format so fix it
	    if (currentClass.indexOf("rgb") >= 0) 
	    {
	        var rgbStr = currentClass.slice(currentClass.indexOf('(') + 1,
	                                     currentClass.indexOf(')'));
	        var rgbValues = rgbStr.split(",");
	        currentClass = "#";
	        var hexChars = "0123456789ABCDEF";
	        for (var i = 0; i < 3; i++)
	        {
	            var v = rgbValues[i].valueOf();
	            currentClass += hexChars.charAt(v/16) + hexChars.charAt(v%16);
	        }
	    }
		*/
	    // 4. Defines the new Class
	    // 4.1 Current Class is the default one
	    if (currentClass == ''
	        || currentClass.toLowerCase() == theDefaultClass.toLowerCase()) {
	        if (theAction == 'over' && thePointerClass != '') {
	            newClass              = thePointerClass;
	        }
	        else if (theAction == 'click' && theMarkClass != '') {
	            newClass              = theMarkClass;
	            marked_row[theRowNum] = true;
	            // Garvin: deactivated onclick marking of the checkbox because it's also executed
	            // when an action (like edit/delete) on a single item is performed. Then the checkbox
	            // would get deactived, even though we need it activated. Maybe there is a way
	            // to detect if the row was clicked, and not an item therein...
	            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
	        }
	    }
	    // 4.1.2 Current Class is the pointer one
	    else if (currentClass.toLowerCase() == thePointerClass.toLowerCase()
	             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
	        if (theAction == 'out') {
	            newClass              = theDefaultClass;
	        }
	        else if (theAction == 'click' && theMarkClass != '') {
	            newClass              = theMarkClass;
	            marked_row[theRowNum] = true;
	            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
	        }
	    }
	    // 4.1.3 Current Class is the marker one
	    else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) {
	        if (theAction == 'click') {
	            newClass              = (thePointerClass != '')
	                                  ? thePointerClass
	                                  : theDefaultClass;
	            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
	                                  ? true
	                                  : null;
	        }
	    } // end 4
	
	    // 5. Sets the new Class...
	    if (newClass) {
	        var c = null;
	        
	        for (c = 0; c < rowCellsCnt; c++) {
	        	theCells[c].className = newClass;
	        } // end for
	        
	    } // end 5
	
	    return true;
	} // end of the 'setPointer()' function
