//
// User defined logic for Field controls that triggered client update event
//

// functions to use in trigger update function:
//
// - GetProfileValue(fieldName);
// - SetProfileValue(fieldName, value);
// - GetIsProfileChecked(fieldName);
// - GetProfileObject(fieldName);
// - GetValueFromObject(obj);
// - SetValueToObject(obj, value);
//
// - FilterComboStartWith(FieldName, value);
// - FilterComboContains(FieldName, value);
// - FilterComboReset(FieldName);

function TriggerFieldUpdated(dbTitle, fieldName, id, value)
{
	//alert('dbTitle: [' + dbTitle + '] FieldName: [' + fieldName + '] id: [' + id + '] Value: [' + value + ']');

	if (dbTitle === "Test")
	{
		if (fieldName === "ExportDocument")
		{
			var ed = GetProfileValue("ExportDocument");
			if (ed == "Nee")
			{
				//SetProfileValue("ExportDocument", "Ja"); // check checkmark, "Ja" of "1" of "true"
				//SetProfileValue("ExportDocument", "Nee"); // uncheck checkmark, "Nee" of "0" of "false"
			}

			if (GetIsProfileChecked("ExportDocument"))
			{
				SetProfileValue("Test", "Ja");
			}
			else
			{
				SetProfileValue("Test", "Nee");
			}
		}

		if (fieldName === "Test_2")
		{
			switch (value)
			{
				case "Test 1":
					SetProfileValue("Test_2", "Test 2");
					break;
				case "Test 2":
					//var s = GetProfileValue("Datum");
					SetProfileValue("Comments", value);
					//SetProfileValue("Datum", "06-12-2009");
					break;
				case "Test 3":
					//SetProfileValue("Test_2", "Test 1");
					break;
			}
		}
		if (fieldName === "Test")
		{
			SetProfileValue("Test_2", value);
		}
	}
}

function TriggerFolderUpdated(dbTitle, foldernumber, value)
{
	try
	{
		// alert('db: ' + dbTitle + ' folder updated: ' + foldernumber + ' Value: ' + value);

		if (dbTitle === "Test")
		{
			if (foldernumber === 2)
			{
				if (value === "Bla 2")
				{
					FilterComboStartWith("Test_2", "J");
				}
				else
				{
					FilterComboReset("Test_2");
				}
			}
		}
	}
	catch (e)
	{
	}
}