var theRowId, theRow;
var allRows = new Array();
var selectedRows = new Array();
var selectedRowsClasses = new Array();
var selectedRowsChecked = new Array();


function prepareRows()
{
	allRows = document.getElementsByTagName("tr");

	for (var i = 0; i < allRows.length; i++) {
		if ((theRowId = allRows[i].id.split("_",2)[1]))
		{
			selectedRows[theRowId] = theRowId;
			selectedRowsClasses[theRowId] = allRows[i].className;
			selectedRowsChecked[theRowId] = false;
		}
	}
}




function checkRow( rowId )
{
	theRow = document.getElementById( 'r_' + rowId );
	if (theRow.className == 'trOn' && selectedRowsChecked[rowId])
	{
		selectedRowsChecked[rowId] = false;
	}
	else if (!selectedRowsChecked[rowId])
	{
		theRow.className = 'trOn';
		selectedRowsChecked[rowId] = true;
	}
}




function highlightRow( rowId )
{
	theRow = document.getElementById( 'r_' + rowId );
	if (!selectedRowsChecked[rowId])
	{
		theRow.className = (theRow.className == 'trOn') ? selectedRowsClasses[rowId] : 'trOn';
	}
}




function hideRows()
{
	var t_flag = false;
	for (var i = 0; i < allRows.length; i++) {
		if ((theRowId = allRows[i].id.split("_",2)[1])) {
			if (selectedRowsChecked[theRowId]) {
				t_flag = true;
				break;
			}			
		}
	}
	if (!t_flag) {return;}

	for (var i = 0; i < allRows.length; i++) {
		rowId = allRows[i].id.split("_",2)[1];
		if (theRow = document.getElementById( 'r_' + rowId )) {
			if (selectedRowsChecked[rowId])
			{
				theRow.className = selectedRowsClasses[rowId];
			}
			else
			{
				theRow.style.display = 'none';
			}
		}
	}

	if (btn_hide = document.getElementById('dl_rows_hide') )	{
		btn_hide.className = (btn_hide.className=='pUp') ? 'pDown' : 'pUp';
	}
	if (btn_show = document.getElementById('dl_rows_show') )	{
		btn_show.className = (btn_show.className=='pUp') ? 'pDown' : 'pUp';
	}
}




function showRows()
{
	for (var i = 0; i < allRows.length; i++) {
		rowId = allRows[i].id.split("_",2)[1];
		if (theRow = document.getElementById( 'r_' + rowId )) {
			if (selectedRowsChecked[rowId])
			{
				theRow.className = 'trOn';
			}
			else
			{
				if (navigator.userAgent.indexOf("Firefox") != -1) {
					theRow.style.display = 'table-row';
				}
				else
				{
					theRow.style.display = 'block';
				}
				theRow.className = selectedRowsClasses[rowId];
			}
		}
	}

	if (btn_hide = document.getElementById('dl_rows_hide') )	{
		btn_hide.className = (btn_hide.className=='pUp') ? 'pDown' : 'pUp';
	}
	if (btn_show = document.getElementById('dl_rows_show') )	{
		btn_show.className = (btn_show.className=='pUp') ? 'pDown' : 'pUp';
	}
}