function Panel() {
  
  this.minimap;
  
  this.upgradeWindow;
  
  this.hp;
  this.money;
  
  this.showIntro = true;
  
  this.showInfoBox = -1;
  
  
  this.init = function() {
    
    this.minimap = new Minimap();
    this.minimap.init();
    
    this.upgradeWindow = new UpgradeWindow();
    this.upgradeWindow.init();
    
    this.hp = new Text();
    this.hp.setPosition(828, 33);
    this.hp.setAlignment(Text.CENTER);
    this.hp.setFont("Border");
    
    this.money = new Text();
    this.money.setPosition(806, 143);
    this.money.setFont("Shadow");
    
    mouse.registerUpArea("closeIntro", 410, 375, 60, 36, function() {
      mouse.deleteUpArea("closeIntro");
      panel.showIntro = false;
      panel.openInfoBox(0);
    });
  };
  
  
  this.openInfoBox = function(which) {
    this.showInfoBox = which;
    ship.forbidMovement();
    map.paused = true;
    if(which == 0 || which == 1 || which == 2 || which == 3) {
      mouse.registerUpArea("closeInfoBox", 296, 300, 100, 34, function() {
        ship.allowMovement();
        map.paused = false;
        mouse.deleteUpArea("closeInfoBox");
        panel.showInfoBox = -1;
      });
    }
  };
  
  
  this.openUpgradeWindow = function() {
    if(ship.atPort) {
      this.upgradeWindow.open();
      ship.forbidMovement();
      map.paused = true;
    }
  };
  
  
  this.closeUpgradeWindow = function() {
    this.upgradeWindow.close();
    ship.allowMovement();
    map.paused = false;
  };
  
  
  this.draw = function() {
    
    this.minimap.draw();
    
    if(ship.atPort && !this.upgradeWindow.isOpen && !this.showIntro && this.showInfoBox == -1) {
      img.draw("portHint", 96, 432);
    }
    
    img.draw("panel", 0, 0);
    
    this.upgradeWindow.draw();
    
    var hpPercentage = 100 * (ship.hp / ship.maxHp);
    if(hpPercentage <= 10) {
      c.fillStyle = "#f00";
    } else if(hpPercentage <= 40) {
      c.fillStyle = "#fe0";
    } else {
      c.fillStyle = "#0e0";
    }
    c.fillRect(738, 35, 180 * (ship.hp / ship.maxHp), 16);
    
    img.draw("barCover", 738, 35);
    
    var coolDownWidth = 180 * ((ship.coolDown - ship.coolDownProgress) / ship.coolDown);
    if(coolDownWidth < 0) {
      coolDownWidth = 0;
    }
    c.fillStyle = "#ccc";
    c.fillRect(738, 85, coolDownWidth, 16);
    
    img.draw("barCover", 738, 85);
    
    this.hp.text(ship.hp + "/" + ship.maxHp);
    this.hp.draw();
    
    this.money.text(ship.gold.toString());
    this.money.draw();
    
    if(this.showIntro) {
      img.draw("intro", 108, 0);
    }
    
    if(this.showInfoBox != -1) {
      img.drawSprite("infoBox", 108, 108, 476, 300, 0, this.showInfoBox);
      if(this.showInfoBox == 0 || this.showInfoBox == 1 || this.showInfoBox == 2 || this.showInfoBox == 3) {
        if(mouse.isOver(296, 300, 100, 34)) {
          if(mouse.down) {
            img.drawSprite("okButton", 286, 290, 120, 54, 2, 0);
          } else {
            img.drawSprite("okButton", 286, 290, 120, 54, 1, 0);
          }
        } else {
          img.drawSprite("okButton", 286, 290, 120, 54, 0, 0);
        }
      }
    }
  };
  
  
}