function NCSProgressbar(uid, objectID, size, showText)
{
    if (arguments.length > 0)
    {
    	this.init(uid, objectID);
    }
	this.size = size;
	if (showText != null) 
    {
	    this.showText = showText;
    }
    else
    {
    	this.showText = true;
    }
	this.progress = 0;
	this.progressColor = "#8BDAFF";
	this.backgroundColor = "#EEEEEE";
	this.borderColor = "#808080";
	this.align = "left";
	this.label = null;

	if (objectID != null)
    {
    	this.build();
    }
}
function NCSProgressbar_Build()
{	
	var text = "<div style='font-size:5pt;padding:2px;border:#FFFFFF 1px'>";
    
    if (this.label != null)
    {
		text += "<span><font face=Arial size=-1>" + this.label + "</font></span>";
    }
    
    var i=0;

    for (i=0; i<this.size; i++)
    {
        text += "<span style='border:solid " + this.borderColor + " 1px;' id='" + this.uid + "_progress" + i + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;";
    }
    if (this.showText)
    { 
        text += "<span><font face=Arial size=-1 ><label id='" + this.uid + "_label" + "'> 0%</label></font></span>";
    }

    text += "</div>";
    
    if (this.element)
    {
    	this.element.innerHTML = text;
    }
    else
    {
    	return text;
    }
}
function NCSProgressbar_SetProgress(value)
{
	if (value < 0) value = 0;
	if (value > 100) value = 100;

	if( Math.ceil(this.size*(value/100.0)) == this.progress ) return; 
	this.progress = Math.ceil(this.size*(value/100.0));

    var i=0;
	for (i=0; i<this.size; i++)
	{
		if (i < this.progress)
		   document.getElementById(this.uid + "_progress" + i).style.backgroundColor = this.progressColor;
		else
		   document.getElementById(this.uid + "_progress" + i).style.backgroundColor = this.backgroundColor;
    }
    if (this.showText)
    {
       document.getElementById(this.uid + "_label").innerHTML = " " + value + "%";
    }
}

NCSProgressbar.prototype              = new NCSControl();
NCSProgressbar.prototype.constructor  = NCSProgressbar;
NCSProgressbar.superclass             = NCSControl.prototype;
NCSProgressbar.prototype.build        = NCSProgressbar_Build;
NCSProgressbar.prototype.setProgress  = NCSProgressbar_SetProgress;




