// function for striping tables
// CREDIT FOR THIS SCRIPT: Matthew Pennell
// URL: http://www.thewatchmakerproject.com


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/,"");
}

function addClassName(el,className) {
	removeClassName(el,className);
	el.className = (el.className + " " + className).trim();
}

function removeClassName(el,className) {
	el.className = el.className.replace(className,"").trim();
}

var ZebraTable = {
	bgcolor: '',
	classname: '',
	stripe: function(el) {
		if (!$(el)) return;
		var rows = $(el).select('tr');
		for (var i=1,len=rows.length;i<len;i++) {
			if (i % 2 == 0) rows[i].className = 'alt';
			Event.observe(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
			Event.observe(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
			Event.observe(rows[i],'click',function() { ZebraTable.click(this); });
		}
	},
	mouseover: function(row) {
		this.bgcolor = row.style.backgroundColor;
		this.classname = row.className;
		addClassName(row,'over');
	},
	
	mouseout: function(row) {
		removeClassName(row,'over');
		addClassName(row,this.classname);
		row.style.backgroundColor = this.bgcolor;
	},
		
	click: function(row) {
	  anchor = row.select('a');
	  document.location.href = anchor;
	}
}

