// Copyright (C) 2007-2012 Bristle Software, Inc.
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 1, or (at your option)
// any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc.

/******************************************************************************
* com.bristle.jslib.WorkFlow.js
*******************************************************************************
* Purpose:
*       This file contains routines to manage HTML events.
* Usage:
*       - The typical scenario for using this file from an HTML file is:
*         <script language='JavaScript' src='com.bristle.jslib.WorkFlow.js'></script>
*         Call the various functions that reside here.
* Assumptions:
* Effects:
*       - None.
* Anticipated Changes:
* Notes:
* Implementation Notes:
* Portability Issues:
* Revision History:
*   $Log$
******************************************************************************/

// Create the "namespace" to hold the functions in this file.
com.bristle.jslib.WorkFlow = {};


/******************************************************************************
* If there is unsaved data, prompt the user to save it.  If he wants to save
* it, return true.  If there is no unsaved data, or if the user wants to 
* discard it, return false.
*
*@param blnDirtyFlag    True if data is dirty (unsaved).  False otherwise.
*@param blnOKMeansSave  True if strMessage directs the user to click OK to save
*                       data; False if it directs him to click Cancel to save
*                       data.
*@param strMessage      Message to show the user to ask what to do.
*@return                Updated dirty flag:  true if the data is still dirty 
*                       and should be saved; false otherwise.
*@throws                None.
******************************************************************************/
com.bristle.jslib.WorkFlow.blnDIRTY = true;
com.bristle.jslib.WorkFlow.blnNOT_DIRTY = false;
com.bristle.jslib.WorkFlow.blnOK_MEANS_SAVE = true;
com.bristle.jslib.WorkFlow.blnCANCEL_MEANS_SAVE = false;
com.bristle.jslib.WorkFlow.checkDirtyFlag =
function(blnDirtyFlag, blnOKMeansSave, strMessage)
{
    if (blnDirtyFlag)
    {
        if (blnOKMeansSave)
        {
            return confirm(strMessage);
        }
        else
        {
            return !confirm(strMessage);
        }
    }
    return false;
}

