/* Populate questions and answers */
var qz = new Array();

qz[0] = new Quiz();
qz[0].question = "The Fairchild F, released in 1976, was the second cartridge-based game system but the first that was programmable. It came with a clone version of <i>Pong</i> and <i>Hockey</i>, a more complex version of <i>Pong</i>. The game system was based on the Fairchild F8 CPU which was invented by a man who left Fairchild to start his own company. What was the name of the company he founded?";
qz[0].answerDesc = "C. Robert Noyce left Fairchild and founded Intel--and the rest is history."
qz[0].answers1 = new Array();
qz[0].answers1[0] = new Answer("Nintendo");
qz[0].answers1[1] = new Answer("Commodore");
qz[0].answers1[2] = new Answer("Intel", "Correct");
qz[0].answers1[3] = new Answer("Bally Midway");

qz[0].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/717fairchild300x250.jpg";


qz[1] = new Quiz();
qz[1].question = "Probably the most-popular sports series of all time is <i>Madden NFL</i>. The very first edition of the game, called <i>John Madden Football</i>, was built for what system?";
qz[1].answerDesc = "A. Electronic Arts released the first version of <i>Madden</i> for the Apple II computer in 1989, but it was not fast enough to show all 22 players on the field at once and proved to be a flop."
qz[1].answers1 = new Array();
qz[1].answers1[0] = new Answer("Apple II", "Correct");
qz[1].answers1[1] = new Answer("PC");
qz[1].answers1[2] = new Answer("Sega Genesis");
qz[1].answers1[3] = new Answer("Atari 2600");

qz[1].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719maddenfb192x250.jpg";


qz[2] = new Quiz();
qz[2].question = "What was the original name of this character in <i>Donkey Kong</i>?";
qz[2].answerDesc = "C. Nintendo's leading character debuted in <i>Donkey Kong</i>, but he wasn't called Mario Mario until <i>The Super Mario Bros. Super Show</i>. Legend says he was named after Mario Segale, a Redmond, Wash., landlord who disrupted a meeting at the Nintendo of America headquarters to demand an overdue rent payment."
qz[2].answers1 = new Array();
qz[2].answers1[0] = new Answer("Mario");
qz[2].answers1[1] = new Answer("Luigi Mario");
qz[2].answers1[2] = new Answer("Jumpman", "Correct");
qz[2].answers1[3] = new Answer("Mario Mario");

qz[2].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/717mario187x250.jpg";



qz[3] = new Quiz();
qz[3].question = "One of the top game makers today, Blizzard Entertainment, got its start in the 1990s with hits that are still among the top games of today--proving that quality far overshadows quantity in game development. Name the earliest game developed by the core people who run Blizzard. And for extra credit, name them all in order of release date.";
qz[3].answerDesc = "B. <i>Rock N' Roll Racing</i> was released in 1993, <i>Warcraft</i> in 1994, <i>Diablo</i> in 1996, and <i>StarCraft</i> in 1998. The company was founded by Allen Adham in 1991 under the name Silicon &#38; Synapse. Your extra credit is the joy you have received by getting all the answers right. "
qz[3].answers1 = new Array();
qz[3].answers1[0] = new Answer("<i>StarCraft</i>");
qz[3].answers1[1] = new Answer("<i>Rock N' Roll Racing</i>", "Correct");
qz[3].answers1[2] = new Answer("<i>Warcraft: Orcs and Humans</i>");
qz[3].answers1[3] = new Answer("<i>Diablo</i>");

qz[3].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719blizzard300x180.jpg";


qz[4] = new Quiz();
qz[4].question = "In <i>Space Invaders</i>, one of the most popular games of the 1980s, when ships are shot down, the remaining UFOs move faster as they near the bottom of the screen. What was the original reason for this?";
qz[4].answerDesc = "C. <i>Space Invaders</i> ran on a 2MHz Intel 8080 chip."
qz[4].answers1 = new Array();
qz[4].answers1[0] = new Answer("Gravity.");
qz[4].answers1[1] = new Answer("Game developers wanted to increase the game's difficulty to make more money from replays.");
qz[4].answers1[2] = new Answer("The display would update faster with fewer alien ships. ", "Correct");
qz[4].answers1[3] = new Answer("All of the above.");

qz[4].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719spaceinvaders300x210.jpg";




qz[5] = new Quiz();
qz[5].question = "In 1983 game sales plummeted. Which was not a reason?";
qz[5].answerDesc = "D. The Reagan administration, which considered ketchup to be a vegetable, probably was unaware of video games."
qz[5].answers1 = new Array();
qz[5].answers1[0] = new Answer("Poor versions of <i>E.T.</i> and <i>Pac-Man</i> for the Atari 2600.");
qz[5].answers1[1] = new Answer("Parents preferred the Commodore 64 for its educational qualities.");
qz[5].answers1[2] = new Answer("A price war rocked the industry.");
qz[5].answers1[3] = new Answer("The Reagan administration successfully attacked the violence in video games.", "Correct");

qz[5].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/717et195x250.jpg";



qz[6] = new Quiz();
qz[6].question = "This popular puzzle game, developed in 1984, is considered one of the reasons for the resurgence of the gaming industry.";
qz[6].answerDesc = "C. Russian programmer Alex Pajitnov designed <i>Tetris</i>, a simple puzzle game that can be played on PCs. "
qz[6].answers1 = new Array();
qz[6].answers1[0] = new Answer("<i>Marble Madness</i>");
qz[6].answers1[1] = new Answer("<i>Qix</i>");
qz[6].answers1[2] = new Answer("<i>Tetris</i>", "Correct");
qz[6].answers1[3] = new Answer("<i>Lemmings</i>");

qz[6].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719quizpuzzle170x250.jpg";



qz[7] = new Quiz();
qz[7].question = "There were many spin-offs of the game <i>Space Invaders</i>. One of the early ones, pictured here, was the first arcade game in full color.";
qz[7].answerDesc = "A. <i>Galaxian</i> was released in 1979 by Namco and featured alien ships that broke formation and flew directly at the shooter."
qz[7].answers1 = new Array();
qz[7].answers1[0] = new Answer("<i>Galaxian</i>", "Correct");
qz[7].answers1[1] = new Answer("<i>Defender</i>");
qz[7].answers1[2] = new Answer("<i>Alien Invaders</i>");
qz[7].answers1[3] = new Answer("<i>Galaxy Defender</i>");

qz[7].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719galaxian300x226.jpg";



qz[8] = new Quiz();
qz[8].question = "The Commodore 64 is listed as the best-selling personal computer of all time by the <i>Guinness Book of World Records</i>. Which one is it?";
qz[8].answerDesc = "D.<br /><br /> <ul id=\"answer_9\">The identities of the other gadgets and their debut dates are:<li>A. Amiga A600 (1992)</li><li>B. Logitech Cordless Desktop MX 3100 (2007)</li><li>C. Commodore VIC 20 (1981)</li><li>D. Commodore 64 (1982) - You can't say sales of the Commodore 64 were due to its the word processing capabilities.</li></ul>"
qz[8].answers1 = new Array();
qz[8].answers1[0] = new Answer("Photo A");
qz[8].answers1[1] = new Answer("Photo B");
qz[8].answers1[2] = new Answer("Photo C");
qz[8].answers1[3] = new Answer("Photo D", "Correct");

qz[8].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719c64quiz300x250.jpg";



qz[9] = new Quiz();
qz[9].question = "<i>Pac-Man</i>, the winner of CNET News.com's most popular arcade game poll, was followed up by <i>Ms. Pac-Man</i> in 1981. How did that game compare to the original <i>Pac-Man</i>? Which was not true?";
qz[9].answerDesc = "C. Ghosts in <i>Ms. Pac-Man</i> moved in somewhat random directions."
qz[9].answers1 = new Array();
qz[9].answers1[0] = new Answer("<i>Ms. Pac-Man</i> is faster.");
qz[9].answers1[1] = new Answer("Walls in <i>Ms. Pac-Man</i> were filled in while <i>Pac-Man</i> walls weren't. ");
qz[9].answers1[2] = new Answer("Ghosts in <i>Ms. Pac-Man</i> moved in patterns so knowledgeable gamers knew how to avoid them.", "Correct");
qz[9].answers1[3] = new Answer("The original games both contained a bug that prevented you from going beyond the 133rd level.");
qz[9].answers1[4] = new Answer("Clyde the ghost was replaced by Sue.");

qz[9].image = "http://i.i.com.com/cnwk.1d/i/ne/p/2007/719mspacman300x221.jpg";
/* Object to hold quiz questions, answers, and images */
function Quiz (q_question, q_answers, q_image) {
  this.question = q_question;
  this.answers = q_answers;
  this.image = q_image;
}

/* Object to hold answer description and a short blurb */
function Answer (a_description, a_blurb) {
  this.description = a_description;
  this.blurb = (a_blurb) ? a_blurb : "";
}

/* Verifies radio button is checked */
function radioCheck(rc) {
	var rc1;

  for (var i = 0; i < rc.a1.length; i++) {
    if (rc.a1[i].checked) {
      return true;
    }
  }

  alert("Please select an answer first and then click Submit.");
  return false;
}

/* Records selected answers to form variable "g" */
function recordAnswerLog(g,a,n) {
	if (n == 1) {
		g.value = (answerlog1 != "") ? answerlog1 + "," + a : a;
	}
}

/* Retrieve index from answer log */
function readAnswerLog(q,n) {
	if (n == 1) {
  		var g = answerlog1.split(",");
  		if ((g.length > 0) && (g.length > q)) {
		return g[q];
  		}
  }
  return "";
}

/* Retrieve index to correct answer */
function getCorrectAnswer1(q){
  for (var i = 0; i < qz[q].answers1.length; i++) {
    if (qz[q].answers1[i].blurb != "")
      return i;
  }
  return "";
}

/* Retrieve the number of correct answers */
function getNumberCorrect1() {
  var n = 0;
  for (var i = 0; i < qz.length; i++) {
    if (((readAnswerLog(i,1) != "") && (getCorrectAnswer1(i) != "") && (readAnswerLog(i,1) == getCorrectAnswer1(i))) || ((readAnswerLog(i,1) == 0) && (getCorrectAnswer1(i) == 0))) {
      n++;
    }
  }
  return n;
}

