/*
Modificacion
	Gerado Garcia Hernández
	Gedas CRM
	Se cambio el background hacía el layer que funciona
	como desplazo, ya que estaba sobrel el fondo y luego se mostraba Fuera
	23/Feb/2004
*/
/*
 *	DHTMLVBar
 */

function DHTMLVBar( left, top,
                    width, height,
                    upButtonImage, upButtonWidth, upButtonHeight,
                    downButtonImage, downButtonWidth, downButtonHeight,
                    scrollButtonImage, scrollButtonWidth, scrollButtonHeight,
                    backgroudImage,
                    status,
                    zIndex ){

  
  this.init                 = DHTMLVBar_init
  this.getInnerHTML         = DHTMLVBar_getInnerHTML
  this.getStyle             = DHTMLVBar_getStyle
  this.toString             = DHTMLVBar_toString
  this.getFormatStyle       = DHTMLVBar_getFormatStyle
  
  this.getHeight            = DHTMLVBar_getHeight 
  this.getWidth             = DHTMLVBar_getWidth
  this.setVisible           = DHTMLVBar_setVisible
  
  this.setHeight            = DHTMLVBar_setHeight
  
  this.getName              = DHTMLVBar_getName
  this.getBodyName          = DHTMLVBar_getBodyName
  this.getUpButtonName      = DHTMLVBar_getUpButtonName
  this.getDownButtonName    = DHTMLVBar_getDownButtonName
  this.getScrollButtonName  = DHTMLVBar_getScrollButtonName
  
                    
  this.left           = left
  this.top            = top
  this.width          = width
  this.height         = height 
  this.upButton       = new DHTMLButton( 0, 0, upButtonWidth, upButtonHeight, upButtonImage, null, null, true, zIndex+2  )
  this.downButton     = new DHTMLButton( 0,  (height-downButtonHeight+3), downButtonWidth, downButtonHeight, downButtonImage, null, null, true, zIndex+2  )
  this.backgroudImage = backgroudImage
  this.status         = status
  this.zIndex         = zIndex
  
  this.scrollButtonImage  = scrollButtonImage
  this.scrollButtonWidth  = scrollButtonWidth
  this.scrollButtonHeight = scrollButtonHeight
  
  do{
    this.divName = "DHTMLVBar" + parseInt(Math.random()*1000000) 
  }while( MM_findObj( this.divName ) )
  
}

function DHTMLVBar_init(){
  if( document.layers ) {
    var ref = MM_findObj( this.getBodyName() )
    ref.background.src = this.backgroudImage
  }
}

function DHTMLVBar_setVisible( visible ){
  MM_showHideLayers( this.divName, null, visible?"visible":"hide" )
}

function DHTMLVBar_getBodyName(){
  return this.divName + "BODY"
}

function DHTMLVBar_getName(){
  return this.divName
}

function DHTMLVBar_getUpButtonName(){
  return this.upButton.divName
}

function DHTMLVBar_getDownButtonName(){
  return this.downButton.divName
}

function DHTMLVBar_getScrollButtonName(){
  return this.divName + "SCROLL"
}
  
  
function DHTMLVBar_getFormatStyle(){
  var innerHTML = ""
  
  innerHTML += "<style>"
  innerHTML += this.getStyle()
  innerHTML += "</style>"
  return innerHTML
}

function DHTMLVBar_getHeight(){
  return this.height
}

function DHTMLVBar_getWidth(){
  return this.width
}

function DHTMLVBar_getStyle(){
  var innerHTML = ""
  
  innerHTML += "\n<!--\n\n"

  innerHTML += "#" + this.divName + "{\n" 
  innerHTML += "  position:absolute;\n" 
  innerHTML += "  left:" + this.left + ";\n"
  innerHTML += "  top:" + this.top + ";\n"
  innerHTML += "  width:" + this.width + ";\n"
  innerHTML += "  height:" + this.height + ";\n"
//   innerHTML += "  background-color: red;\n"
//  innerHTML += "  background-image: url('" + this.backgroudImage + "');\n"
  innerHTML += "  layer-background-image: url('" + this.backgroudImage + "');\n"
  innerHTML += "  z-index:" + this.zIndex +";\n"
  innerHTML += "  clip: rect( 0 " + this.width + " " + this.height + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n"
  
  var tmpHeight = (parseInt(this.height) - parseInt(this.downButton.getHeight()) - parseInt(this.upButton.getHeight()) )
  innerHTML += "#" + this.divName + "BODY{\n" 
  innerHTML += "  position:absolute;\n" 
  innerHTML += "  left:0;\n"

  innerHTML += "  top:" + this.upButton.getHeight() + ";\n"
  innerHTML += "  width:" + this.width + ";\n"
  innerHTML += "  height:" +  tmpHeight + ";\n"
  innerHTML += "  z-index:" + (this.zIndex+1) +";\n"
 // innerHTML += "  background-color: red;\n"
  innerHTML += "  background-image: url('" + this.backgroudImage + "');\n"
  innerHTML += "  clip: rect( 0 " + this.width +" " + tmpHeight + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n"
  
  innerHTML += "#" + this.divName + "BACKGROUND{\n" 
  innerHTML += "  position:absolute;\n" 
  innerHTML += "  left:0;\n"
  innerHTML += "  top:0\n"
  innerHTML += "  width:" + this.width + ";\n"
  innerHTML += "  height:" +tmpHeight + ";\n"
  innerHTML += "  z-index:" + (this.zIndex+2) +";\n"
  innerHTML += "  clip: rect( 0 " + this.width +" " + tmpHeight + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n"
  
  this.imgBackground = "<IMG name='img_" + this.divName + "BODYBACKGROUND' " +
                       "width='" + this.width + "' " +
                       "height='" + tmpHeight  + "' " +
                       "src=' " + theSpacerBackground + "'>"
                         
  innerHTML += "#" + this.divName + "SCROLL{\n" 
  innerHTML += "  position:absolute;\n" 
  innerHTML += "  left:0;\n"
  innerHTML += "  top:0;\n"
  innerHTML += "  width:" + this.scrollButtonWidth + ";\n"
  innerHTML += "  height:" + this.scrollButtonHeight + ";\n"
  innerHTML += "  background-image: url('" + this.scrollButtonImage + "');\n"
  innerHTML += "  layer-background-image: url('" + this.scrollButtonImage + "');\n"
  innerHTML += "  z-index:" + (this.zIndex+3 ) +";\n"
  innerHTML += "  clip: rect( 0 " + this.scrollButtonWidth + " " + this.scrollButtonHeight + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n"
  
  innerHTML += "-->\n"
    
  innerHTML += this.upButton.getStyle()
  innerHTML += this.downButton.getStyle()
          
  return  innerHTML 
}


function DHTMLVBar_getInnerHTML(){
  var innerHTML = ""
  
  innerHTML += "<DIV id='" + this.divName + "'>\n" 
  innerHTML += "  <DIV id='" + this.divName + "BODY'>\n" 
  innerHTML += "  <DIV id='" + this.divName + "BACKGROUND'>" + this.imgBackground + "</DIV>\n" 
  innerHTML += "    <DIV id='" + this.divName + "SCROLL'>\n" 
  innerHTML += "    </DIV>\n"
  innerHTML += "  </DIV>\n"
  innerHTML += this.upButton.getInnerHTML()
  innerHTML += this.downButton.getInnerHTML()
  innerHTML += "</DIV>\n"

  return innerHTML
}

function DHTMLVBar_getScript(){
  var innerHTML = ""
  

  
  return innerHTML
}

function DHTMLVBar_toString(){
  return  this.getFormatStyle() + 
          this.getInnerHTML()
}

function DHTMLVBar_setHeight( height ){
  if( !this.vbar ){
    this.vbar     = new DHTMLLayer( this.getName() )
    this.vbody    = new DHTMLLayer( this.getBodyName() )
    this.uButton  = new DHTMLLayer( this.getUpButtonName() )
    this.dButton  = new DHTMLLayer( this.getDownButtonName() )
    this.sButton  = new DHTMLLayer( this.getScrollButtonName() )
  }
  
  this.vbar.setHeight( height )
  this.vbody.setHeight( height - this.uButton.getHeight() - this.dButton.getHeight() )
  this.dButton.setY( height - this.dButton.getHeight() )  

}