PrintManagerPanel = function (newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newMapObject, newMapId)
{
  if (arguments.length > 0)
    this.init(newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, newMapObject, newMapId);
};

PrintManagerPanel.prototype = new GuiWidget();
PrintManagerPanel.constructor = PrintManagerPanel;
PrintManagerPanel.superclass = GuiWidget.prototype;
 
PrintManagerPanel.prototype.init = function (newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility,newMapObject, newMapId)
{
  PrintManagerPanel.superclass.init.call(this, newId, newParent, newXPosition, newYPosition, newZIndex, newWidth, newHeight, newVisibility, "");
  this.id = newId;

  if (newMapId!=null)
  {
    this.mapObject = OBJECT_MANAGER.getControl(newMapId);
    this.mapId = newMapId;
  }
  else
  {
    this.mapObject = newMapObject;
    this.mapId = newMapObject.id;
  }
  
  this.mapObject.printManagerControl = this;
};

PrintManagerPanel.prototype.setConfig = function(cfg)
{
  this.config = cfg;
};

PrintManagerPanel.prototype.draw = function()
{
  var ypos = 0;
  var htmlString = '';
  //declare a widget to contain the query panels.  This will be hidden by default
  this.simplePanelWidget = new GuiWidget(this.id+"themeElement", this.element, 0, 0, 0, this.width(), 230, true, "");
  this.headerCaptionElement = new GuiWidget(this.id+"headerCaptionElement", this.simplePanelWidget.element, 0, 0, 0, this.width(), 20, true, "themeGroupHeader");
  this.headerCaptionElement.element.cbe.innerHtml("Print Manager");
  this.formContainer = new GuiWidget (this.id+"formContainer", this.simplePanelWidget.element, 0, 20, 0, this.width(), 135, true, "QueryObjectBottom");
  if (this.config.templates.length > 0)
  {
    var htmlString = '';
    for(var pcv=0;pcv < this.config.templates.length;pcv++)
    {
      htmlString += '<INPUT type="radio" value="'+pcv+'" name="printManagerSelector"';
      if (pcv==0)
        htmlString += ' checked="checked"';
      htmlString += ' onclick="document.getGuiControl(\'map0\').config.printConfig.activeTemplate='+pcv+';"';
      htmlString += '><span style="vertical-align:top">'+this.config.templates[pcv].displayName+'</span><br>';
      var currentOrientation=(this.config.templates[pcv].pageOrientation == "P")?'Portrait':'Landscape';
      var currentWidth = this.config.templates[pcv].width;
      var currentHeight = this.config.templates[pcv].height;
      htmlString += '<span style="margin-left: 20px;">('+currentWidth+'"x'+currentHeight+'") - '+currentOrientation+'</span><!--<span style="height:1px;width:100%;border-bottom-width:thin;border-bottom-color:black;border-bottom-style:solid;"></span>--><hr />';
      ypos += 47;
    }
  }
  this.printManagerHeader = new GuiWidget(this.id+"printManagerHeader", this.formContainer.element, 10, 0, 0, this.width()-10, ypos+20+100, true, "");
  this.printManagerHeader.element.cbe.innerHtml(htmlString);
  this.formContainer.height(ypos+20+100);
  this.simplePanelWidget.height(ypos+20+100);
  this.height(this.simplePanelWidget.height());
};

PrintManagerPanel.prototype.resize = function(newWidth, newHeight)
{
  this.element.cbe.resizeTo(newWidth, this.height());
};


