/**
* jt_ProgressBar.js - Progress Bar widget
*
* @version 29 Apr 2005
* @author Joseph Oster, wingo.com, Copyright (c) 2005-2007
*/

jt_ProgressBar = function(parent, width, fontSize, barClass) {
    // constructor for Progress Bar object; 'width' and 'fontSize' in pixels
    this.pixels = width;
    this.outerDIV = document.createElement("div");
    this.outerDIV.style.border = "1px solid #000000";
    this.outerDIV.style.background = "#FFFFFF";
    this.outerDIV.style.fontFamily = "Arial,Verdana";
    this.outerDIV.style.fontSize = fontSize + "px";
    this.outerDIV.style.width = (width + 2) + "px";
    this.outerDIV.style.textAlign = "left";
    parent.appendChild(this.outerDIV);

    this.fillDIV = document.createElement("div");
    this.fillDIV.style.textAlign = "right";
    this.fillDIV.style.overflow = "hidden";
    this.fillDIV.innerHTML = "x";
    this.fillDIV.style.width = "0px";
    if (barClass) this.fillDIV.className = barClass;
    else {
        this.fillDIV.style.background = "#12597a";
        this.fillDIV.style.border = "1px solid #FFFFFF";
        this.fillDIV.style.color = "#FFFFFF";
        }
    this.outerDIV.appendChild(this.fillDIV);
}

jt_ProgressBar.prototype.setPercent = function(pct) {
    // expects 'pct' values between 0.0 and 1.0
    var fillPixels;
    if (pct < 1.0) fillPixels = Math.round(this.pixels * pct);
    else { // avoid round off error
        pct = 1.0;
        fillPixels = this.pixels;
        }
    this.fillDIV.innerHTML = Math.round(100 * pct) + "%";
    this.fillDIV.style.width = fillPixels + "px";
}