﻿


////////////////////////// PROGRESS BAR //////////////////////////
/////////// Two div based progress bar ///////////////
function IbiDivProgressBar(sInner, sOuter)
{ 
    this._p_inner = null; 
    this._p_outer = null;
    this._p_total = 0;
    
    this._p_in_progress = false;
     
    this._constructor_default = function()
    {
        this._p_inner = document.getElementById(sInner);
        this._p_outer = document.getElementById(sOuter);
        
        if ( this._p_inner == null || this._p_outer == null )
            throw "Can not find inner div";                                                                                                                                 
    }
    
    //Run default constructor now
    this._constructor_default();
    
    this.setSoFar = function(sofar)
    {  
        if ( this._p_total == 0)
            throw "Total is not initialised";
                        
        var percent = Math.floor( 100 * ( sofar / this._p_total ) );
        
        // DEBUG
        try
        {
            window.status = percent;        
        }
        catch(wstatus_msg)
        {// Do not let debug destroy our future
        }
           
        // TODO: HTML DOM
        this._p_inner.style.width = percent + "%" ;     
    }
    
    this.setTotal = function(total)
    {
        this._p_total = total;
        this._p_in_progress = true;
               
        // Show div
        // TODO: HTML DOM
        this._p_outer.style.display="block";       
    }
    
    this.setComplete = function()
    {
        this._p_in_progress = false;
    
        // Hide it
        // TODO: HTML DOM             
        this._p_outer.style.display="none";
    }
    
    this.isInProgress = function()
    {
        return this._p_in_progress;
    }
                       
}//end class DivProgressBar
