<!-- Begin
function __isFormDirty( form )
{
	var bHasChanged = false;
	var strDirtyFlagID = "__" + form.id + "IsDirty";

	if ( form.elements[strDirtyFlagID].value != "false" )
		bHasChanged = true;

    	if ( !bHasChanged )
    	{
		var objElement;
		var i = 0;
		objElement = form.elements[i];

		while (objElement != null && !bHasChanged )
			{
 			if (objElement.type != "hidden" )
				bHasChanged = __hasObjectChanged( objElement, form );
			i += 1;
			objElement = form.elements[i];
                        if ( typeof(objElement) == "undefined" )
                            objElement = null;
			}
	}

	return bHasChanged;
}

function __doRedirectIfNotDirty(form, strRedirectUrl)
{
	if ( !__isFormDirty(form) )
	{
		window.location = BuildPathToFile(strRedirectUrl);
		return false;
	}
	return true;
}

function __doRedirectOrCloseIfNotDirty(form, strRedirectUrl)
{
	if ( !__isFormDirty(form) )
	{
		if (strRedirectUrl != "")
			window.location = BuildPathToFile(strRedirectUrl);
		else
			window.close();
		return false;
	}
	return true;
}

function __doConfirmedPostBackIfDirty(form,strConfirmationText)
{
    if ( __isFormDirty(form) )
         return window.confirm(strConfirmationText);

    return true;
}

function __doConfirmedRedirectIfDirty(form,strConfirmationText,strRedirectUrl)
{
    if ( __isFormDirty(form) )
	{
		if ( !window.confirm(strConfirmationText) )
			return;
	}

	window.location = BuildPathToFile(strRedirectUrl);
}

function __doConfirmedRedirectOrCloseIfDirty(form,strConfirmationText,strRedirectUrl)
{
    if ( __isFormDirty(form) )
	{
		if ( !window.confirm(strConfirmationText) )
			return;
	}

	if (strRedirectUrl != "")
		window.location = BuildPathToFile(strRedirectUrl);
	else
		window.close();
}

function __toggleObjectEnableState( strId, bEnabled )
{
	var obj = document.getElementById(strId);
	if ( obj != null )
		__toggleObjectEnableStateByObject(obj,bEnabled);
}

function __toggleObjectEnableStateByObject( obj, bEnabled )
{
	if ( obj != null )
	{
		// ie will disable the parent and all children, but others will not
		if ( typeof(obj) != "undefined" && obj.disabled != null )
			obj.disabled = !bEnabled;

		var objChild = obj.firstChild;
		while( objChild != null )
		{
			__toggleObjectEnableStateByObject( objChild, bEnabled )

		    objChild = objChild.nextSibling;
		}
	}
}

function __hasObjectChanged( objElement, form )
{
	var bHasChanged = false;
	if ( objElement.type == "checkbox" )
		{
		if (objElement.defaultChecked != objElement.checked)
			bHasChanged = true;
		}
	else if ( objElement.type == "select-one" )
		{
		var defValue = null;
		var curValue = null;
		var nOption = 0;
		var objOption = objElement.options[nOption];

		while( objOption != null && (defValue == null || curValue == null))
			{
			if (objOption.defaultSelected)
				defValue = objOption.value;
			if (objOption.selected)
				curValue = objOption.value;
			nOption += 1;
			objOption = objElement.options[nOption];
			}
		if ( defValue != curValue )
			bHasChanged = true;
		}
	else if ( objElement.type == "radio" )
		{
		objElement = form.elements[objElement.name];
		var defValue = null;
		var curValue = null;
		var nOption = 0;
		var objOption = objElement[nOption];

		while( objOption != null && (defValue == null || curValue == null))
			{
			if (objOption.defaultChecked)
				defValue = objOption.value;
			if (objOption.checked)
				curValue = objOption.value;
			nOption += 1;
			objOption = objElement[nOption];
			}
		if ( defValue != curValue )
			bHasChanged = true;
		}
	else if (objElement.type != "button" &&
	    objElement.type != "submit" && objElement.type != "reset" )
		{
		if ( objElement.defaultValue != objElement.value )
			bHasChanged = true;
		}
	return bHasChanged;
}
//  End -->

