SelectionPanel = function (newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionControlId)
{
  if (arguments.length > 0)
    this.init(newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionControlId);
};

SelectionPanel.prototype = new GuiWidget();
SelectionPanel.constructor = SelectionPanel;
SelectionPanel.superclass = GuiWidget.prototype;

SelectionPanel.prototype.init = function (newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newSelectionControl, newSelectionControlId)
{
  SelectionPanel.superclass.init.call(this, newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, "selectionObjectPanel");
  this.id = newId;
  if (newSelectionControlId != null)
  {
    this.selectionControl = OBJECT_MANAGER.getControl(newSelectionControlId);
    this.selectionControlId = newSelectionControlId;
  }
  else
  {
    this.selectionControl = newSelectionControl;
    this.selectionControlId = newSelectionControl.id;
  }
  this.selectionControl.selectionPanel = this;
  this.indexPanel = new SelectionIndex(newId+'IndexPanel', this.element, 0, 0, newZIndex, newWidth, newHeight, true, this.selectionControl, this);
  this.displayPanel = new SelectionDisplay(newId+'DisplayPanel', this.element, 0, 0, newZIndex, newWidth, newHeight, false, this.selectionControl, this);
};

SelectionPanel.prototype.initialize = function()
{
  this.indexPanel.initialize(); 
  this.indexPanel.show();
  this.displayPanel.hide();
};

SelectionPanel.prototype.redrawIndex = function()
{
  this.indexPanel.redraw(); 
};

SelectionPanel.prototype.displaySelection = function(newThemeIndex, newSelectionHandle)
{
  this.currentSelection = this.selectionControl.getSelection(newThemeIndex, newSelectionHandle);
  if (this.currentSelection == null)
  {
    alert('Selection not found');
    return;
  }
  this.displayPanel.setSelection(this.currentSelection);
  this.indexPanel.hide();
  this.displayPanel.show();
};

SelectionPanel.prototype.displayIndex = function()
{
  this.indexPanel.show();
  this.displayPanel.hide();
};

SelectionPanel.prototype.zoomTo = function(newThemeIndex, newSelectionHandle)
{
  this.selectionControl.zoomTo(newThemeIndex, newSelectionHandle);
  if (this.onZoomTo)
    this.onZoomTo();
};

SelectionPanel.prototype.clearSelection = function(newThemeIndex, newSelectionHandle)
{
  this.selectionControl.clearSelection(newThemeIndex, newSelectionHandle);
  this.displayIndex();
};

SelectionPanel.prototype.clearTheme = function(newThemeIndex)
{
  this.selectionControl.clearTheme(newThemeIndex);
  this.displayIndex();
};

SelectionPanel.prototype.printSelection = function(newThemeIndex, newSelectionHandle)
{
  this.selectionControl.printSelection(newThemeIndex, newSelectionHandle);
};

SelectionPanel.prototype.getAttachmentElem = function(newThemeIndex, newSelectionHandle)
{
  return(this.selectionControl.getAttachmentElem(newThemeIndex, newSelectionHandle));
};

SelectionPanel.prototype.resize = function(newWidth, newHeight)
{
  this.element.cbe.resizeTo(newWidth, newHeight);
  this.indexPanel.resize(newWidth,newHeight);
  this.displayPanel.resize(newWidth,newHeight);
  if (this.resizeEvent)
    this.resizeEvent(newWidth, newHeight);
};


