/* adds a striped effect to any TRs located within the TBODY of a table with class "sdfZebra" */

function addClass(e,c)
{
	if (e.className==undefined)
		e.className = c;
	else
		e.className += ' ' + c;
}

function hasClass(e,c)
{
	cs = e.className.split(' ');

	for(var i=0; i<cs.length; i++)
		if (cs[i]==c) return true;
	
	return false;
}

zebraEffect = function()
{
	var eTables = document.getElementsByTagName('TABLE');

	for (var i=0; i<eTables.length; i++)
	{
		if (hasClass(eTables[i], 'zebra'))
		{
			var eTableChildren = eTables[i].childNodes;
			
			for (var j=0; j<eTableChildren.length; j++)
			{
				if (eTableChildren[j].tagName=='TBODY')
				{
					var eTRs = eTableChildren[j].getElementsByTagName('TR');
					
					for (var k=0; k<eTRs.length; k++)
						addClass(eTRs[k], 'zebra' + (k%2 + 1));
				}
			}
		}
		if (hasClass(eTables[i], 'zebra2'))
		{
			var eTableChildren = eTables[i].childNodes;
			
			for (var j=0; j<eTableChildren.length; j++)
			{
				if (eTableChildren[j].tagName=='TBODY')
				{
					var eTRs = eTableChildren[j].getElementsByTagName('TR');
					
					for (var k=0; k<eTRs.length; k++)
					{
						addClass(eTRs[k], 'dblzebra' + (k%4 + 1));
					}
				}
			}
		}
	}
}

//this trick cannot be done by a pseudoclass, so we make sure we apply to all browsers
if (window.attachEvent)
	window.attachEvent("onload", zebraEffect);	//apply to opera and ie
else
	window.addEventListener("load", zebraEffect, true); //apply to mozilla and firefox
	
//should I use true or false - what's the difference?
