function ron(row_id, row_class)
{
	//this is the default val
	if (row_class == null) row_class = "row_on";
	document.getElementById("tr_" + row_id).className = row_class;
}

function roff(row_id, row_class)
{
	if (row_class == null) row_class = "row_off_a"; //this is the default val
	if (document.getElementById("chk_" + row_id))
	{
		if(document.getElementById("chk_" + row_id).checked == false) document.getElementById("tr_" + row_id).className = row_class;
		else document.getElementById("tr_" + row_id).className = "row_selected";
	}
	else document.getElementById("tr_" + row_id).className = row_class;
}

function select_row(row_id)
{
	if (document.getElementById("chk_" + row_id))
	{
		if(document.getElementById("chk_" + row_id).checked == false)
		{
			document.getElementById("chk_" + row_id).checked = true;
			document.getElementById("tr_" + row_id).className = "row_selected";
		}
		else document.getElementById("chk_" + row_id).checked = false;
	}
}

function select_deselect_all_rows(trigger_chk_id, target_id_part, range_start, range_end)
{
	if (range_start >= 0 && range_start <= range_end)
	{
		if (document.getElementById(trigger_chk_id).checked == true)
		{
			/* select all rows */
			for (i=range_start; i<=range_end; i++)
			{
				document.getElementById("chk_" + target_id_part + i).checked = true;
				if(document.getElementById("tr_" + target_id_part + i)) document.getElementById("tr_" + target_id_part + i).className = "row_selected";
			}
		}
		else 
		{
			/* deselect all rows */
			for (i=range_start; i<=range_end; i++)
			{
				document.getElementById("chk_" + target_id_part + i).checked = false;
				if(document.getElementById("tr_" + target_id_part + i))
				{
					(i % 2 == 0) ? document.getElementById("tr_" + target_id_part + i).className = "row_off_b" : document.getElementById("tr_" + target_id_part + i).className = "row_off_a";
				}
			}
		}
	}
}

/*this function verifies if we have at least one checkbox checked*/
function check_selected(start_id, end_id, alert_message) 
{
	k = false;
	if (end_id != 0)
	{
		for (i=start_id; i<=end_id; i++)
		{
			if (document.getElementById("chk_" + i).checked == true)
			{
				k = true;
			}
		}
	}
	if (k == false)
	{
		alert(alert_message);
		return false;
	}
	else return true;
}

/*this function verifies if we have only one checkbox checked*/
function check_selected1(row_id, start_id, end_id, alert_message)
{
	k = 0;
	if (end_id != 0)
	{
		for (i=start_id; i<=end_id; i++)
		{
			if (document.getElementById("chk_" + row_id + i).checked == true)
			{
				k = k + 1;
			}
		}
	}
	if (k != 1)
	{
		alert(alert_message);
		return false;
	}
	else return true;
}