/******************************************************************************
 setScore sets the competitor's average and score.
 ******************************************************************************/
function setScore() {
  var eventCount = 0;
  var vaultScore, barsScore, beamScore, floorScore;
  
  if(inRange(this.vault)) {
    vaultScore = this.vault;
    eventCount++;
  }
  else {
    vaultScore = 0;
  }

  if(inRange(this.bars)) {
    barsScore = this.bars;
    eventCount++;
  }
  else {
    barsScore = 0;
  }

  if(inRange(this.beam)) {
    beamScore = this.beam;
    eventCount++;
  }
  else {
    beamScore = 0;
  }

  if(inRange(this.floor)) {
    floorScore = this.floor;
    eventCount++;
  }
  else {
    floorScore = 0;
  }

  if(eventCount == 0) {
    // Scores were not entered, return non-breaking space.
    this.score = "&nbsp;";
    this.average = "&nbsp;";
  }
  else {
    // At least one score is within range, so calculate the score.
    var score = vaultScore + barsScore + beamScore + floorScore;
    var average = score / eventCount;
    this.score = scorifyBig(score);
    this.average = scorifyBig(average);
  }
}

/******************************************************************************
 competitor is an object.  This is the definition for that object.  'new'
 will create a new instance of competitor and stuff parameter data into and
 initialize properties of the object.
 ******************************************************************************/
function competitor(fName, lName, year, school, vault, bars, beam, floor) {
	this.fName = fName;											// string
	this.lName = lName;											// string
	this.year = year;												// int
	this.school = school;										// string
	this.vault = vault; 										// float
	this.bars = bars;   										// float
	this.beam = beam;   										// float
	this.floor = floor; 										// float
	this.average = "";          						// string
	this.score = "";  											// string
	this.place = "&nbsp;";									// string
	this.getFullName = getFullName;					// getFullName() returns string with competitor's full name
	this.setScore = setScore;               // setScore() sets the competitor's score
}