/**
 * Copyright 2004 Earth Resource Mapping Pty Ltd. This document contains unpublished source code of
 * Earth Resource Mapping Pty Ltd. This notice does not indicate any intention to publish the source
 * code contained herein.
 * 
 * /ecwplugins/lib/Scripts/NCSProgressbar2.js
 *
 */
 
function NCSProgressbar2(uid, objectID, width, height, useLabels, leftLabelText)
{
    if (arguments.length > 0)
    {
    	this.init(uid, objectID);
    }
	this.progress = 0;
	this.width = width;
	this.height = height;
	this.progressColor = "#8BDAFF";
	this.backgroundColor = "#EEEEEE";
	this.borderColor = "#EEEEEE";
	this.outerDivID = uid + "_outerDivID";
	this.innerDivID = uid + "_innerDivID";
	this.rightLabelID = uid + "_rightLabelID";
	
	if (leftLabelText != null)
	{
		this.leftLabel = leftLabelText;
	}
	if(useLabels != null)
	{
		this.rightLabel = useLabels;
	}

	if (objectID != null)
    {
    	this.build();
    }
}
function NCSProgressbar2_Build()
{	
	var nAdjust = (navigator.userAgent.indexOf("MSIE") != -1) ? 4 : 2;
	var barheight = this.height;
	var text = "";
	
	if ( this.leftLabel != null || this.rightLabel == true)
	{
		text+='<TABLE border=0 cellpadding=2 cellspacing=2 width='+this.width+' height='+this.height+'><TR>';
		if (this.leftLabel != null)
		{
			text+='<TD>' + this.leftLabel + '</TD>';
		}
		text+='<TD width='+this.width+'>';
	}
	
	text+='<div id="'+this.outerDivID+'" style="position:relative; visibility:visible; background-color:'+this.borderColor+'; height:'+barheight+'px; BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid;BORDER-BOTTOM: 1px solid">';
	text+='<div id="'+this.innerDivID+'" style="position:absolute; top:1px; left:0px; width:0; height:'+(barheight-nAdjust)+'px; background-color:'+this.progressColor+'; font-size:0px; ">';
	text+='</div></div>';
	
	if ( this.leftLabel != null || this.rightLabel == true)
	{
		text+='</TD>';
		if (this.rightLabel == true)
		{
		   text+='<TD> <input type="text" readonly=true style="BACKGROUND-COLOR: transparent; width:45px;border:0; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" id='+this.rightLabelID+'></TD>';
		}
		text+='</TR></TABLE>';
	}

    if (this.element)
    {
    	this.element.innerHTML = text;
    }
    else
    {
    	return text;
    }
}
function NCSProgressbar2_SetFgColor(color)
{
	this.progressColor = color;
}
function NCSProgressbar2_SetBgColor(color)
{
	this.borderColor = color;
}
function NCSProgressbar2_SetProgress(value)
{
	if (value < 0) value = 0;
	if (value > 100) value = 100;
	document.getElementById(this.innerDivID).style.width=value+'%';
	if (this.rightLabel == true)
	{
           document.getElementById(this.rightLabelID).value=value+'%';
        }
}
NCSProgressbar2.prototype					= new NCSControl();
NCSProgressbar2.prototype.constructor		= NCSProgressbar2;
NCSProgressbar2.superclass					= NCSControl.prototype;
NCSProgressbar2.prototype.build				= NCSProgressbar2_Build;
NCSProgressbar2.prototype.setProgress		= NCSProgressbar2_SetProgress;
NCSProgressbar2.prototype.setFgColor		= NCSProgressbar2_SetFgColor;
NCSProgressbar2.prototype.setBgColor		= NCSProgressbar2_SetBgColor;





