function ChooserClass() {
  this.choices = new Array();
  this.needed = 0;
  this.required = true;
  this.currentPhase = -1;
  this.nextStep = -1;
  this.instruction = "";
  this.picked = new Array();
  this.notPicked = new Array();

  this.start = function(choices, needed, required, currentPhase, nextStep, instruction) {
    this.choices = choices;
    this.needed = needed;
    this.required = required;
    this.currentPhase = currentPhase;
    this.nextStep = nextStep;
    this.instruction = instruction;
    this.picked = new Array();
    this.notPicked = new Array();
    document.getElementById("chooser").style.visibility = "visible";
    document.getElementById("chooserText").innerHTML = this.instruction;
    document.getElementById("chooserLeft").value = this.needed;
    document.getElementById("chooserDone").style.visibility = this.required ? "hidden" : "visible";
    this.run();
  }

  this.run = function() {
    if (this.needed == this.picked.length) {
      this.finish();
    } else {
      for (var i=0; i<24; i++) {
        document.getElementById("choice" + i).childNodes[0].src = "images/blank.gif";
        document.getElementById("choice" + i).style.cursor = "default";
      }
      for (i=0; i<this.choices.length; i++) {
        this.choices[i].drawSmallAt("choice" + i);
        document.getElementById("choice" + i).style.cursor = "pointer";
      }
    }
  }

  this.pick = function(num) {
    if (num < this.choices.length) {
      this.picked.push(this.choices[num]);
      this.choices.splice(num, 1);
      document.getElementById("chooserLeft").value = this.needed - this.picked.length;
      this.run();
    }
  }

  this.finish = function() {
    document.getElementById("chooser").style.visibility = "hidden";
    document.getElementById("chooserDone").style.visibility = "hidden";
    this.notPicked = this.choices;
    switch (this.currentPhase) {
      case ROLE_COUNCILLOR:
        player[0].council(this.nextStep);
        break;
      case ROLE_BUILDER:
        player[0].build(this.nextStep);
        break;
      case ROLE_PRODUCER:
        player[0].produce(this.nextStep);
        break;
      case ROLE_TRADER:
        player[0].trade(this.nextStep);
        break;
      case ROLE_PROSPECTOR:
        player[0].prospect(this.nextStep);
        break;
      case ROLE_CHAPEL:
        player[0].chapel(this.nextStep);
        break;
      case ROLE_CARDCHECK:
        player[0].cardCheck(this.nextStep);
        break;
    }
  }

  this.showLarge = function(num) {
    if (num < this.choices.length) {
      this.choices[num].showLarge();
    }
  }

  this.hideLarge = function() {
    document.getElementById("largePic").style.visibility = "hidden";
  }
}
