// prosvecovani radku v tabulce
// - tabulka ktera ma jednu z classu "horiz_ruler"
// - aktivni prosviceny radek ziska class "tablecurrent"
//
// s tim musi samozrejme byt ruku v ruce patricne css, tedy jen jeho reakce
// na class "tablecurrent", napriklad uplne obecne:
//
//	table.horiz_ruler tr.tablecurrent td { background-color: #ccf }

function table_horiz_ruler()
{
	var tables = document.getElementsByTagName('table');
	for (i = 0; i < tables.length; i++) {
		if (tables[i].className.match("horiz_ruler")) {
			var trs = tables[i].getElementsByTagName('tr');
			for(j = 0; j < trs.length; j++) {
				trs[j].j = j;
				trs[j].table_ref = tables[i];
				trs[j].set_current = function() { 
					this.oldClassName_before_tablecurrent = this.className;
					this.className = this.className + ' tablecurrent'; 
					this.table_ref.current_tr = this;
				}
				trs[j].reset_current = function() { 
					this.className = this.oldClassName_before_tablecurrent; 
					this.table_ref.current_tr = null;
				}
				trs[j].onmouseover = function() { 
					//my_log('row ' + this.j + ' - onmouse OVER<br>');
					if (this.table_ref.current_tr) {
						//alert('opravil jsem chybu');
						this.table_ref.current_tr.reset_current();
					}
					this.set_current();
					//if ((cur = check_horiz_ruler()) > 1)
					//	my_log('ERROR!!! ' + cur + ' lines marked as current!<br>');
				}
				trs[j].onmouseout = function() { 
					//my_log('row ' + this.j + ' - onmouse OUT<br>');
					this.reset_current();
					//if ((cur = check_horiz_ruler()) > 1)
					//	my_log('ERROR!!! ' + cur + ' lines marked as current!<br>');
				}
			}
		}
	}
}

// vrati, kolik radek ma tablecurrent - abych zjistil tu chybu
// pokud je to cislo > 1, tak je to samozrejme spatne
function check_horiz_ruler()
{
	var cur = 0;
	var tables = document.getElementsByTagName('table');
	for (i = 0; i < tables.length; i++) {
		if (tables[i].className.match("horiz_ruler")) {
			var trs = tables[i].getElementsByTagName('tr');
			for(j = 0; j < trs.length; j++) {
				if (trs[j].className.match('tablecurrent'))
					cur++;
			}
		}
	}
	return cur;
}


window.onload_before_tabler123423 = window.onload;
window.onload = function()
{
	if (window.onload_before_tabler123423)
		window.onload_before_tabler123423();
	table_horiz_ruler();
}


