/*
    .--------------------------.
    |   Wait cursor manager    |
    *--------------------------*
    
    Class: Wait Cursor Manager
    	Models a stack of "wait" cursor to the user.
    	
    Requires:
        - 
    
    Author: 
        Marko Ristin
    
    Changelog:
        - 2007/01/27, mristin, initial version
        - 2007/08/28, ahermann, added reset function
*/ 

function Wait_cursor_manager ()
{
    /*
        Variable: pending_jobs
        	Int, number of jobs that need to be processed
    */
    this.pending_jobs = 0;

    /*
        Function: push_pending_job_signal
        	Increases the pending jobs counter, shows the wait cursor to the user.
    */
    this.push_pending_job_signal = function ()
    {
        document.body.style.cursor = 'wait';
        
        this.pending_jobs ++;        
    };
    
    /*
        Function: pop_pending_job_signal
        	Decreases the pending job counter.
        	
        	If there are no pending jobs, it clears 'wait' cursor and sets it to default.
    */
    this.pop_pending_job_signal = function ()
    {
        if ( this.pending_jobs > 0 )
        {
            this.pending_jobs --;
        }
        
        if ( this.pending_jobs == 0 )
        {
            document.body.style.cursor = 'default';
        }
    };
	
	/*
	 * Function: reset
	 * 		Resets the status of the job counter to zero and shows the normal cursor
	 */
	this.reset = function()
	{
		this.pending_jobs = 0;
		document.body.style.cursor = 'default';
	};
}
