/*
 *	DHTMLButton
 */


function DHTMLButton( left,
                      top,
                      width,
                      height,
                      enableImgSrc,
                      disableImgSrc,
                      activeImgSrc,
                      status,
                      zIndex ){
                      
  this.getInnerHTML   = DHTMLButton_getInnerHTML
  this.getStyle       = DHTMLButton_getStyle
  this.getFormatStyle = DHTMLButton_getFormatStyle
  this.toString       = DHTMLButton_toString
  
  this.getWidth       = DHTMLButton_getWidth
  this.getHeight      = DHTMLButton_getHeight
  
  this.getLeft        = DHTMLButton_getLeft
  this.getTop         = DHTMLButton_getTop
  
  this.setVisible     = DHTMLButton_setVisible
 
  
  this.left           = left
  this.top            = top
  this.width          = width
  this.height         = height
  this.enableImgSrc   = enableImgSrc
  this.disableImgSrc  = disableImgSrc
  this.activeImgSrc   = activeImgSrc
  this.status         = status?status:false
  this.zIndex         = zIndex?zIndex:1

  do{
    this.divName = "dhtmlButton" + parseInt(Math.random()*1000000) 
  }while( MM_findObj( this.divName ) )
}

function DHTMLButton_setVisible( visible ){
  MM_showHideLayers( this.divName, null, visible?"show":"hide" )
}

function DHTMLButton_getFormatStyle(){
  var innerHTML = ""
  
  innerHTML += "<style>"
  innerHTML += this.getStyle()
  innerHTML += "</style>"
  
  return innerHTML
}

function DHTMLButton_getWidth(){
  return this.width
}

function DHTMLButton_getLeft(){
  return this.left
}

function DHTMLButton_getTop(){
  return this.top
}

function DHTMLButton_getHeight(){
  return this.height
}


function DHTMLButton_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 += "  z-index:" + this.zIndex +";\n"
  //innerHTML += "  overflow:hidden;\n"
  innerHTML += "  clip: rect( 0 " + this.width + " " + this.height + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n" 
  
  innerHTML += "#" + this.divName + "IMAGE{\n" 
  innerHTML += "  position:absolute;\n" 
  innerHTML += "  left:0;\n"
  innerHTML += "  top:0;\n"
  innerHTML += "  width:" + this.width + ";\n"
  innerHTML += "  height:" + this.height + ";\n"
  innerHTML += "  z-index:" + ( this.zIndex + 2 ) +";\n"
  innerHTML += "  background-image: url('" + this.enableImgSrc + "');\n"
  innerHTML += "  layer-background-image: url('" + this.enableImgSrc + "');\n"
  //innerHTML += "  overflow:hidden;\n"
  innerHTML += "  clip: rect( 0 " + this.width + " " +  this.height + " 0);\n"
  innerHTML += "  border: 0px none #000000\n"
  innerHTML += "}\n\n" 

  innerHTML += "-->\n"
  
  return innerHTML
}

function DHTMLButton_getInnerHTML(){
  var innerHTML = ""
  
  innerHTML += "<DIV id='" + this.divName + "'>\n" 
  innerHTML += "  <DIV id='" + this.divName + "IMAGE'>\n" 
  innerHTML += "  </DIV>\n"
  innerHTML += "</DIV>\n"
  
  return innerHTML
}

function DHTMLButton_toString(){

  var innerHTML = this.getFormatStyle() + 
                  this.getInnerHTML()
  return innerHTML
}

