function OnFormSubmit( formName, action, plugin, task )
{
	try
	{
		if( action != null )
			document.forms[ formName ].action = action;
		
		if( ( plugin != null ) && ( plugin.length > 0 ) )
			document.forms[ formName ].plugin.value = plugin;
		
		if( ( task != null ) && ( task.length > 0 ) )
			document.forms[ formName ].task.value = task;
		
		document.forms[ formName ].submit();
	}
	catch( ex )
	{
		alert( ex );
	}
}

function OnLimitedInput( formName, textFieldName, maxLength, outputFieldName )
{
	try
	{
		var myForm = document.forms[ formName ];
		var rest = maxLength;

		if( ( textFieldName != null ) && ( textFieldName.length > 0 ) )
		{
			var field = myForm.elements[ textFieldName ];
			
			if( field.value.length > maxLength )
				field.value = field.value.slice( 0, maxLength );
			
			rest -= field.value.length;
		}

		if( ( outputFieldName != null ) && ( outputFieldName.length > 0 ) )
			myForm.elements[ outputFieldName ].value = rest.toString();
	}
	catch( ex )
	{
		alert( ex );
	}		
}

function OnDisableControl( formName, checkBoxName, controlName, empty )
{
	try
	{
		var myForm = document.forms[ formName ];

		if( ( checkBoxName != null ) && ( checkBoxName.length > 0 ) && ( controlName != null ) && ( controlName.length > 0 ) )
		{
			var checkBox = myForm.elements[ checkBoxName ];
			var control = myForm.elements[ controlName ];
			
			if( ( control.disabled = checkBox.checked ) && empty )
				control.value = "";
		}
	}
	catch( ex )
	{
		alert( ex );
	}		
}
