var stripe_class = {
	stripe: function()
	{
		if (!document.getElementsByTagName)
		{
			return;
		}		
		// Find all tables.
		nodeList_table = document.getElementsByTagName("table");
		
		// Traverse the tables looking for those with class: "stripe_me"
		for (i_table = 0; i_table < nodeList_table.length; i_table++)
		{
			cur_table = nodeList_table[i_table];
			if (cur_table.className.indexOf("stripe_me") != -1)
			{
				// A table can have multiple <tbody>'s.
				// Each <tbody> will be striped separately.
				nodeList_tbody = cur_table.getElementsByTagName("tbody");
				for(i_tbody = 0; i_tbody < nodeList_tbody.length; i_tbody++)
				{
					cur_tbody = nodeList_tbody[i_tbody];
					cur_rows = cur_tbody.rows;
					num_rows = cur_rows.length;
					
					// Stripe every other row.
					alt_count = 0;
					for(i_rows = 0; i_rows < num_rows; i_rows++)
					{
						// Do not consider rows that are hidden. (display: none)
						if (cur_rows[i_rows].style.display.indexOf("none") == -1)
						{
							alt_count++;
							if(alt_count % 2 == 0)
							{
								remove_class(cur_rows[i_rows], 'alt');
								add_class(cur_rows[i_rows], 'alt');
							}
							else
							{
								remove_class(cur_rows[i_rows], 'alt');
							}
						}
						event.add(cur_rows[i_rows], "mouseover", function() { stripe_class.highlight_on(this); }, false);
						event.add(cur_rows[i_rows], "mouseout", function() { stripe_class.highlight_off(this); }, false);
						event.add(cur_rows[i_rows], "click", function() { stripe_class.select(this); }, false);
					}
				}
			}
		}
	}, 
	
	highlight_on: function(row)
	{
		add_class(row, "over");
	},
	
	highlight_off: function(row)
	{
		remove_class(row, "over");
	},
	
	select: function(row)
	{
		// If the row is already selected, remove the selection when you click it again.
		// Otherwise, select the row.
		if (row.className.indexOf("selected") != -1)
		{
			remove_class(row, "selected");
		}
		else
		{
			add_class(row, "selected");
		}
	}
}

event.add(window, "load", function() { stripe_class.stripe(); }, false);