/*	
	RowHighlight.js v 1.0	
	Author:  Nitin Menon
	Date:	 7/18/2007 	
*/

var Highlight = {
	init: function(){
		this.HIGHLIGHT_CLASS = 'highlight';					// Class to use when cursor is hovering over the row
		this.TR_CLASSES = '(all)'; // [REGEXP] TR classes that need highlighting attached
		this.CHECKBOX_NAME = 'delete';						// [OPTIONAL] Toggle row color if a checkbox is clicked on that row 
		this.SELECTED_ROW_COLOR = '#D6DEEC';				// Color of row when the check box is checked
		this.AttachEvents();
	},
	AttachEvents: function(){
		var TR = document.getElementsByTagName("tr");	
		var regex = new RegExp( this.TR_CLASSES );
		for ( var j = 0; j < TR.length; j++ ) {
			var _TR = TR[ j ];
			var TR_CLASS = _TR.className; 
			if( regex.test( TR_CLASS ) ){
				_TR.onmouseover = function() {
					Highlight.OnMouseover( this );
				};
				_TR.onmouseout = function() {
					Highlight.OnMouseout( this );
				};
			}
		}
		if( this.CHECKBOX_NAME ){
			var _INPUTCHECKBOX = document.getElementsByName( this.CHECKBOX_NAME );
			for ( var _k = 0; _k < _INPUTCHECKBOX.length; _k++ ){
				var _INPUT = _INPUTCHECKBOX[ _k ];
				if( _INPUT.type == 'checkbox' ){
					_INPUT.onclick = function(){
						Highlight.OnClick( this );	
					};
				}
			}
		}
	},
	OnMouseover: function( el ){
		this.OLD_CLASS = el.className;
		el.className = this.HIGHLIGHT_CLASS;
	},
	OnMouseout: function( el ){
		if( this.OLD_CLASS ) el.className = this.OLD_CLASS;
	},
	OnClick: function( el ){
		TR = el.parentNode.parentNode;
		TR.style.backgroundColor = el.checked ? this.SELECTED_ROW_COLOR : "";
	}
}
//window.onload = function(){ Highlight.init(); };
//if (window.attachEvent) window.attachEvent("onload", Highlight.init);