var sStyleName = "";
var sDeleteAlertFunctionPrefixHiddenId = "";
function fnSummary( sError )
{
	Alert( "","Validation", sError, "", "Accept" )
}
function ConfirmSendError( ErrorMessage )
{
	ErrorMessage = ErrorMessage.replace(/'/g, "&rsquo;");
	var fnYes = "fnSendErrorToServer('" + ErrorMessage + "' )";
	var fnNo = "";
	var sTitle = "Error Report";
	
	var sWhat = "";
	
	if ( sNavigationMode == "Live" )
		/*sWhat += "The system is having a problem or you found a bug.\n\nPlease help us to improve our products by sending us\nthis error report. Thank you!";*/
		/*01-03-2008 auto Send Report*/
		sWhat += "An error was generated and it has been reported";
	else
		sWhat += ErrorMessage;

	var bShowAlertMessageByError = false;
	if ( ErrorMessage.indexOf( "ShowAlertMessage:=" ) == 0 )
	{
		bShowAlertMessageByError = true;
		if ( ErrorMessage.indexOf( "ShowAlertMessage:=[Logoff]" ) == 0 )
		{
			sWhat = ErrorMessage.substring( "ShowAlertMessage:=[Logoff]".length );
			fnYes = "fnLogoffFromSystem";
		}
		else
		{
			sWhat = ErrorMessage.substring( "ShowAlertMessage:=".length );
			fnYes = "";
		}
		sTitle = "Message";
	}
		
	/*sWhat += "\n\nSend Error?";	01-03-2008 auto Send Report	*/
	
	fnYes = fnYes.replace( /\n/g, "<br>" );
	fnYes = fnYes.replace( /\r/g, "" );
	
	/*Confirm( fnYes, fnNo, sTitle, sWhat ) 01-03-2008 auto Send Report	*/
	if ( ( sNavigationMode != "Live" ) && ( !bShowAlertMessageByError ) )
		Confirm( fnYes, fnNo, sTitle, sWhat );
	else
		Alert( fnYes, sTitle, sWhat, "", 'Ok' );
		
}
var FunctionConfirmExecuted = false;
var FunctionConfirm_Yes="";
var FunctionConfirm_No="";
function Confirm( fnYes, fnNo, sTitle, sWhat )
{
	FunctionConfirmExecuted = true;
	FunctionConfirm_Yes = fnYes;
	FunctionConfirm_No = fnNo;
	alertBuildAlert( sWhat,null,null,sTitle,sStyleName,'');
	/*wrong...alertBuildAlert( sWhat,null,null,sTitle,sStyleName,'', 'Ok'); 09-03-07 auto send report */
	return false;
}
var FunctionConfirmIfExecuted = false;
var FunctionConfirmIf_Yes="";
var FunctionConfirmIf_No="";
function ConfirmIf( fnYes, fnNo, sTitle, sWhat, sParam )
{
	if (sParam == null ) 
		sParam = "";
	FunctionConfirmIfExecuted = true;
	FunctionConfirmIf_Yes = fnYes;
	FunctionConfirmIf_No = fnNo;
	alertBuildAlert( sWhat,null,null,sTitle,sStyleName,sParam);
	return false;
}
var FunctionConfirmMeExecuted = false;
function ConfirmMe(oObjectId, sTitle, sWhat)
{
	if ( FunctionConfirmMeExecuted == true )
	{
		FunctionConfirmMeExecuted = false;
		return true;
	}
	FunctionConfirmMeExecuted = true;
	sDeleteAlertFunctionPrefixHiddenId = oObjectId
	var oHd = document.getElementById(sDeleteAlertFunctionPrefixHiddenId);
	
	alertBuildAlert( sWhat,null,null,sTitle,sStyleName,'');
	return false;
}
var FunctionAlertOkExecuted = false;
var FunctionAlertOk="";
function Alert( fnOk, sTitle, sWhat, sParam, sTextButton )
{
	if (sTextButton == null ) 
		sTextButton = "OK";
	if (sParam == null ) 
		sParam = "";
		
	FunctionAlertOkExecuted = true;
	FunctionAlertOk = fnOk;	
	alertBuildAlert( sWhat,null,null,sTitle,sStyleName,sParam,sTextButton );
	return false;
}
function fnDeleteAlertReturn(bReturnValue, sParameters)
{
	if (FunctionConfirmExecuted)
	{
		if (bReturnValue)
		{
			FunctionConfirmExecuted = false;
			if (FunctionConfirm_Yes != "")
			{
				eval( FunctionConfirm_Yes );
			}
		}
		else
		{
			FunctionConfirmExecuted = false;
			if (FunctionConfirm_No != "")
				eval( FunctionConfirm_No );
		}
	}
	if (FunctionConfirmIfExecuted)
	{
		if (bReturnValue)
		{
			FunctionConfirmIfExecuted = false;
			if (FunctionConfirmIf_Yes != "")
			{
				if ( sParameters == '' )
						strFn = FunctionConfirmIf_Yes + '()';
				else
					strFn = FunctionConfirmIf_Yes + "('" + sParameters + "')";
				eval( strFn );
			}
		}
		else
		{
			FunctionConfirmIfExecuted = false;
			if (FunctionConfirmIf_No != "")
				eval( FunctionConfirmIf_No + "()" );
		}
	}
	if (FunctionAlertOkExecuted) /* 01-04-2008 auto Send Report */
	{
		FunctionAlertOkExecuted = false;
		if (FunctionAlertOk != "")
		{
			if ( sParameters == '' )
			{
				if ( FunctionAlertOk.indexOf( "(" ) == -1 ) /* 01-04-2008 auto Send Report */
					strFn = FunctionAlertOk + '()';
				else strFn = FunctionAlertOk;
			}
			else
				strFn = FunctionAlertOk + "('" + sParameters + "')";
			eval( strFn );
		}
	}
	
	/*if (FunctionAlertOkExecuted)
	{
		FunctionAlertOkExecuted = false;
		if (FunctionAlertOk != "")
		{
			if ( sParameters == '' )
				strFn = FunctionAlertOk + '()';
			else
				strFn = FunctionAlertOk + "('" + sParameters + "')";
				
			eval( strFn );
		}
	}*/
	if (FunctionConfirmMeExecuted)
	{
		if (bReturnValue)
		{
			var oHd = document.getElementById(sDeleteAlertFunctionPrefixHiddenId);
			if (oHd)
			{
				oObjectId = sDeleteAlertFunctionPrefixHiddenId;
				
				if (document.getElementById( oObjectId ))
				{
					if ( document.getElementById( oObjectId ).tagName == "A" )
						eval( document.getElementById( oObjectId ).href )
					else
						document.getElementById( oObjectId ).click();
				}
				else
				{
					alert( "Object Id '"+ oObjectId + "' not found" );
					FunctionConfirmMeExecuted = false;
				}
			}
			else
			{
				alert( "Object not found" );
				FunctionConfirmMeExecuted = false;
			}
		}
		else
		{
			FunctionConfirmMeExecuted = false;
		}
	}
}
