//These functions are used by the menu items

function StartTask(taskName, taskArguments)
{
	try
	{
		var frm = document.forms[0];
		if(frm.elements["_MNU_SAVEBEFORELEAVE"].value == "Y")
		{
			if(!ConfirmExitWithoutSave())
				return;
		}
		frm.elements["_TASK"].value = taskName;
		if(taskArguments == null)
		{
			frm.elements["_TASKARGUMENTS"].value = "NEW";
		}
		else
		{
			frm.elements["_TASKTYPE"].value = "NEWWITHARGUMENTS";
			
			var args = "";
			for(var i = 0; i < taskArguments.length;i++)
			{
				args += "|" + taskArguments[i];
			}
			
			frm.elements["_TASKARGUMENTS"].value = args.substring(1);
		}
		
		frm.submit();
	}
	catch(e){}
}

function ResumeTask(taskName, taskId)
{
	try
	{
		var frm = document.forms[0];
		if(frm.elements["_MNU_SAVEBEFORELEAVE"].value == "Y")
		{
			if(!ConfirmExitWithoutSave())
				return;
		}
		frm.elements["_TASK"].value = taskName;
		frm.elements["_TASKTYPE"].value = "EXISTING";
		frm.elements["_TASKARGUMENTS"].value = taskId;
		frm.submit();
	}
	catch(e){}
}

function ChangeView(viewName)
{
	try
	{
		var frm = document.forms[0];
		
		//doesn't confirm an exit because it assumes you are within a task
		frm.elements["_VIEW"].value = viewName;
		frm.submit();
	}
	catch(e){}
}

function NavigateToPage(pageLocation)
{
	try
	{
		var frm = document.forms[0];
		var save = frm.elements["_MNU_SAVEBEFORELEAVE"];
		if(save != null && save.value == "Y")
		{
			if(!ConfirmExitWithoutSave())
				return;
		}
		window.location.href = pageLocation;
	}
	catch(e){}
}

function ExecuteScript(script)
{
	try
	{
		window.eval(script);
	}
	catch(e){}
		
}

function ConfirmExitWithoutSave()
{
	var ok = window.confirm("If you leave this page without saving your work then all information you have entered will be lost.  Are you sure you want to leave this page?");
	return ok;	
}
