function NCSProgressbar(uid, objectID, NCSView, ViewDivName, img) {
    if (arguments.length > 0) {
    	this.init(uid, objectID);
    }
    this.uid=uid;
    this.image=img;
    this.ncsView = NCSView;
    this.viewDivName=ViewDivName;
    this.align="lo";//"cc";
    if (objectID != null) {
    	this.build();
    }
    this.getPosition=function() {
      if (this.ncsView) {
        var position=getPosition(this.ncsView);
        if (position.x==0 && position.y==0) 
          position=getPosition(this.viewDivName);
        var size=new Object();
	size.width=this.ncsView.GetViewWidth();
        size.height=this.ncsView.GetViewHeight();  
      }
      else {
        var position=new Object();
        position.x=0;
        position.y=0;      
        var size=getWindowSize();
      }
      var thePos=new Object();
      if (this.image) {
        switch (this.align) {
          case "cc":
            thePos.x=position.x+(size.width-this.image.width)/2;
            thePos.y=position.y+(size.height-this.image.height)/2;
          break;
          case "lo":
            thePos.x=position.x+5;//+this.image.width/2;
            thePos.y=position.y+5;//+this.image.height/2;          
          break;
          case "lu":
            thePos.x=position.x+5;//+this.image.width/2;
            thePos.y=position.y+size.height-this.image.height-5;
          break;
          case "ro":
            thePos.x=position.x+size.width-this.image.width-5;
            thePos.y=position.y+5;//+this.image.height/2;          
          break;          
          case "ru":
            thePos.x=position.x+size.width-this.image.width-5;
            thePos.y=position.y+size.height-this.image.height-5;
          break;
        }
      }
      else {
        thePos.x=size.width/2;
        thePos.y=size.height/2;
      }
      return thePos;
    }
}
function NCSProgressbar_Build()
{     
   var text = "<div id='"+this.uid+"' NOWRAP style='position:absolute;overflow:hidden;left:0px;top:0px;width:"+this.image.width+"px;height:"+this.image.height+"px;z-index:5;background-color:transparent;visibility:hidden;'>";
   text+="<image src='"+this.image.src+"'>";
   text+="</div>";
    if (this.element)
    {
    	this.element.innerHTML = text;
    }
    else
    {
    	return text;
    }
}
function NCSProgressbar_SetProgress(value)  
{
	var position=this.getPosition();
        moveLayer(this.uid,position.x,position.y);
	if (value < 0) value = 0;
	if (value > 100) value = 100;
	
	if (value<100) {
	  showLayer(this.uid);
	}
	else {
	  hideLayer(this.uid);
	}
}
function setNCSView(NCSView) {
  this.ncsView = NCSView;
}

NCSProgressbar.prototype              = new NCSControl();
NCSProgressbar.prototype.constructor  = NCSProgressbar;
NCSProgressbar.superclass             = NCSControl.prototype;
NCSProgressbar.prototype.build        = NCSProgressbar_Build;
NCSProgressbar.prototype.setNCSView   = setNCSView;
NCSProgressbar.prototype.setProgress  = NCSProgressbar_SetProgress;
function onProgressBar(value) {
  ECWProgressBar.setProgress(value);
}




