//GColorbarControl.Inherits(GControl);
function GColorbarControl(printable,selectable) {
  if ( arguments.length > 1 ) {
    GControl.apply(this,Array.prototype.slice.call(arguments,1));
  } else {
    GControl.call(this);
  }

  //this.Inherits(GControl,printable,selectable);
  this.shown = false;
  this._printable = printable;
  this._selectable = selectable;
  this.setOpacity(0.70);
}
GColorbarControl.prototype = new GControl();
GControl.prototype.constructor = GColorbarControl;

GColorbarControl.prototype.setOpts = function(opts) {
  for ( var i in opts ) {
    this[i] = opts[i];  
  }
}

GColorbarControl.prototype.setOpacity = function(opacity) {
  if ( typeof(this.dom) != "undefined" ) {
    this.dom.style['opacity'] = opacity;
    this.dom.style['mozOpacity'] = opacity;
    this.dom.style['khtmlOpacity'] = opacity;
  }
  if ( typeof(this.style) == "undefined" ) this.style = {};
  this.style['opacity'] = opacity;
  this.style['mozOpacity'] = opacity;
  this.style['khtmlOpacity'] = opacity;
}

GColorbarControl.prototype.initialize = function(map) {
  if ( typeof(this["src"]) == "undefined" ||
       typeof(this["height"]) == "undefined" ||
       typeof(this["width"]) == "undefined" ) {
    return null;
  }

  colorbar = document.createElement("img"); 
  colorbar.src = this.src;
  colorbar.height = this.height;
  colorbar.width = this.width;
  colorbar.className = "colorbar";
  if ( typeof(this.style) != "undefined" ) {
    for ( var i in this.style ) {
      colorbar.style[i] = this.style[i];
    }
  }
  this.dom = colorbar;
  this.shown = true;

  map.getContainer().appendChild(colorbar);  
  return colorbar;
}

GColorbarControl.prototype.getContainer = function() {
  if ( typeof(this.dom) != "undefined" ) return this.dom;
  return null;
}


GColorbarControl.prototype.printable = function() {
  return this._printable;
}

GColorbarControl.prototype.selectable = function() {
  return this._selectable;
}

GColorbarControl.prototype.isHidden = function() {
  return this.shown;
}
GColorbarControl.prototype.show = function() {
  if (typeof(this.dom) == "undefined" ) return;
  this.shown = true;
  this.dom.style.display = "block";
  //this.dom.style.zIndex = "50";
}

GColorbarControl.prototype.hide = function() {
  if (typeof(this.dom) == "undefined" ) return;
  this.shown = false;
  this.dom.style.display = "none";
  //this.dom.style.zIndex = "0";
}

GColorbarControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, 
                          new GSize(7,29));
}



