//FUNCTIONS TO STRIPE TABLES

//script modified from http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html

function zebra(){
	if(document.getElementsByName && document.getElementsByTagName) //check to make sure it's browser supported
	{

		// define used variables
		var momtable,mombodys,i,j,addclass,colourclass;

		// define the class to add to colourise the rows
		var colourclass='colouredrow';

		// grab the table, and each tbody in it.
		momtable=document.getElementsByName('stripeMe');

		for (k=0;k<momtable.length;k++)
		{	
			mombodys=momtable[k].getElementsByTagName('tbody');

			// loop through the rows of the bodys
			for (i=0;i<mombodys.length;i++)
			{
				momtrs=mombodys[i].getElementsByTagName('tr')
				for (j=0;j<momtrs.length;j++)
				{
					// if the rows don't contain any headers
					if(momtrs[j].getElementsByTagName('th').length==0)
					{
						// add the class colourclass to each second row.
						addclass=j%2==0?' '+colourclass:'';
						momtrs[j].className=momtrs[j].className+addclass;

						// call the function hlrow 
						momtrs[j].onmouseover=function(){hlrow(this);};
						momtrs[j].onmouseout=function(){hlrow(this);};
					} //end if
				} //end for
			} //end for
		} //end for
	} //end if(document.getElementById...
} //end function zebra



function hlrow(o)
{
	// check if the row's classname already contains hl and replace respectively 
	// add it.
	o.className=/hl/.test(o.className)?o.className.replace('hl',''):o.className+' hl';
} //end function hlrow
	
	

