SelectionDisplay = function (newId, newParent, newXPosition, newYPosition, newZDisplay, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionPanel)
{
  if (arguments.length > 0)
    this.init(newId, newParent, newXPosition, newYPosition, newZDisplay, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionPanel);
};

SelectionDisplay.prototype = new GuiWidget();
SelectionDisplay.constructor = SelectionDisplay;
SelectionDisplay.superclass = GuiWidget.prototype;

SelectionDisplay.prototype.init = function (newId, newParent, newXPosition, newYPosition, newZDisplay, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionPanel)
{
  SelectionDisplay.superclass.init.call(this, newId, newParent, newXPosition, newYPosition, newZDisplay,newWidth, newHeight, newVisibility, "selectionDisplay");
  this.id = newId;
  this.selectionPanel = newSelectionPanel;
  this.captionElement = new GuiWidget(this.id+"captionElement", this.element, 0, 0, 0, this.width(), 25, true, "queryObjectPanel");
  this.captionHTML = '<span class="pseudolink" onclick="document.getWidgetById(\''+this.selectionPanel.id+'\').displayIndex();">Index&gt&gt</span><b>Selection Details</b>';
  
  this.captionElement.innerHtml(this.captionHTML);

  this.closeButton = new ImageButton(this.id+"CloseButton", this.captionElement.element, this.element.cbe.width() - 20, 0, 0, 15, 15, true, "tabKill", "Clear Selection");
  this.closeButton.panel = this;
  this.closeButton.clickEvent = function(e)
  {
    this.panel.clear();
  };
  this.printButton = new ImageButton(this.id+"PrintButton", this.captionElement.element, this.element.cbe.width() - 45, 0, 0, 25, 25, true, "print", "Print Selection");
  this.printButton.panel = this;
  this.printButton.clickEvent = function(e)
  {
    this.panel.print();
  };
  if ((OBJECT_MANAGER.getGuiValueById('extensions')) && (OBJECT_MANAGER.getGuiValueById('extensions')['email']))
    if(OBJECT_MANAGER.getGuiValueById('extensions')['email'].enabled)
    {
      var emailConfig = OBJECT_MANAGER.getGuiValueById('emailConfig');
      if (emailConfig.allowSelectionResults)
      {
        this.attachButton = new ImageButton(this.id+"attachButton", this.captionElement.element, this.element.cbe.width() - 70, 0, 0, 25, 25, true, "attachAnim", "Attach To EMail");
        this.attachButton.panel = this;
        this.attachButton.clickEvent = function(e)
        {
          attachSelectionResults(this.panel.getAttachmentElem());
        };
      }
    }
  this.panelElement = new GuiWidget(this.id+"panelElement", this.element, 0, 25, 0, this.width(), this.height()-25, true, "selectionIndexPanel");

  this.selectionControl = newSelectionControl;
  this.selectionControlId = newSelectionControl.id;
};


SelectionDisplay.prototype.setSelection = function(newSelection)
{
  this.selection = newSelection;
  this.selection.renderTarget = this.panelElement.element;
  this.selection.render();
};

SelectionDisplay.prototype.clearSelection = function(themeId, handle)
{
  this.selectionPanel.clearSelection(themeId, handle);
};

SelectionDisplay.prototype.zoomTo = function(themeId, handle)
{
  this.selectionPanel.zoomTo(themeId, handle); 
};

SelectionDisplay.prototype.clear = function()
{
  this.selectionPanel.clearSelection(this.selection.themeIndex, this.selection.handle); 
};

SelectionDisplay.prototype.print = function()
{
  this.selectionPanel.printSelection(this.selection.themeIndex, this.selection.handle); 
};

SelectionDisplay.prototype.getAttachmentElem = function()
{
  return(this.selectionPanel.getAttachmentElem(this.selection.themeIndex, this.selection.handle)); 
};

SelectionDisplay.prototype.resize = function(newWidth, newHeight)
{
  this.element.cbe.resizeTo(newWidth, newHeight);
  this.captionElement.setPosition(0,0);
  this.captionElement.setSize(this.width(),25);
  this.closeButton.setPosition(this.element.cbe.width() - 20, 0);
  this.printButton.setPosition(this.element.cbe.width() - 45, 0);
  this.panelElement.setPosition(0,25);
  this.panelElement.setSize(this.width(), this.height()-25);
  if (this.resizeEvent)
    this.resizeEvent(newWidth, newHeight);
};


