oldTableRulerFunc = window.onload;
window.onload = function() {
	if(typeof oldTableRulerFunc == 'function') {
		oldTableRulerFunc();
	}
	TableRuler();
}

function TableRuler()
{
	if (document.getElementById &&  document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(CssClasses(tables[i]).exists('list'))
			{
				var trs=tables[i].getElementsByTagName('tr');
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT' && !CssClasses(trs[j]).exists('inline')  && !CssClasses(trs[j]).exists('no_ruled') && !CssClasses(trs[j]).exists('cell_selected'))
					{
						trs[j].onmouseover = function(){
							if (!this.marked && !$(this).hasClass('no_ruled')) {
								this.style.backgroundColor='#fef5e7';
								
								allocIds = getAllocatedRows(this.id);
								for(var k = 0; k < allocIds.length; k++) {
									tr_obj = document.getElementById(allocIds[k]);
									if(tr_obj != null) {
										tr_obj.style.backgroundColor='#fef5e7';
									}
								}
							}
						}
						trs[j].onmouseout  = function(){
							if (!this.marked && !$(this).hasClass('no_ruled')) {
								this.style.backgroundColor = '';
								
								allocIds = getAllocatedRows(this.id);
								for(var k = 0; k < allocIds.length; k++) {
									tr_obj = document.getElementById(allocIds[k]);
									if(tr_obj != null) {
										tr_obj.style.backgroundColor='';
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function getAllocatedRows(row_id) {
	if(row_id == null || row_id == '') {
		return new Array();
	}
	if(row_id.indexOf('_addinfo') >= 0) {
		tr_parent_id = row_id.substr(0,row_id.indexOf('_addinfo'));
		return new Array(tr_parent_id, tr_parent_id+'_addrow1', row_id);
	} else if(row_id.indexOf('_addrow1') >= 0) {
		tr_parent_id = row_id.substr(0,row_id.indexOf('_addrow1'));
		return new Array(tr_parent_id, row_id, tr_parent_id+'_addinfo');
	} else {
		return new Array(row_id, row_id+'_addrow1', row_id+'_addinfo');
	}
}
