function tabledecorator(){
	if (document.getElementById && document.createTextNode){
		var tables = new Array();
		var evencolor = "#f0f0f0";
		var oddcolor = "#eee";
		var oncolor = "#ddd";
		var classselector = "";
		if(arguments.length == 0){
			// no parameters: all the tables in the page will be modified with the default colors
			tables = document.getElementsByTagName('table');
		} else if(arguments.length == 1){
			// 1 parameter: if is a string, will be a class selector, otherwise an object (getElementById) to apply the format
			if(typeof(arguments[0]) == "object"){
				tables[0] = arguments[0];
			} else {
				tables = document.getElementsByTagName('table');
				classselector = arguments[0];
			}			
		} else if(arguments.length == 3){
			// 3 parameters: all the tables will be modified using the three colors passed (oddcolor, evencolor, oncolor)
			tables=document.getElementsByTagName('table');
			evencolor = arguments[0];
			oddcolor = arguments[1];
			oncolor = arguments[2];
		} else if(arguments.length == 4){
			// 4 parameters: as for 1 parameter but with colors stated as in the 3 parameters syntax
			if(typeof(arguments[0]) == "object"){
				tables[0] = arguments[0];
			} else {
				tables = document.getElementsByTagName('table');
				classselector = arguments[0];
			}
			evencolor = arguments[1];
			oddcolor = arguments[2];
			oncolor = arguments[3];
		} else {
			// wrong number of parameters have been passed
			return false;
		}
		for (var i=0;i<tables.length;i++){
			if(classselector == "" || tables[i].className == classselector){
				var trs=tables[i].getElementsByTagName('tr');
				var counter = 1;
				for(var j=0;j<trs.length;j++){
					if((trs[j].parentNode.nodeName.toLowerCase()=='tbody' ||  trs[j].parentNode.nodeName.toLowerCase()=='table') && trs[j].getElementsByTagName('th').length != trs[j].cells.length){
						trs[j].style.backgroundColor = (counter % 2) ? evencolor : oddcolor;
						trs[j].onmouseover=function(){this.style.backgroundColor = oncolor;return false}
						trs[j].counter = counter;
						trs[j].onmouseout=function(){this.style.backgroundColor = (this.counter % 2) ? evencolor : oddcolor;return false}
						counter++;
					} else {
						counter = 1;
					}
				}
			}
		}
	}
}

function init(){
	tabledecorator('pricetovar', '#ffffff','#f0f0f0','#ffcc00');
	return true;
}

window.onload = function(){
	init();
}
