// =================================================================
// ===== What Class Are You?                                   =====
// ===== Text by Bart Carroll 	                               =====
// ===== Concept and Javascript by Mark A Jindra               =====
// ===== (c) 2009 Wizards of the Coast LLC,                    =====  
// ===== a subsidiary of Hasbro, Inc. All Rights Reserved.	   =====	
// =================================================================

// =================================================================
// Variables and Arrays 

dURL = window.location.href;
var time=new Date();
var year=time.getYear();
if (year < 2000) { year = year + 1900; }
var Defender = 0;
var Leader = 0;
var Controller = 0;
var Striker = 0;
var Primal = 0;
var Arcane = 0;
var Divine = 0;
var Martial = 0;
var Tie1 = 0;
var Tie2 = 0;
var Tie3 = 0;
var catonetrack = 0;
var cattwotrack = 0;
var codehtml = "HTML Default";
var codebb = "BB Default";
var codetext = "Text Default";
var qtext = "-";
var Q = 0;
var qx = new Array(0,1,2,3,4,5,6,7,8,9);
var qlist = new Array();

var questions = new Array(
"Stop me if you've heard this one. A group of trolls walk into a bar and… start eating the patrons. When battle erupts, my preferred fighting style is to&#58;:Stand at the front&#151;no troll will get past me to attack the rest of my party!:Defender:Help out the group&#151;making sure my party receives the healing and inspiration they need when the going gets tough.:Leader:Take on all comers&#151;the more trolls to battle at once, the better!:Controller:Find a key target&#151;single him out and take him down!:Striker:1",
"Which is more important&#58; good offense, or good defense&#58;:Offense. In fact, the more widespread the better.:Controller:Offense&#133; strategically used.:Striker:Defense. Though, having a good offense when the fight is right in my face helps, too.:Defender:Whatever works, so long as my party wins in the end.:Leader:1",
"It's the final showdown in the adventure; we're up against Sinruth and his remaining band of hobgoblins. To best help my party in this fight, my powers include&#58;:A bit of trickery&#151;weakening, confusing, and unwittingly shifting around hobgoblins.:Controller:Improved teamwork&#151;better targeting hobgoblins for the party to concentrate against.:Leader:Serving as a roadblock&#151;making sure these hobgoblins don't move past or ignore me… not without my permission.: Defender:Concentrated firepower&#151;using whatever works to take down a hobgoblin, preferably Sinruth himself, the quickest.:Striker:1",
"Given the choice, I would prefer to use the following powers&#58;:World Serpent Rage, Prismatic Explosion, Unstoppable Arrows:Striker:Form of the Displacer Beast, Even Hand of Justice, Your Delectable Pain:Defender:Sleep, Time Stop, Bigby's Grasping Hands:Controller:Cure Serious Wounds, Hold the Line, Panacea:Leader:1",
"You've helped defeat the elder red dragon, and now it's time to pick through his treasure hoard. On my turn, I'd select the following items&#58;:An item that will help us achieve our goals&#58; an instant campsite, a map of orienteering, or a potion of life:Leader:Something with some magic power&#58; a wand, a staff or a totem.:Controller:That's easy; who wouldn't want a magical sword or bow?:Striker:A good shield and suit of armor is the strongest foundation.:Defender:1",
"I derive my power from the energies of&#58;:The natural world and its spirits.:Primal:The magic that permeates the cosmos.:Arcane:The very gods, through prayer and litany.:Divine:My own training and dedication.:Martial:2",
"What is best in life (aside from crushing your enemies, etc., etc.)?:To heal, protect, and smite the enemies of my gods!:Divine:To destroy those that threaten the balance of nature!:Primal:To use my strength and willpower to vanquish my enemies!:Martial:To study the use of magical power!:Arcane:2",
"Given the choice, I would prefer to use the following powers&#58;:Prismatic Storm, Hideous Laughter, Fireball:Arcane:Supremacy of Steel, Confounding Arrows, Perfect Strike:Martial:Insect Plague, Call Lightning Storm, Avalanche Strike:Primal:Wrath of the Divine, Oath of the Inevitable Blade, Godstrike:Divine:2",
"Which god am I most likely to worship (or at least most respect), given their various teachings?:Kord, who teaches to be strong, be brave, and scorn cowardice in any form.:Martial:Bahamut, who teaches to uphold the highest ideals of honor and justice, be constantly vigilant against evil and oppose it on all fronts. :Divine:Melora, who teaches to protect the wild places of the world, oppose the rampant spread of cities and empires, and hunt abominations of nature.:Primal:Ioun, who teaches to seek the perfection of your mind, and accumulate, preserve, and distribute knowledge.:Arcane:2",
"After my long, glorious, and illustrious career, how will historians describe my final place in the world?:History is written by the victorious. Who now living can say how I got where I am, a legend among the military leaders of history?:Martial:My god chose me to be her hand of justice, to correct the failings in her servants and ensure her temples' sanctity.:Divine:My lifelong perusal of grimoires, librams, tomes, and spellbooks finally revealed the foundation of reality to me&#58; that spells are each a portion of a larger truth.:Arcane:I have become the embodiment of nature's power, a mighty spirit veiled in living flesh.:Primal:2"
);

var tieonequestion = "While there are great resources of magical energy throughout the cosmos, I specifically tap into them through&#58;:My own instinctive or inborn connections, drawn from such elemental forces as dragons and primordial beings.:Sorcerer:Infernal intelligences or fey spirits; beings from other planes that know a thing or two about powerful magic!:Warlock"

var tietwoquestion = "Once I've selected my chosen foe, the best way to take him down is usually&#58;:From a distance; why rush in with a sword when a bow works just as well?:Ranger:Up close. Ranged weapons are fine, but I prefer the thrill of sneaking right up to my prey.:Rogue"

var tiethreequestion = "The most elegant way to express the wonders of my craft is through&#58;:Song, verse, and epic legend&#151;those that I myself tell, and those certain someday to be told about me.:Bard:Cryptic formulas and the complex recipes of alchemy&#151;only understood by those with enough skill themselves to truly appreciate my accomplishments.:Artificer"
 
var classes = new Array("Cleric","Fighter","Paladin","Ranger","Rogue","Warlock","Warlord","Wizard","Swordmage","Avenger","Barbarian","Bard","Druid","Invoker","Shaman","Sorcerer","Warden","Artificer"); 

var classblurb = new Array(
"<p>Clerics are battle leaders who are invested with divine power. They blast foes with magical prayers, bolster and heal companions, and lead the way to victory with a mace in one hand and a holy symbol in the other. Clerics run the gamut from humble servants of the common folk to ruthless enforcers of evil gods.</p><p>As a cleric, the deity (or deities) you choose to revere goes a long way toward defining you, or at least how other people in the world see you. You could be a platinum-garbed envoy of Bahamut seeking justice throughout the land, a shadowy follower of Sehanine with a roguish streak, a burly disciple of Kord who believes the virtue of strength is sufficient for all challenges, or a dwarf cleric of Moradin bringing honor to the denizens of your mountain home.</p><p>Will you protect what is sacred to your god, quest for legendary holy artifacts, pursue a life of evangelical adventuring, or attempt all these deeds and more?</p>",
"<p>Fighters are determined combat adepts trained to protect the other members of their adventuring groups. Fighters define the front line by bashing and slicing foes into submission while reflecting enemy attacks through the use of heavy armor. Fighters draw weapons for gold, for glory, for duty, and for the mere joy of unrestrained martial exercise.</p><p>Regardless of your level of skill and the specific weapons you eventually master, your motivations determine who you defend and who you slay. You could be a noble champion who pledges your blade to gallant causes, a calculating mercenary who cares more for the clink of gold than praise, a homeless prince on the run from assassins, or a blood-loving thug looking for the next good fight.</p><p>Your future is yours. When you unsheathe your weapon, what battle cry flies from your lips?</p>",
"<p>Paladins are indomitable warriors who've pledged their prowess to something greater than themselves. Paladins smite enemies with divine authority, bolster the courage of nearby companions, and radiate as if a beacon of inextinguishable hope. Paladins are transfigured on the field of battle, exemplars of divine ethos in action.</p><p>To you is given the responsibility to unflinchingly stand before an enemy's charge, smiting them with your sword while protecting your allies with your sacrifice. Where others waver and wonder, your motivation is pure and simple, and your devotion is your strength. Where others scheme and steal, you take the high road, refusing to allow the illusions of temptation to dissuade you from your obligations.</p><p>Take up your blessed sword and sanctified shield, brave warrior, and charge forward to hallowed glory!</p>",
"<p>Rangers are watchful warriors who roam past the horizon to safeguard a region, a principle, or a way of life. Masters of bow and blade, rangers excel at hit-and-run assaults and can quickly and silently eliminate foes. Rangers lay superb ambushes and excel at avoiding danger.</p><p>As a ranger, you possess almost supernaturally keen senses and a deep appreciation for untamed wilderness. With your knowledge of the natural world, you are able to track enemies through nearly any landscape, using the smallest clue to set your course, even sometimes the calls and songs of beasts and birds. Your severe demeanor promises a deadly conclusion to any enemy you hunt.</p><p>When you catch sight of your quarry, will the transgressor perish by swift bow shots from a distance, or by the twofold blades that glint and glitter in each of your battle-scarred hands?</p>",
"<p>Rogues are cunning and elusive adversaries. Rogues slip into and out of shadows on a whim, pass anywhere across the field of battle without fear of reprisal, and appear suddenly only to drive home a lethal blade.</p><p>As a rogue, you might face others' preconceptions regarding your motivations, but your nature is your own to mold. You could be an agent fresh from the deposed king's shattered intelligence network, an accused criminal on the lam seeking to clear your name, a wiry performer whose goals transcend the theatrical stage, a kid trying to turn around your hardluck story, or a daredevil thrill-seeker who can't get enough of the adrenaline rush of conflict. Or perhaps you are merely in it for the gold, after all.</p><p>With a blade up your sleeve and a concealing cloak across your shoulders, you stride forth, eyes alight with anticipation. What worldly wonders and rewards are yours for the taking?</p>",
"<p>Warlocks channel arcane might wrested from primeval entities. They commune with infernal intelligences and fey spirits, scour enemies with potent blasts of eldritch power, and bedevil foes with hexing curses. Armed with esoteric secrets and dangerous lore, warlocks are clever and resourceful foes.</p><p>However you came to your arcane knowledge, you need not accept the poor reputation warlocks sometimes endure. You could be a libram-toting scholar captivated by ominous lore, a foot-loose wanderer searching for elusive ultimate truths, a devil-touched hunter using infernal spells to eliminate evil, or even a black-clad mercenary who uses sinister trappings to discourage prying strangers and unwanted attention. On the other hand, you could be a true diabolist using your gifts to tyrannize the weak&#151;some warlocks unfortunately are exactly that.</p><p>The pacts are complete. The rites have concluded. The signs are drawn in blood, and the seals are broken. Your destiny beckons.</p>",
"<p>Warlords are accomplished and competent battle leaders. Warlords stand on the front line issuing commands and bolstering their allies while leading the battle with weapon in hand. Warlords know how to rally a team to win a fight.</p><p>Your ability to lead others to victory is a direct result of your history. You could be a minor warchief looking to make a name for yourself, a pious knight-commander on leave from your militant order, a youthful noble eager to apply years of training to life outside the castle walls, a calculating mercenary captain, or a courageous marshal of the borderlands who fights to protect the frontier. Regardless of your background, you are a skillful warrior with an uncanny gift for leadership.</p><p>The weight of your armor is not a hindrance; it is a familiar comfort. The worn weapon grip molds to your hand as if it were a natural extension of your arm. It's time to fight and to lead.</p>",
"<p>Wizards are scions of arcane magic. Wizards tap the true power that permeates the cosmos, research esoteric rituals that can alter time and space, and hurl balls of fire that incinerate massed foes. Wizards wield spells the way warriors brandish swords.</p><p>Magic lured you into its grasp, and now you seek to master it in turn. You could be a bespectacled sage searching for dusty tomes in forgotten sepulchers, a scarred war mage plying foes with fireballs and foul language in equal measure, a disgruntled apprentice who absconded with your master's spellbooks, an eladrin upholding the magical tradition of your race, or even a power-hungry student of magic who might do anything to learn a new spell.</p><p>A cloak of spells enfolds you, ancient rituals bolster your senses, and runed implements of your craft hang from your belt. Effervescing arcane lore pulses through your consciousness, a constant pressure craving release. When will you know enough magic to storm the ramparts of reality itself?</p>",
"<p>Swordmages apply the arcane arts to melee combat. The combat skills they possess are enhanced by the magic they wield. The flourish of a swordmage's blade not only bites with steel, but also with fire, lightning, or other powerful forces.</p><p>You studied and practiced for years to master your skills. You mastered the fundamentals of arcane magic and combined this academic study with endless hours of physical training. You might be a young eladrin in search of your fortune, a stranger to the wider world outside the seclusion of your homeland; a self-trained genasi sellsword, gifted with an affinity for elemental magic; the scion of a disgraced noble human family, taught by the finest tutors in your youth but now a footloose expatriate; or a half-elf arcane champion, rigorously trained in a war magic academy to serve in the armies of your homeland.</p><p>Magical barriers of force swirl around you, protecting you from harm. The blade you carry is an extension of your being, both body and mind. It pulses with eldritch energy as you prepare to defend your allies and unleash magical fury against your foes.</p>",
"<p>In secret temples far from bustling cities and priestly hierarchies, orders of esoteric warriors train their initiates in ancient traditions now forgotten or forbidden by most religious organizations. The champions of these orders are avengers&#151;deadly weapons in the hands of their gods, imbued with divine power through secret rites of initiation. In battle, avengers swear to execute divine vengeance, entering a mental state that gives them unerring focus on a single enemy.</p><p>As an avenger, you were trained in a monastery, initiated through secret rites, and imbued with the power to smite your god's foes. You might be a disciple of Ioun, sworn to hunt and exterminate the minions of Vecna until you one day face the Maimed God. You could be an agent of the Raven Queen, bringing death to those who would defy your mistress. Or perhaps you serve Bahamut as an agent of justice, bringing ruin to tyrants and oppressors. The organizations devoted to your god might view you as a heretic or a hero, but you answer only to your god and to the vows you swore upon your initiation as an avenger.</p><p>Where will those vows lead you? One thing is certain: Doing the will of your god is never easy and never free of peril.</p>",
"<p>Barbarians are savage warriors who deal out powerful blows from their mighty weapons. They charge from foe to foe and seldom feel the pain of an enemy's strike. For barbarians' foes, the moments of greatest terror come when barbarians call upon primal forces to lend power to their raging spirits. These rages, although temporary, give a barbarian incredible powers, a combination of skill, willpower, and a legacy of ancient tribal rituals.</p><p>As a barbarian, you have a link to powerful nature spirits and other primal forces bound to the warriors of your tribe by the songs and totems of your legacy. These spirits lend energy to your rages, transforming you into a devastating force on the battlefield. As you become more experienced, these rages transcend mortal limitations, manifesting directly as waves of elemental power or gifting you with supernatural recuperative powers.</p><p>When the heat of battle is upon you, will you respond with a sudden charge that fells with one mighty swing of your weapon, or with a prolonged rage that leaves destroyed foes in your wake?</p>",
"<p>Bards are artists first and foremost, and they practice magic just as they practice song, drama, or poetry. They have a clear sense of how people perceive reality, so they master charm magic and some illusions. Sagas of great heroes are part of a bard's repertoire, and most bards follow the example of many fables and become skilled in a variety of fields. A bard's artistic ability, knowledge of lore, and arcane might are widely respected, particularly among the world's rulers.</p><p>Art and magic share a sublime beauty, and, as a bard, you seek the place where the two meet. You might be a naturally talented wanderer who casts impressive spells almost instinctively, a student of a bardic college who learned ordered systems of magic and epic poetry, a warrior skald who mixes skill at arms with thundering music, a dashing performer known for putting on a good show even for your enemies, or a perfectionist who seeks the consummate formula that blends art and magic into a higher force.</p><p>A steady rhythm beats in the back of your mind as you brandish your sword. Your eyes and ears pick up the motion of the villains that surround you, and one glance tells you everything you need to know to defeat them. You whistle three staccato notes, letting your allies know the symphony of battle is about to begin.</p>",
"<p>Secretive and enigmatic, druids call the wilderness their home. They are capable of running with a wolf pack, speaking with the most ancient trees, and watching thunderstorms from atop the clouds themselves. They regard challenges as tests, both of their fitness and of their connection with the wild places of the world. And though many druids project an outward calm, they have the cunning of the beast and the fury of the storm.</p><p>Whether you were born to the wilds or retreated from civilization, whether you chose your path or answered a call that whispered in your heart, you share a bond with the primal spirits of nature. You are neither their servant nor their master, but winds, trees, and beasts heed your words, for they recognize you as kin.</p><p>Call to the spirits, and they will entangle your foes or smite your enemies with the storm. Unleash your own spirit, and you will become the Primal Beast, uncaged and untamed.</p>",
"<p>At the dawn of time, the gods who inhabited the Astral Sea warred with the primordials of the Elemental Chaos, the mighty beings who shaped the world out of formless void. The greatest of the gods' mortal agents in that war were invokers, imbued with a fragment of the gods' own might to fight alongside them. No other mortal servant of the gods can claim the same kind of power. Through rites of investiture, avengers, clerics, and paladins gain the ability to manifest echoes of that power, uttering careful prayers and channeling divine energy through their holy symbols. You, however, channel your god's power directly. No mere symbol can contain it, for you speak the words of creation, shaping the universe to your and your god's will.</p><p>Perhaps you were trained in a secret monastery, or you studied in a library where the universe's oldest lore was preserved. Or perhaps you experienced the presence of your god firsthand and took a shard of divine power into yourself. You might even be an immortal born into flesh, slowly awakening to the awesome divine power that is your birthright. Whatever your past, you are among the gods' most trusted servants, bound to a covenant in which you swore to use divine power with great care. To what end will you wield that might?</p>",
"<p>Shamans are inspiring and dangerous battle leaders. They command powerful spirit guides, and through them lead their allies. These nature spirits bolster their allies' attacks and offer protection and healing when needed.</p><p>In a rite of passage or initiation, you pledged yourself to the spirits, to be their voice and hands in the world. Through ancient song and sacred ceremony, you have called a powerful spirit companion to your side. The primal spirits of nature affirm your will, guide the actions of your allies, and deal mighty attacks against your foes. You might be a venerable advisor to a tribal leader, a young traveler seeking to bring tales of a wider world back to your people, or a scholar devoted to the pursuit of nearly forgotten lore.</p><p>The spirits and voices of nature guide your every step. Their power flows through you, calling you to lead, to fight, and to triumph.</p>",
"<p>The sorcerer is the arcane antithesis of the wizard. Wielding raw, barely contained magical power, sorcerers channel bursts and blasts of arcane energy through their bodies. They gain their power not through rigorous study of esoteric tomes, but by harnessing magic in their blood, waiting to be tapped and shaped. If wizards wield magic as fighters wield swords, a sorcerer's magic is the arcing greataxe of a raging barbarian.</p><p>You might be a proud dragonborn scion of ancient Arkhosia, calling on the draconic power of your heritage, or perhaps you were bathed in dragon blood as an infant to fill you with that power. You might have been born in a place where planar forces converged in strange eddies, infusing you with chaos, or perhaps you survived implantation of a slaad embryo, which left the taint of chaos upon you.</p><p>Magic pulses through your veins, calling on you to give it expression. As it grows ever stronger, will it consume you or transform you into magic incarnate?</p>",
"<p>As mountains stand fast against the buffeting wind and trees bend but do not break in the storm, wardens are stalwart protectors who draw on the primal spirits of nature to defend the natural world from those who would corrupt or destroy it. Some wardens use the power of earth and stone to shield their allies from harm, whereas others summon the primal strength within themselves to increase their ferocity and tenacity.</p><p>As a warden, you might be the staunch defender of a tribe, chosen by the spirits to be your people's champion. Perhaps you were visited by spirits at a sacred grove and charged with protecting it against a spreading corruption. You might have been raised by a bear or nurtured by dryads, chosen from infancy to stand fast against nature's enemies.</p><p>Primal power waits in the ground beneath your feet, surges with every beat of your heart, and flows through your lungs with every breath. The world cries out to you, calling for a champion to defend it. Will you heed its call?</p>",
"<p>Artificers treat mastery of magic like a tech­nical skill. They see a pattern in energy and matter, and they develop an understanding of how to manipulate the flow of arcane energy in and around material objects and creatures. Artificers learn to channel magic into items by using complex chains of sigils and diagrams or by using magical materi­als. With their skills, they can assemble the perfect magical object for any situation.</p><p>As an artificer, you might have learned your craft through a variety of means. You could be a formal student of arcana who became interested in magic items and arti­facts. Maybe you're a tinkerer who devised magic tools in a musty basement. Or perhaps you are an explorer who found your knowledge in forgotten places.</p><p>With a bandolier slung across your chest, you carry an arsenal of alchemical compounds, magical implements, mundane materials, and tools. You mix reagents, drink potions, and craft items. And you use your knowledge to infuse yourself and your allies with arcane power. One day, your magical skills will carry you into legend.</p>"
); 

var classquote = new Array(
"Have courage, my friends! Pelor favors us today!",
"You'll have to deal with me first, dragon!",
"I am the righteous shield of Moradin and a sword in his mighty hand! I fear no evil!",
"I'll get the one in the back. That's one hobgoblin who'll regret ever lifting a bow.",
"You look surprised to see me. If you'd been paying attention, you might still be alive.",
"The darkness holds no terror for me, demon! I curse you now under the Sign of Ill Omen!",
"Onward to victory! They cannot stand before us!",
"I am the fire that burns, the choking fog, the storm that rains devastation on our foes.",
"Under the leaves of Myth Drannor I learned the ancient eladrin way of battle. Spells are my armor, and words of ruin are bound to my blade.",
"Everything my god needs to say to you can be said with my weapon.",
"My strength is the fury of the wild.",
"The clash of blades, a note/A battle fought, a verse/The hero's war, a song.",
"I am the seeker. I am the stalker. I am the storm.",
"The only thing stronger than my faith is the fire I use to burn away those who stand against the will of the gods.",
"The spirits surround us, guide us, and hold all the knowledge of the world.",
"I am in the arcane, and the arcane is in me.",
"Get past me? You might as well try to push the mountains aside.",
"I see the secret patterns of magic, and through the items I carry, I can use that magic to protect you, heal you... or make you explode."
); 


var complink = "http://ww2.wizards.com/dnd/insider/class.aspx?id="; 
var complink2 = "http://www.wizards.com/dndinsider/compendium/database.aspx?searchterm=";
var classids = new Array("2","3","4","5","6","7","8","9","53","129","148","104","126","127","147","128","134","125"); 
var catlink = "http://www.wizards.com/default.asp?x=products/dndacc/" 
var classsource = new Array("219567200","219567200","219567200","219567200","219567200","219567200","219567200","219567200","219567200","9780786950164","9780786950164","9780786950164","9780786950164","9780786950164","9780786950164","9780786950164","9780786950164","9780786950164"); 

// =================================================================

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
};

function rand(number) {
	return Math.round(rnd()*number) ;
};

// =================================================================

shufflequestions();

function shufflequestions () {
	var qs = qx.length
	for (z=0; z<qs; z++){
		getq = rand(qx.length - 1);
		qlist[z] = qx[getq]	
		qx.splice(getq, 1);
	}
}

// =================================================================

function question () {
 
	document.getElementById("tally").innerHTML = "<a href='javascript:nextquestion()'><img id='nextimg' src='images/q_next.jpg' border='0'/></a>";
	var xx = new Array(0,1,2,3);
	var xlist = new Array();
	var xs = xx.length
	for (z=0; z<xs; z++){
		getx = rand(xx.length - 1);
		xlist[z] = xx[getx]	
		xx.splice(getx, 1);
	}
	var xanswer = new Array();
	var xpoints = new Array();	
	qnbr = qlist[Q];
	qsplit = questions[qnbr] 
	qsplit = qsplit.split(":")
	xanswer[0] = qsplit[1]
	xanswer[1] = qsplit[3]
	xanswer[2] = qsplit[5]
	xanswer[3] = qsplit[7]
	xpoints[0] = qsplit[2]
	xpoints[1] = qsplit[4]
	xpoints[2] = qsplit[6]
	xpoints[3] = qsplit[8]
	if (qsplit[9] == 1) { catonetrack += 1 };
	if (qsplit[9] == 2) { cattwotrack += 1 };
 	document.getElementById("question").innerHTML = "<span class='size18'>" + qsplit[0] + "</span>"; 	
 	qtext = qsplit[0];
	var xdisp = "<img src='images/q_line.jpg' border='0' height='1px' width='560px'/><br/><img src='images/clear.gif' border='0' height='10px' width='560px'/><br/>"
	for (z=0; z<4; z++){
		xdisp += "<table border='0' width='100%' cellpadding='2' cellspacing='2'><tr><td valign='top' width='20px'><input type='radio' name='qst' value='" + xpoints[xlist[z]] + "'></td><td valign='top'><span style='font-weight: bold; color: #4a2500' class='size15'>" + xanswer[xlist[z]] + "</span></td></tr></table><img src='images/clear.gif' border='0' height='10px' width='600px'/><br/><img src='images/q_line.jpg' border='0' height='1px' width='560px'/><br/><img src='images/clear.gif' border='0' height='10px' width='560px'/>" 
	}	
 	document.getElementById("answers").innerHTML = xdisp	
}

// =================================================================

function nextquestion () {
	chosen = ""
	len = document.form1.qst.length
	for (i = 0; i <len; i++) {
		if (document.form1.qst[i].checked) {
			chosen = document.form1.qst[i].value
		}
	}
	if (chosen == "") {
		alert("Please Choose an Answer")
	}
	else {
		if (chosen == "Defender") { Defender += 1 };
		if (chosen == "Leader") { Leader += 1 };
		if (chosen == "Controller") { Controller += 1 };
		if (chosen == "Striker") { Striker += 1 };
		if (chosen == "Primal") { Primal += 1 };
		if (chosen == "Arcane") { Arcane += 1 };
		if (chosen == "Divine") { Divine += 1 };	
		if (chosen == "Martial") { Martial += 1 };
		if (Q < 9) {
			Q += 1
			question();
		} else {
			checkwinners();
			checkclass();
		}
	}
} 

// =================================================================

function switchanswer () {
	document.getElementById("questionback").style.visibility = "hidden";	
	document.getElementById("question").style.visibility = "hidden";
	document.getElementById("answers").style.visibility = "hidden";	
	document.getElementById("tally").style.visibility = "hidden";	
	document.getElementById("answerback").style.visibility = "visible";	
	document.getElementById("classimg").style.visibility = "visible";	
	document.getElementById("classblurb").style.visibility = "visible";	
	document.getElementById("bbhtml").style.visibility = "visible";	
	document.getElementById("answerback").style.visibility = "visible";	
	document.getElementById("again").style.visibility = "visible";	
	document.getElementById("image").style.visibility = "visible";		
	return;
}	
	
function tieone () {
	document.getElementById("tally").innerHTML = "<a href='javascript:tiequestion()'><img src='images/q_next.jpg' border='0'/></a>";	
	var tx = new Array(0,1);
	var tlist = new Array();
	var ts = tx.length
	for (z=0; z<ts; z++){
		gett = rand(tx.length - 1);
		tlist[z] = tx[gett]	
		tx.splice(gett, 1);
	}
	var tanswer = new Array();
	var tpoints = new Array();
	tsplit = tieonequestion 
	tsplit = tsplit.split(":")
 	document.getElementById("question").innerHTML = "<span class='size18'>" + tsplit[0] + "</span>"; 		
 	qtext = tsplit[0];
	tanswer[0] = tsplit[1]
	tanswer[1] = tsplit[3]
	tpoints[0] = tsplit[2]
	tpoints[1] = tsplit[4]
	var xdisp = ""
	for (z=0; z<2; z++){
		xdisp += "<table border='0' width='100%' cellpadding='2' cellspacing='2'><tr><td valign='top' width='20px'><input type='radio' name='qst' value='" + tpoints[tlist[z]] + "'></td><td valign='top'><span style='font-weight: bold; color: #4a2500' class='size15'>" + tanswer[tlist[z]] + "</span></td></tr></table><img src='images/clear.gif' border='0' height='10px' width='600px'/><br/><img src='images/q_line.jpg' border='0' height='1px' width='560px'/><br/><img src='images/clear.gif' border='0' height='10px' width='560px'/>" 
	}	
 	document.getElementById("answers").innerHTML = xdisp	
}

// =================================================================

function tietwo () {
	document.getElementById("tally").innerHTML = "<a href='javascript:tiequestion()'><img src='images/q_next.jpg' border='0'/></a>";	
	var tx = new Array(0,1);
	var tlist = new Array();
	var ts = tx.length
	for (z=0; z<ts; z++){
		gett = rand(tx.length - 1);
		tlist[z] = tx[gett]	
		tx.splice(gett, 1);
	}
	var tanswer = new Array();
	var tpoints = new Array();
	tsplit = tietwoquestion 
	tsplit = tsplit.split(":")
 	document.getElementById("question").innerHTML = "<span class='size18'>" + tsplit[0] + "</span>"; 		
 	qtext = tsplit[0];
	tanswer[0] = tsplit[1]
	tanswer[1] = tsplit[3]
	tpoints[0] = tsplit[2]
	tpoints[1] = tsplit[4]
	var xdisp = ""
	for (z=0; z<2; z++){
		xdisp += "<table border='0' width='100%' cellpadding='2' cellspacing='2'><tr><td valign='top' width='20px'><input type='radio' name='qst' value='" + tpoints[tlist[z]] + "'></td><td valign='top'><span style='font-weight: bold; color: #4a2500' class='size15'>" + tanswer[tlist[z]] + "</span></td></tr></table><img src='images/clear.gif' border='0' height='10px' width='600px'/><br/><img src='images/q_line.jpg' border='0' height='1px' width='560px'/><br/><img src='images/clear.gif' border='0' height='10px' width='560px'/>" 
	}	
 	document.getElementById("answers").innerHTML = xdisp	
}

// =================================================================

function tiethree () {
	document.getElementById("tally").innerHTML = "<a href='javascript:tiequestion()'><img src='images/q_next.jpg' border='0'/></a>";	
	var tx = new Array(0,1);
	var tlist = new Array();
	var ts = tx.length
	for (z=0; z<ts; z++){
		gett = rand(tx.length - 1);
		tlist[z] = tx[gett]	
		tx.splice(gett, 1);
	}
	var tanswer = new Array();
	var tpoints = new Array();
	tsplit = tiethreequestion 
	tsplit = tsplit.split(":")
 	document.getElementById("question").innerHTML = "<span class='size18'>" + tsplit[0] + "</span>"; 		
 	qtext = tsplit[0];
	tanswer[0] = tsplit[1]
	tanswer[1] = tsplit[3]
	tpoints[0] = tsplit[2]
	tpoints[1] = tsplit[4]
	var xdisp = ""
	for (z=0; z<2; z++){
		xdisp += "<table border='0' width='100%' cellpadding='2' cellspacing='2'><tr><td valign='top' width='20px'><input type='radio' name='qst' value='" + tpoints[tlist[z]] + "'></td><td valign='top'><span style='font-weight: bold; color: #4a2500' class='size15'>" + tanswer[tlist[z]] + "</span></td></tr></table><img src='images/clear.gif' border='0' height='10px' width='600px'/><br/><img src='images/q_line.jpg' border='0' height='1px' width='560px'/><br/><img src='images/clear.gif' border='0' height='10px' width='560px'/>" 
	}	
 	document.getElementById("answers").innerHTML = xdisp	
}

// =================================================================

function tiequestion () {
	chosen = "";
	len = document.form1.qst.length
	for (i = 0; i <len; i++) {
		if (document.form1.qst[i].checked) {
			chosen = document.form1.qst[i].value
		}
	}
	if (chosen == "") {
		alert("Please Choose an Answer")
	}
	else {
		if (chosen == "Sorcerer") { classwinner = "Sorcerer"};
		if (chosen == "Warlock") { classwinner = "Warlock"};
		if (chosen == "Rogue") { classwinner = "Rogue"};
		if (chosen == "Ranger") { classwinner = "Ranger"};
		if (chosen == "Bard") { classwinner = "Bard"};
		if (chosen == "Artificer") { classwinner = "Artificer"};
		document.getElementById("tally").innerHTML = "";	
		showclass(classwinner);
	}
} 


function showclass (cwin) {
	len = classes.length
	for (i = 0; i <len; i++) {
		if (classes[i] == cwin) {
			cnbr = i;
		}
	}		
	classblurb[cnbr]	
 	document.getElementById("classimg").innerHTML = "<a href='" + complink + classids[cnbr] + "' target='_blank'><img src='images/titles/" + cwin + ".jpg' border='0'/></a>";
 	document.getElementById("image").innerHTML = "<a href='" + catlink + classsource[cnbr] + "' target='_blank'><img src='images/splash/" + cwin + ".jpg' border='0'/></a>";
 	document.getElementById("classblurb").innerHTML = "<span style='color:#a40000 ;' class='size12'><b><i>\"" + classquote[cnbr] + "\"</i></b></span><span class='size11'>" + classblurb[cnbr] + "</span>"; 	
	switchanswer();	
	setcode(cnbr);
	dispcode('html');
} 

// =================================================================

function noclass () {
	var d_one = rand(3 + 1);
	var d_two = rand(3 + 1);
	var d_three = rand(3 + 1);
	var coinflip = rand(2 - 1)
	var martialcoin = "";
	var controllercoin = "";
	if (Martial == Controller) {
		if (coinflip == 1) { 
			Martial += 1
		 	martialcoin = "*";
		} else {
			controllercoin = "*";
			Controller += 1
		}
	}
	if (Martial >= Controller) {
		if ((Primal + Arcane + Divine) == 0) {
			Primal = d_one;
			Arcane = d_two;
			Divine = d_three;
			Martial = 0;
		} else {
			Primal += 1;
			Arcane += 1;
			Divine += 1;
			Martial = 0;
		} 
	} else {
		if ((Defender + Leader + Striker) == 0) {
			Defender = d_one; 
			Leader = d_two;
			Striker = d_three;
			Controller = 0;
		} else {
			Defender += 1; 
			Leader += 1;
			Striker += 1;
			Controller = 0;
		}
	}
	checkwinners();
	checkclass();	
}


// =================================================================

/*
Primal + Controller = Druid
Primal + Defender = Warden
Primal + Leader = Shaman
Primal + Striker = Barbarian
Arcane + Controller = Wizard
Arcane + Defender = Swordmage
Arcane + Leader = Tie 3 (Bard/Artificer)
Arcane + Striker = Tie 1 (Sorcerer/Warlock)
Divine + Controller = Invoker
Divine + Defender = Paladin
Divine + Leader = Cleric
Divine + Striker = Avenger
Martial + Controller = 0 (no class)
Martial + Defender = Fighter
Martial + Leader = Warlord
Martial + Striker = Tie 2 (Ranger/Rogue)
*/

function checkwinners () {
		classwinner = "None";
		catonetie = "None";
		catonevalue = 0;
		catonetievalue = 0;
		if (Defender > catonevalue) { 
			catonewinner = "Defender";			
			catonevalue = Defender
		}
		if (Leader == catonevalue) { 
			catonetie = "Leader";			
			catonetievalue = Leader
		}
		if (Leader > catonevalue) { 
			catonewinner = "Leader";			
			catonevalue = Leader
		}
		if (Controller == catonevalue) { 
			catonetie = "Controller";			
			catonetievalue = Controller
		}
		if (Controller > catonevalue) { 
			catonewinner = "Controller";			
			catonevalue = Controller
		}
		if (Striker == catonevalue) { 
			catonetie = "Striker";			
			catonetievalue = Striker
		}		
		if (Striker > catonevalue) { 
			catonewinner = "Striker";			
			catonevalue = Striker
		}		
		cattwowinner = "None";
		cattwotie = "None";
		cattwovalue = 0;
		cattwotievalue = 0;
		if (Primal > cattwovalue) { 
			cattwowinner = "Primal";			
			cattwovalue = Primal
		}
		if (Arcane == cattwovalue) { 
			cattwotie = "Arcane";			
			cattwotievalue = Arcane
		}
		if (Arcane > cattwovalue) { 
			cattwowinner = "Arcane";			
			cattwovalue = Arcane
		}
		if (Divine == cattwovalue) { 
			cattwotie = "Divine";			
			cattwotievalue = Divine
		}
		if (Divine > cattwovalue) { 
			cattwowinner = "Divine";			
			cattwovalue = Divine
		}
		if (Martial == cattwovalue) { 
			cattwotie = "Martial";			
			cattwotievalue = Martial
		}		
		if (Martial > cattwovalue) { 
			cattwowinner = "Martial";			
			cattwovalue = Martial
		}		
		if (catonevalue == catonetievalue) {
			coinflip = rand(2 - 1);
			if (coinflip == 1) {
				catonewinner = catonetie;		
			}
		} 
		if (cattwovalue == cattwotievalue) {
			coinflip = rand(2 - 1);
			if (coinflip == 1) {
				cattwowinner = cattwotie;		
			}
		}
}

// =================================================================

function checkclass () {
	var classwinner = "None" 
	if (cattwowinner == "Primal") {
		if (catonewinner == "Controller") {
			classwinner = "Druid"		
		}	
		if (catonewinner == "Defender") {
			classwinner = "Warden"			
		}	
		if (catonewinner == "Leader") {
			classwinner = "Shaman"			
		}	
		if (catonewinner == "Striker") {
			classwinner = "Barbarian"			
		}	
	}
	if (cattwowinner == "Arcane") {
		if (catonewinner == "Controller") {
			classwinner = "Wizard"			
		}	
		if (catonewinner == "Defender") {
			classwinner = "Swordmage"			
		}	
		if (catonewinner == "Leader") {
			classwinner = "Tie 3 (Bard/Artificer)"			
		}	
		if (catonewinner == "Striker") {
			classwinner = "Tie 1 (Sorcerer/Warlock)"	
		}	
	}
	if (cattwowinner == "Divine") {
		if (catonewinner == "Controller") {
			classwinner = "Invoker"			
		}	
		if (catonewinner == "Defender") {
			classwinner = "Paladin"			
		}	
		if (catonewinner == "Leader") {
			classwinner = "Cleric"			
		}	
		if (catonewinner == "Striker") {
			classwinner = "Avenger"			
		}	
	}
	if (cattwowinner == "Martial") {
		if (catonewinner == "Controller") {
			classwinner = "(no class)"	
		}	
		if (catonewinner == "Defender") {
			classwinner = "Fighter"			
		}	
		if (catonewinner == "Leader") {
			classwinner = "Warlord"			
		}	
		if (catonewinner == "Striker") {
			classwinner = "Tie 2 (Ranger/Rogue)"	
		}	
	}
	if (classwinner == "Tie 1 (Sorcerer/Warlock)")
		{ 
			tieone();
		} 
	else if (classwinner == "Tie 2 (Ranger/Rogue)")
		{ 
			tietwo(); 
		}
	else if (classwinner == "Tie 3 (Bard/Artificer)")
		{ 
			tiethree(); 
		}				
	else if (classwinner == "(no class)") 
		{
			noclass();
		}
	else
		{
			showclass(classwinner);
		}
}

// =================================================================

function setcode (snbr) {
	codehtml = '<p align="center"><img src="http://www.wizards.com/dnd/class/images/banners/' + classes[snbr] + '.jpg"/><br/><a href="http://www.wizards.com/dnd/" target="_blank">D&D Home Page</a> - <a href="http://www.wizards.com/dnd/class/index.asp" target="_blank">What Class Are You?</a> - <a href="http://www.wizards.com/default.asp?x=dnd/insider/characterbuilder" target="_blank">Build A Character</a> - <a href="' + complink2 + classes[cnbr] + '" target="_blank">D&amp;D Compendium</a></p>';
	codedetailedhtml = '<p align="center"><img src="http://www.wizards.com/dnd/class/images/banners/' + classes[snbr] + '.jpg"/>' + classblurb[cnbr] + '<a href="http://www.wizards.com/dnd/" target="_blank">D&D Home Page</a> - <a href="http://www.wizards.com/dnd/class/index.asp" target="_blank">What Class Are You?</a> - <a href="http://www.wizards.com/default.asp?x=dnd/insider/characterbuilder" target="_blank">Build A Character</a> - <a href="' + complink2 + classes[cnbr] + '" target="_blank">D&amp;D Compendium</a></p>';
	codebb = '[CENTER][IMG]http://www.wizards.com/dnd/class/images/banners/' + classes[snbr] + '.jpg[/IMG]\n[URL="http://www.wizards.com/dnd/"]D&D Home Page[/URL] - [URL="http://www.wizards.com/dnd/class/index.asp"]What Class Are You?[/URL] - [URL="http://www.wizards.com/default.asp?x=dnd/insider/characterbuilder"]Build A Character[/URL] - [URL="' + complink2 + classes[cnbr] + '"]D&D Compendium[/URL][/CENTER]';
	codetext = "My Class is " + classes[snbr] + " ... \"" + classquote[snbr] + "\"" ;
	codeimage = 'http://www.wizards.com/dnd/class/images/banners/' + classes[snbr] + '.jpg' ;
}

// =================================================================

function dispcode (ctype) {
	if (ctype == "html")
		{
			document.getElementById("codeword").innerHTML = "HTML";
			document.form1.classcode.value = codehtml;
		} 
	else if (ctype == "detailedhtml")
		{
			document.getElementById("codeword").innerHTML = "HTML";
			document.form1.classcode.value = codedetailedhtml;
		} 		
	else if (ctype == "bb")
		{
			document.getElementById("codeword").innerHTML = "BB code";
			document.form1.classcode.value = codebb;
		} 
	else if (ctype == "image")
		{
			document.getElementById("codeword").innerHTML = "image";
			document.form1.classcode.value = codeimage;
		} 
	else 
		{
			document.getElementById("codeword").innerHTML = "text";
			document.form1.classcode.value = codetext;
		} 
}

// =================================================================

function playagain () {
	window.location.reload( true );
}

// =================================================================

function theyear () {
	document.getElementById("thisyear").innerHTML = year; 
}

// =================================================================

