
var counter=0;
var numBooks=7;

function factoid (book,iOldRandom) {
	var arrFactoid = new Array(numBooks);
	book=book-1;
	arrFactoid[0] = new Array(15);
	arrFactoid[0][0] = "This is Harry's first year at Hogwarts School of Witchcraft and Wizardry.";
	arrFactoid[0][1] = "Harry meets the kindly giant Hagrid on his eleventh birthday, July 31.";
	arrFactoid[0][2] = "The train to Hogwarts leaves from Platform 9 3/4 at Kings Cross station.";
	arrFactoid[0][3] = "First years are sorted into one of four different Houses: Hufflepuff, Gryffindor, Slytherin, or Ravenclaw.";
	arrFactoid[0][4] = "Nicholas Flamel is the creator of the Sorcerer's Stone, which produces a liquid that makes the drinker immortal and which turns other metals into gold.";
	arrFactoid[0][5] = "Harry's best friend, Ron Weasley, is a whiz at Wizard's Chess.";
	arrFactoid[0][6] = "Both of know-it-all Hermione Granger's parents are Muggles and dentists.";
	arrFactoid[0][7] = "Harry, Ron, and Hermione become friends by battling a twelve-foot troll in the girls' bathroom.";
	arrFactoid[0][8] = "Professor Quirrell teaches the Defense Against the Dark Arts class.";
	arrFactoid[0][9] = "Professor Snape teaches Potions and does not like Harry.";
	arrFactoid[0][10] = "Professor McGonagall is head of Gryffindor House.";
	arrFactoid[0][11] = "Professor Snape is head of Slytherin House.";
	arrFactoid[0][12] = "Harry is Gryffindor's youngest Seeker in a century.";
	arrFactoid[0][13] = "The Mirror of Erised shows you your heart's deepest desire.";
	arrFactoid[0][14] = "Albus Dumbledore is the Headmaster at Hogwarts.";
	arrFactoid[1] = new Array(8);
	arrFactoid[1][0] = "This is Harry's second year at Hogwarts; he is twelve.";
	arrFactoid[1][1] = "Ginny Weasley, Ron's little sister, starts at Hogwarts this year.";
	arrFactoid[1][2] = "Harry and Ron arrive at Hogwarts in the Weasleys' flying blue Ford Anglia.";
	arrFactoid[1][3] = "The new Defense Against the Dark Arts teacher is named Gilderoy Lockhart.";
	arrFactoid[1][4] = "Ron is afraid of spiders.";
	arrFactoid[1][5] = "When Hagrid was a student at Hogwarts, he raised a giant spider, or 'acromantula', named Aragog, who now lives in the Forbidden Forest.";
	arrFactoid[1][6] = "Sir Nicholas de Mimsy-Porpington - better known as the ghost “Nearly Headless Nick” - celebrates his 500th Deathday in this book.";
	arrFactoid[1][7] = "The Chamber of Secrets is purported to be a hidden chamber in the castle created by one of the founders of the school - cunning Salazar Slytherin.";
	arrFactoid[2] = new Array(14);
	arrFactoid[2][0] = "This is Harry's third year at Hogwarts; he is thirteen.";
	arrFactoid[2][1] = "The new Defense Against the Dark Arts teacher is named Remus Lupin.";
	arrFactoid[2][2] = "Hagrid begins teaching the Care of Magical Creatures class.";
	arrFactoid[2][3] = "An Animagus is a wizard who can change into an animal at will.";
	arrFactoid[2][4] = "Azkaban, the prison in the wizarding world, is located on an island in the North Sea.";
	arrFactoid[2][5] = "Dementors are evil creatures who feed on happiness and make you feel cold and hopeless. They serve as guards at Azkaban.";
	arrFactoid[2][6] = "Chocolate helps cure the effects of the Dementors.";
	arrFactoid[2][7] = "The Patronus Charm will repel a dementor; the incantation is ''Expecto Patronum.''";
	arrFactoid[2][8] = "A Boggart takes on the shape of whatever you fear the most.";
	arrFactoid[2][9] = "You can defeat a Boggart by shouting ''Riddikulus!'' and laughing at it.";
	arrFactoid[2][10] = "A hippogriff is a creature that is half horse, half bird.";
	arrFactoid[2][11] = "To open The Monster Book of Monsters - a living, scuttling, biting book - you must stroke its spine.";
	arrFactoid[2][12] = "The Weasleys went to Egypt on a summer holiday trip.";
	arrFactoid[2][13] = "The Shrieking Shack is reputed to be the most haunted place in all of Britain.";
	arrFactoid[3] = new Array(12);
	arrFactoid[3][0] = "This is Harry's fourth year at Hogwarts; he is fourteen.";
	arrFactoid[3][1] = "A Portkey looks like a regular object, but if you touch it, it will magically whisk you from one place to another.";
	arrFactoid[3][2] = "Lord Voldemort's signal, known as the Dark Mark, is a skull with a snake protruding from its mouth.";
	arrFactoid[3][3] = "The Bulgarians play the Irish in the Quidditch World Cup.";
	arrFactoid[3][4] = "The Triwizard Tournament is a competition between one student from each of the three European schools of magic.";
	arrFactoid[3][5] = "The three European schools of magic are Hogwarts, Beauxbatons Academy of Magic, and Durmstrang Institute.";
	arrFactoid[3][6] = "The Goblet of Fire chooses which students will compete in the Triwizard Tournament.";
	arrFactoid[3][7] = "The new Defense Against the Dark Arts teacher is named Alastor “Mad-Eye” Moody. He is a former Auror, or Dark wizard catcher, for the Ministry of Magic.";
	arrFactoid[3][8] = "Rita Skeeter is a reporter for the Daily Prophet.";
	arrFactoid[3][9] = "Ron has a new pet, an owl named Pigwidgeon. (He let Ginny name it, to his regret.)";
	arrFactoid[3][10] = "Gillyweed makes you grow gills and flippers so you can swim underwater, like a fish.";
	arrFactoid[3][11] = "There are three Unforgivable Curses: the Imperius Curse; the Cruciatus Curse; and Avada Kedavra, the Killing Curse";
	arrFactoid[4] = new Array(13);
	arrFactoid[4][0] = "This is Harry's fifth year at Hogwarts; he is fifteen.";
	arrFactoid[4][1] = "A Squib is a non-magical person from a wizarding family.";
	arrFactoid[4][2] = "Sirius Black's house is at Number Twelve, Grimmauld Place.";
	arrFactoid[4][3] = "The Order of the Phoenix is a group out to stop Lord Voldemort.";
	arrFactoid[4][4] = "Lord Voldemort's followers are called Death Eaters.";
	arrFactoid[4][5] = "Arthur Weasley works on the seventh floor of the Ministry of Magic.";
	arrFactoid[4][6] = "The new Defense Against the Dark Arts professor is named Dolores Jane Umbridge.";
	arrFactoid[4][7] = "Harry, Hermione and friends form a special Defense Against the Dark Arts study group they call ''D.A.,'' for ''Dumbledore's Army.''";
	arrFactoid[4][8] = "Ron Weasley joins the Gryffindor Quidditch team as a Keeper; Ginny Weasley comes on as a Seeker.";
	arrFactoid[4][9] = "Fifth-year students take O.W.L.s – Oridinary Wizarding Levels – to determine their magical proficiencies and their classes for the next year.";
	arrFactoid[4][10] = "Harry and Neville Longbottom have the same birthday: July 31.";
	arrFactoid[4][11] = "St. Mungo's Hospital for Magical Maladies and Injuries is the wizard hospital.";
	arrFactoid[4][12] = "A Metamorphmagus can change his or her appearance at will.";
	arrFactoid[5] = new Array(8);
	arrFactoid[5][0] = "This is Harry's sixth year at Hogwarts; he is sixteen.";
	arrFactoid[5][1] = "Horace Slughorn is a new professor at Hogwarts.";
	arrFactoid[5][2] = "Bill Weasley, Ron's older brother, is engaged.";
	arrFactoid[5][3] = "Fred and George Weasley open a joke shop in Diagon Alley.";
	arrFactoid[5][4] = "A bezoar - a stone taken from a goat's stomach - will serve as the antidote to most poisons.";
	arrFactoid[5][5] = "Sixth-years take their Apparition Test this year.";
	arrFactoid[5][6] = "Sixth-year students also learn to do nonverbal charms - charms where the incantations are not spoken aloud.";
	arrFactoid[5][7] = "Watch out for love potions like Amortentia, which can be hidden in candies and chocolates.";
	arrFactoid[6] = new Array(10);
	arrFactoid[6][0] = "The deepest vaults at Gringotts are protected by a dragon.";
	arrFactoid[6][1] = "It is common for wizards to wear their dress robes to social functions such as weddings.";
	arrFactoid[6][2] = "Wizards lose their magical Trace, which is used to track underage use of magic, when they turn 17.";
	arrFactoid[6][3] = "Ministry of Magic employees usually commute via the Floo system.";
	arrFactoid[6][4] = "Albus Dumbledore defeated Gellert Grindelwald in a famous wizard's duel.";
	arrFactoid[6][5] = "Ravenclaws have to answer a riddle in order to enter their dormitory.";
	arrFactoid[6][6] = "According to the Goblins, all goblin-made objects are only lent to wizards and ultimately belong to goblins.";
	arrFactoid[6][7] = "House Elves can Apparate and Disapparate from anywhere, even Hogwarts!";
	arrFactoid[6][8] = "The Order of the Phoenix can use their Patronuses to send secret messages.";
	arrFactoid[6][9] = "Food is the first of the five Principal Exceptions to Gamp's Law of Elemental Transfiguration.";
	arrFactoid[7] = new Array();
	var lRand = Math.random();
	var iRandom = Math.round((arrFactoid[book].length-1) * lRand);

	//var iRandom = rand(31)-1;
	//alert (lRand + " " + iRandom);
//	alert(iOldRandom +" "+ iRandom);
	window.status = iRandom;

	//var arrPicked = new Array();
	//arrPicked[counter] = iRandom;
	
	while ((iRandom == iOldRandom) || (iRandom > arrFactoid[book].length-1) || (iOldRandom == "")) {
		iRandom = Math.round((arrFactoid[book].length-1) * Math.random());
//		alert("N2 " + iOldRandom +" "+ iRandom);
		window.status = iRandom + " " + iOldRandom;
	}

//	counter++;
	if (document.getElementById) {
		document.getElementById("dfact").innerHTML = arrFactoid[book][iRandom];
	}
	else if (document.layers) {
		document.layers['dfact1'].document.layers['dfact2'].document.open();
		document.layers['dfact1'].document.layers['dfact2'].document.write(arrFactoid[book][iRandom]);
		document.layers['dfact1'].document.layers['dfact2'].document.close();
	}
	document.hform.rNum.value = iRandom;

//	arrFactoid[iRandom]
}
