
	/*
	 * "public" methods that should be used as "onclick" values
	 *  for various links on pages where we are concerned about
	 *  the user abandoning unsaved data
	 *
	 * rgitzel, 11.9.05
	 */

	var LEAVING_FORM_MESSAGE = "Leaving this page without first saving entered data or option selections will cause these changes to be lost. Continue?" ;
	var CHANGING_TAB_MESSAGE = "Leaving this page without first saving entered data or option selections will cause these changes to be lost. Continue?" ;
	var BLOCK_LOGOUT_MESSAGE = "Logging out without first saving entered data or option selections will cause these changes to be lost. Continue logout?" ;

	 

	// a global variable for use by edit forms 
	var formHasBeenChanged = false ;
	var buttonsToEnable = [] ;
	

	/*
	 * sets a global flag to indicate a value in a form has been changed and not saved
	 *
	 * rgitzel, 11.4.05
	 */
	function markFormAsChanged()
	{
		var i, button ;
		
		// update the flag
		formHasBeenChanged = true ;
		
		// enable any buttons that need it
		for( i = 0 ; i < buttonsToEnable.length ; i++ )
		{
            //alert(buttonsToEnable[i] );
            if( ( button = document.getElementById( buttonsToEnable[i] ) ) != null )
			{
				SetButtonStatus( buttonsToEnable[i], true ) ;
			}
		}
	}


	/*
	 * this should be called on every submit button
	 *
	 * rgitzel, 11.4.05
	 */
	function _blockUserIfFormHasChanged( message )
	{
		var ignoreChanges ;
		
		
		if( formHasBeenChanged )
		{
			ignoreChanges = confirm( message ) ;
		}
		else
		{
			ignoreChanges = true ;
		}
		
		return( ignoreChanges ) ;
	}
	
	/*
	 * use this one for buttons specific to the page 
	 */
	function blockOtherActionsIfFormHasChanged()
	{
        return true;
        //return( _blockUserIfFormHasChanged( LEAVING_FORM_MESSAGE ) ) ;
	}

	/* 
	 * this one is for tabs only
	 */
	function blockTabLinkIfFormHasChanged()
	{
        return true;
        return( _blockUserIfFormHasChanged( CHANGING_TAB_MESSAGE ) ) ;
	}

	/* 
	 * this one is for logout links only
	 */
	function blockLogoutIfFormHasChanged()
	{
		return( _blockUserIfFormHasChanged( BLOCK_LOGOUT_MESSAGE ) ) ;
	}
	
