/*
	(c) Copyright Mobile Bridges Ltd 2005. All Rights Reserved.

	Project: mPhpLib
	Version: 1.0
	Date:    21-10-2005

	Description: Eventhandlers for Grid.

	Version		Date		Author			Initials	Description
	1.0			051021		Ed Schimmel     EAS			Start of development
	1.1			061103		Ed Schimmel		EAS			Changed cursor to default in OnMouseOverRow()
*/

function OnClickRow(inRowName, inItemName, inItemValue, inSubmitOnClick)
{
	if (!inSubmitOnClick)
	{
		var theSelectedRow = document.getElementById("SelectedRow"+inItemName);
		var theValue = theSelectedRow.value;

		var theRow = null;
		if (theValue)
		{
			// unselect currently selected row
			theRow = document.getElementById(theValue);
			theRow.className = "gridRow";
		}

		// select clicked row
		theRow = document.getElementById(inRowName);
		theRow.style.cursor = "default";
		theRow.className = "gridRowSelected";

		theSelectedRow.value = inRowName;
	}

	// set selected value
	var theItem = document.getElementById(inItemName);
	theItem.value = inItemValue;

	if (inSubmitOnClick)
	{
		var theAction = document.getElementById("theAction");
		if (theAction)
			theAction.value = "Load";

		theItem.form.submit();
	}
}

function OnMouseOverRow(inRow)
{
	inRow.style.cursor = "default";
}

function OnMouseOutRow(inRow)
{
	inRow.style.cursor = "default";
}

function OnCheckRow(inItemName, inItemValue)
{
	// set selected value
	var theItem = document.getElementById(inItemName);
	theItem.value = inItemValue;

	var theAction = document.getElementById("theAction");
	if (theAction)
		theAction.value = "Add";

	theItem.form.submit();
}

function OnUncheckRow(inItemName, inItemValue)
{
	// set selected value
	var theItem = document.getElementById(inItemName);
	theItem.value = inItemValue;

	var theAction = document.getElementById("theAction");
	if (theAction)
		theAction.value = "Remove";

	theItem.form.submit();
}
