//ImagePanel.js
ImagePanel = function(newID, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newImageSource, newScaleImage, newImageWidth, newImageHeight)
{
  if (arguments.length > 0)
    this.init(newID, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newImageSource, newScaleImage, newImageWidth, newImageHeight);
};

ImagePanel.prototype = new GuiWidget();
ImagePanel.prototype.constructor = ImagePanel;
ImagePanel.superclass = GuiWidget.prototype;

ImagePanel.prototype.init = function(newID, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newImageSource, newScaleImage, newImageWidth, newImageHeight)
{
  ImagePanel.superclass.init.call(this, newID, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility);
  this.setClass("GuiImagePanel");
  this.imageNode = document.createElement("IMG");
  this.imageNode.objectManagerId = this.element.objectManagerId;
  this.imageNode.src = newImageSource;
  this.imageWidth = newImageWidth;
  this.imageHeight = newImageHeight;
  this.scaleImage = newScaleImage;
  this.element.appendChild(this.imageNode);
  this.imageNode.setAttribute((xIE4Up?("className"):("class")),"GuiImagePanel");
  
  if (this.scaleImage)
  {
    xHeight(this.imageNode,this.height());
    xWidth(this.imageNode,this.width());
    xMoveTo(this.imageNode,0,0);    
  }
  else
  {
    this.centerImage(); 
  }
  this.imageNode.imagePanelObject = this;
  xAddEventListener(this.element,'click',     EVENT_LISTENER, false);
  xAddEventListener(this.element,'mouseover', EVENT_LISTENER, false);
  xAddEventListener(this.element,'mousedown', EVENT_LISTENER, false);
  xAddEventListener(this.element,'mouseup',   EVENT_LISTENER, false);
  xAddEventListener(this.element,'mouseout',  EVENT_LISTENER, false);
  xAddEventListener(this.element,'mousemove', EVENT_LISTENER, false);
};

ImagePanel.prototype.centerImage = function()
{
  if ((this.imageWidth != null) && (this.imageHeight != null))
    xMoveTo(this.imageNode,(xWidth(this.element)/2-(this.imageWidth/2)), xHeight(this.element)/2-(this.imageHeight)/2);
  else
    xMoveTo(this.imageNode,(xWidth(this.element)/2-(xWidth(this.imageNode)/2)), xHeight(this.element)/2-(xHeight(this.imageNode)/2));
};

ImagePanel.prototype.show = function()
{
  xShow(this.element);
  xShow(this.imageNode);
  this.centerImage();
};

ImagePanel.prototype.hide = function()
{
  xHide(this.element);
  xHide(this.imageNode);
  this.centerImage();
};

