// create odd / even tables

//	author: martin (dot) krause (at) gpm (dot) de 

if (styleTables) { throw new Error(0,"styleTables already defined");}
else 
{

	var styleTables = {
		
		classOdd: 'odd',
		classEven: 'even',
		classHover: 'hover',
	
		// create striped tables
		createOddEven: function(marker,root) {

			//object detection
			if(
				!document.getElementsByTagName
			){return true;}

			// set parent element, if empty use document body
			var root = root || document.body ;
			var marker = marker || '';

			// grab table elements, cycle 'em and check for marker as classname
			var tables = root.getElementsByTagName('table');
			var myRegExp = new RegExp((marker), 'g');
			var n = tables.length;

			while(n--)
			{
				var tablecn = tables[n].className;
				var match =  tablecn.match(myRegExp,marker);
				// marker present, so ...
				if (match)
				{
					// grab all of this table's tr elements, cycle, add classname
					var rows = tables[n].getElementsByTagName('tr');
					var m = rows.length;

					while (m--)
					{
		
						rows[m].className += (m % 2 == 1) ? ' '+ styleTables.classOdd : ' '+styleTables.classEven ;
				// usind evt.add
						evt.add(rows[m],'mouseover',function(){this.className += ' '+styleTables.classHover; return false;})
						evt.add(rows[m],'mouseout',function(){this.className = this.className.replace((' '+styleTables.classHover), ''); return false;})
						// plain event
						/*
						rows[m].onmouseover=function(){
							this.className += ' '+styleTables.classHover; return false
						}
						rows[m].onmouseout=function(){
							this.className = this.className.replace((' '+styleTables.classHover), ''); return false
						}
						*/

					}
				}
			}
		}
	}
}


