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

	Project: Project independent
	Version: 1.0
	Date:    04-03-2006

	Description: Eventhandler for ActionForm, generated by Code Generator
*/

function OnFilter()
{
	OnAction("Filter");
}

function OnSelect()
{
	OnAction("Select");
}

function OnEdit()
{
	OnAction("Load");
}

function OnInsert()
{
	OnAction("Add");
}

function OnRemove(inConfirmation)
{
	var isConfirmed = true;

	if (inConfirmation.length)
		isConfirmed = confirm(inConfirmation);

	if (isConfirmed)
		OnAction("Remove");
}

function OnCancel()
{
	OnAction("Load");
}

function OnSave()
{
	OnAction("Save");
}

function OnAction(inAction)
{
	var theForm = document.getElementById("ActionForm");

    theForm.theAction.value = inAction;
    theForm.submit();
}

function OnBack(inPage, inAction)
{
	var theForm = document.getElementById("ActionForm");

	theForm.Page.value = inPage;
	theForm.theAction.value = inAction;

	theForm.action = "";
	theForm.submit();
}

function OnConfirm(inConfirmation, inPage, inAction)
{
	var isConfirmed = true;

	if (inConfirmation.length)
		isConfirmed = confirm(inConfirmation);

	if (isConfirmed)
	{
		var theForm = document.getElementById("ActionForm");

		theForm.Page.value = inPage;
    	theForm.theAction.value = inAction;

		theForm.action = "";
    	theForm.submit();
	}
}

function RestoreSelectBox(inName, inValue)
{
	var theSelectBox = document.getElementById(inName);
	if (theSelectBox)
	{
    	var theOptions = theSelectBox.options;
		for (i=0;i<theOptions.length;i++)
		{
            if (theOptions[i].value == inValue)
			{
				theOptions[i].selected = true;
				return true;
			}
		}
	}
}

function RestoreCheckBox(inName)
{
	var theCheckBox = document.getElementById(inName);
	if (theCheckBox)
		theCheckBox.checked = !theCheckBox.checked;
}

function RestoreRadioButtonGroup(inName, inValue)
{
	var theChildNodes = document.getElementsByTagName("input");
	for (i=0;i<theChildNodes.length;i++)
	{
		var theChildNode = theChildNodes.item(i);
		if (theChildNode.getAttribute("id") == inName) {
			theChildNode.checked = true;
			return;
		}
	}
}
