function Minimap() {
  
  this.minimapCanvas;
  this.minimapC;
  
  this.x = 694;
  this.y = 214;
  
  this.scale = 4;
  this.halfScale = 2;
  
  this.blinking = 0;
  
  
  this.init = function() {
    this.minimapCanvas = document.createElement("canvas");
    this.minimapCanvas.width = 256;
    this.minimapCanvas.height = 256;
    
    this.minimapC = this.minimapCanvas.getContext("2d");
    
    this.minimapC.drawImage(img.get("minimapBG"), 0, 0);
    
    for(var x = 0; x < map.width; x++) {
      for(var y = 0; y < map.height; y++) {
        var pos = this.transform(x, y);
        var tile = map.tiles[x][y];
        if(tile > 0 && tile < 64) {
          var srcX = 4 * (tile % 16);
          var srcY = 2 * Math.floor(tile / 16);
          this.minimapC.drawImage(img.get("minimapTiles"), srcX, srcY, 4, 2, pos.x, pos.y, 4, 2);
        }
      }
    }
  };
  
  
  this.draw = function() {
    
    this.blinking++;
    if(this.blinking == 30) {
      this.blinking = 0;
    }
    
    c.drawImage(this.minimapCanvas, this.x, this.y, 256, 256);
    
    if(map.homePort.beingAttacked && !map.paused && this.blinking < 15) {
      this.drawPort(map.homePort, 1);
    } else {
      this.drawPort(map.homePort, 0);
    }
    
    for(var piratePort in map.piratePorts) {
      if(!map.piratePorts[piratePort].destroyed) {
        this.drawPort(map.piratePorts[piratePort], 2);
      } else {
        this.drawPort(map.piratePorts[piratePort], 3);
      }
    }
    
    var shipPos = this.transform(ship.x, ship.y);
    img.draw("shipSymbol", this.x + shipPos.x - 8, this.y + shipPos.y - 8);
    
  };
  
  
  this.drawPort = function(portPos, spriteOffset) {
    var pos = this.transform(portPos.x, portPos.y);
    img.drawSprite("portSymbol", this.x + pos.x - 8, this.y + pos.y - 8, 16, 16, spriteOffset, 0);
  };
  
  
  this.transform = function(x, y) {
    var transformX = (this.halfScale * map.width) + (x * this.halfScale) - (y * this.halfScale);
    var transformY = this.halfScale + (x * this.halfScale) + (y * this.halfScale);
    return { x : transformX, y : transformY};
  };
  
}