function wizJumpMenu() {
	theMenu = document.getElementById("WizardMenu");
	destination = theMenu.options[theMenu.selectedIndex].value;
	location.href = destination;
}

var WizardLanguage = "english";

// ~/disease-info/diseases/asthma/kids/wizard/chapter2.aspx
function lightUp() { document.images["java"].src="/imgs/ewebeditor/wiz-2.gif" }
function dimDown() { document.images["java"].src="/imgs/ewebeditor/wiz-1.gif" }

// ~/disease-info/diseases/asthma/kids/wizard/chapter10-3.aspx
function lightUpCh10() { document.images["java"].src="/imgs/ewebeditor/pg_62brth.gif" }
function dimDownCh10() { document.images["java"].src="/imgs/ewebeditor/pg_62b.gif" }

// ~/disease-info/diseases/asthma/kids/wizard/chapter10-medquiz.aspx
function Gradeit(language) {	
	var answer1 = document.getElementById("q1").selectedIndex;
	var answer2 = document.getElementById("q2").selectedIndex;
	var answer3 = document.getElementById("q3").selectedIndex;	
	function getselectedIndex(){
		return answer1;
		return answer2;
		return answer3;
	}
	var Answers=new Array(1,2,2,3,1);
	var UserAnswers = new Array(answer1,answer2,answer3);
	var count0 = 0;
	if (Answers[0] == UserAnswers[0]) {
		count0 = count0 + 1
	} else {
		count0 = count0
	}
	if (Answers[1] == UserAnswers[1]) {
		count1 = count0 + 1
	} else {
		count1 = count0
	}
	if (Answers[2] == UserAnswers[2]) {
		count2 = count1 + 1
	} else {
		count2 = count1
	}
	if (language == "spanish") {
		alert("Ok Aprendiz, has sacado " + count2+ "/3 correcto!")
	} else {
		alert("Ok Apprentice, you got " + count2 + "/3 right!")
	}
}

// ~/disease-info/diseases/asthma/kids/wizard/chapter13-quiz.aspx
function Gradeit2(language) {
	var answer1 = document.getElementById("q1").selectedIndex;
	var answer2 = document.getElementById("q2").selectedIndex;
	var answer3 = document.getElementById("q3").selectedIndex;
	var answer4 = document.getElementById("q4").selectedIndex;
	var answer5 = document.getElementById("q5").selectedIndex;
	function getselectedIndex(){
		return answer1;
		return answer2;
		return answer3;
		return answer4;
		return answer5;
	}
	var Answers=new Array(1,2,2,3,1)
	var UserAnswers = new Array(answer1,answer2,answer3,answer4,answer5)
	var count0 = 0
	if (Answers[0] == UserAnswers[0]) {
		count0 = count0 + 1
	} else {
		count0 = count0
	}
	if (Answers[1] == UserAnswers[1]) {
		count1 = count0 + 1
	} else {
		count1 = count0
	}
	if (Answers[2] == UserAnswers[2]) {
		count2 = count1 + 1
	} else {
		count2 = count1
	}
	if (Answers[3] == UserAnswers[3]) {
		count3 = count2 + 1
	} else {
		count3 = count2
	}
	if (Answers[4] == UserAnswers[4]) {
		count4 = count3 + 1
	} else {
		count4 = count3
	}
	if (language == "spanish") {
		alert("Ok Aprendiz, has sacado " + count4 + "/5 correcto!")
	} else {
		alert("Alright Apprentice, you got " + count4 + "/5 right!")
	}
}

// Early Warning Word Find - ~/disease-info/diseases/asthma/kids/wizard/chapter15-wordfind.aspx
function showCrossWordImg(elToShow) {
	document.getElementById("Itchy").style.display = ("none");
	document.getElementById("Grumpy").style.display = ("none");
	document.getElementById("Sneezing").style.display = ("none");
	document.getElementById("Headache").style.display = ("none");
	document.getElementById("Cough").style.display = ("none");
	document.getElementById(elToShow).style.display = ("block");
}


// Smoke Free Puzzle
/*
Original:  John Chacko (johns221b@yahoo.com)
Web Site:  http://holmes221b.50megs.com
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
*/

var blank_pos = 16, count = 0, pos = new Array(), nam = new Array();
function start() {
	pos[1] = 7;
	pos[2] = 10;
	pos[3] = 14;
	pos[4] = 9;
	pos[5] = 12;
	pos[6] = 2;
	pos[7] = 13;
	pos[8] = 1;
	pos[9] = 8;
	pos[10] = 5;
	pos[11] = 4;
	pos[12] = 6;
	pos[13] = 3;
	pos[14] = 11;
	pos[15] = 15;
	nam[1] = document.getElementById("L1").style;
	nam[2] = document.getElementById("L2").style;
	nam[3] = document.getElementById("L3").style;
	nam[4] = document.getElementById("L4").style;
	nam[5] = document.getElementById("L5").style;
	nam[6] = document.getElementById("L6").style;
	nam[7] = document.getElementById("L7").style;
	nam[8] = document.getElementById("L8").style;
	nam[9] = document.getElementById("L9").style;
	nam[10] = document.getElementById("L10").style;
	nam[11] = document.getElementById("L11").style;
	nam[12] = document.getElementById("L12").style;
	nam[13] = document.getElementById("L13").style;
	nam[14] = document.getElementById("L14").style;
	nam[15] = document.getElementById("L15").style;
	document.onkeydown = keyDown;
	document.getElementById("SmokeFreePuzzle").style.visibility = ("visible");
}
function keyDown(e) {
	if (!e) var e = window.event;
	switch (e.keyCode) {
		case 38:
			if (blank_pos < 13) {
				count = blank_pos + 4;
				X = fun(count);
				nam[X].top = addToLength(nam[X].top, -77);
				Q = pos[X];
				pos[X] = blank_pos;
				blank_pos = Q;
			}
			break;
		case 40:
			if (blank_pos > 4) {
				count = blank_pos - 4;
				X = fun(count);
				nam[X].top = addToLength(nam[X].top, 77);
				Q = pos[X];
				pos[X] = blank_pos;
				blank_pos = Q;
			}
			break;
		case 37:
			r = blank_pos % 4
			if (r != 0) {
				count = blank_pos + 1;
				X = fun(count);
				nam[X].left = addToLength(nam[X].left, -77);
				Q = pos[X];
				pos[X] = blank_pos;
				blank_pos = Q;
			}
			break;
		case 39:
			ch = blank_pos + 3;
			r = ch % 4;
			if (r != 0) {
				count = blank_pos - 1;
				X = fun(count);
				nam[X].left = addToLength(nam[X].left, 77);
				Q = pos[X];
				pos[X] = blank_pos;
				blank_pos = Q;
			}
			break;
	}
	A = false;
	b = 0;
	for (i = 1; i < 16; i++) {
		b++;
		if (pos[i] == b) {
			A = true;
		}
		else {
			A = false;
			break;
		}
	}
	if (A) alert("CONGRATULATIONS");
}
function fun(count) {
	for (var i = 1; i < 16; i++) {
		if (pos[i] == count) {
			var X = i;
		}
	}
	return X;
}
function addToLength(initialLength, pixels) {
	return (parseInt(initialLength.substring(0, initialLength.length - 2)) + pixels) + 'px';
}
// End Smoke Free Puzzle

// Peg Game
/* Original:  Erik Gos (erik.gos@hiva.kuleuven.ac.be)
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com */

var pos=new Array(49);
var jumps=new Array();
var boardType="Solitaire";
var numMoves=0;
var finished=false;
var selectnum=false;
var autosolve=false;
var running=false;
var basenum=0;
var destnum=0;
var destnum1=0;
var destnum2=0;
var destnum3=0;
var destnum4=0;
var delaynum=500;
if (document.images) {
blank = new Image(19,19);
blank.src = "/incs/wizard/asthma/english/ch19/blank.gif";
empty = new Image(19,19);
empty.src = "/incs/wizard/asthma/english/ch19/empty.gif";
emptysel = new Image(19,19);
emptysel.src = "/incs/wizard/asthma/english/ch19/emptysel.gif";
peg = new Image(19,19);
peg.src = "/incs/wizard/asthma/english/ch19/peg.gif";
pegact = new Image(19,19);
pegact.src = "/incs/wizard/asthma/english/ch19/pegact.gif";
}
function display(pos,basenum,destnum) {
selectnum=false;
if (!basenum && !destnum) {
for (var i=0; i<pos.length; i++) {
if (pos[i]==-1) document.images["img"+i].src=blank.src;
else if (pos[i]==1) document.images["img"+i].src=peg.src;
else document.images["img"+i].src=empty.src;
 }
}
else {
document.images["img"+basenum].src=empty.src;
document.images["img"+(basenum+destnum/2)].src=empty.src;
document.images["img"+(basenum+destnum)].src=peg.src;
for (var i=0; i<pos.length; i++) {
if (document.images["img"+i].src==emptysel.src)
document.images["img"+i].src=empty.src;
 }
}
if (numMoves>1) win();
}
function move(num) {
var curNumMoves=numMoves;
if (!document.images)
alert("Your browser does not support the 'document.images' property.You\n" +
"should upgrade to at least Netscape 3.0 or Internet explorer 4.0.");
else if (autosolve && running) {}
else if (autosolve && !finished) {
if (confirm('You interrupted the \'Solve\' function. Want to try it yourself?'))
newGame();
}
else if (selectnum) {
if (num!=basenum && num!=basenum+destnum1 && num!=basenum+destnum2 &&
num!=basenum+destnum3 && num!=basenum+destnum4)
alert("Select a destination or click on the original peg again!");
else if (num==basenum) {
document.images["img"+basenum].src=peg.src;
if (destnum1!=0)
document.images["img"+(basenum+destnum1)].src=empty.src;
if (destnum2!=0)
document.images["img"+(basenum+destnum2)].src=empty.src;
if (destnum3!=0)
document.images["img"+(basenum+destnum3)].src=empty.src;
if (destnum4!=0)
document.images["img"+(basenum+destnum4)].src=empty.src;
selectnum=false;
}
else if (num==basenum+destnum1) movePeg(basenum,destnum1)
else if (num==basenum+destnum2) movePeg(basenum,destnum2)
else if (num==basenum+destnum3) movePeg(basenum,destnum3)
else if (num==basenum+destnum4) movePeg(basenum,destnum4)
}
else if (pos[num]==0) {
}
else if ((num==3 || num==10) && pos[num+7]==1 && pos[num+14]==0) movePeg(num,14);
else if ((num==45 || num==38) && pos[num-7]==1 && pos[num-14]==0) movePeg(num,-14);
else if ((num==21 || num==22) && pos[num+1]==1 && pos[num+2]==0) movePeg(num,2);
else if ((num==26 || num==27) && pos[num-1]==1 && pos[num-2]==0) movePeg(num,-2);
else if (num==4 || num==11 || num==19 || num==20) {
if (pos[num-1]==1 && pos[num-2]==0 && pos[num+7]==1 && pos[num+14]==0)
selPeg(num,-2,14);
else if (pos[num-1]==1 && pos[num-2]==0) movePeg(num,-2);
else if (pos[num+7]==1 && pos[num+14]==0) movePeg(num,14);
}
else if (num==2 || num==9 || num==14 || num==15) {
if (pos[num+1]==1 && pos[num+2]==0 && pos[num+7]==1 && pos[num+14]==0)
selPeg(num,2,14);
else if (pos[num+1]==1 && pos[num+2]==0) movePeg(num,2);
else if (pos[num+7]==1 && pos[num+14]==0) movePeg(num,14);
}
else if (num==28 || num==29 || num==37 || num==44) {
if (pos[num+1]==1 && pos[num+2]==0 && pos[num-7]==1 && pos[num-14]==0)
selPeg(num,2,-14);
else if (pos[num+1]==1 && pos[num+2]==0) movePeg(num,2);
else if (pos[num-7]==1 && pos[num-14]==0) movePeg(num,-14);
}
else if (num==33 || num==34 || num==39 || num==46) {
if (pos[num-1]==1 && pos[num-2]==0 && pos[num-7]==1 && pos[num-14]==0)
selPeg(num,-2,-14);
else if (pos[num-1]==1 && pos[num-2]==0) movePeg(num,-2);
else if (pos[num-7]==1 && pos[num-14]==0) movePeg(num,-14);
}
else if (num==16 || num==17 || num==18 || num==23 || num==24 || num==25 || num==30 || num==31 || num==32) {
var cond1=(pos[num-1]==1 && pos[num-2]==0);
var cond2=(pos[num-7]==1 && pos[num-14]==0);
var cond3=(pos[num+1]==1 && pos[num+2]==0);
var cond4=(pos[num+7]==1 && pos[num+14]==0);
if ((cond1 && (cond2 || cond3 || cond4)) ||
(cond2 && (cond1 || cond3 || cond4)) ||
(cond3 && (cond1 || cond2 || cond4)))
{
basenum=num;
destnum1=destnum2=destnum3=destnum4=0;
document.images["img"+basenum].src=pegact.src;
if (cond1) {
destnum1=-2;
document.images["img"+(basenum+destnum1)].src=emptysel.src;
}
if (cond2) {
destnum2=-14;
document.images["img"+(basenum+destnum2)].src=emptysel.src;
}
if (cond3) {
destnum3=2;
document.images["img"+(basenum+destnum3)].src=emptysel.src;
}
if (cond4) {
destnum4=14;
document.images["img"+(basenum+destnum4)].src=emptysel.src;
}
selectnum=true;
}
else if (cond1) movePeg(num,-2);
else if (cond2) movePeg(num,-14);
else if (cond3) movePeg(num,2);
else if (cond4) movePeg(num,14);
}
if (curNumMoves!=numMoves) display(pos,basenum,destnum);
else if (finished) win();
}
function selPeg(num,ofset1,ofset2) {
basenum=num;
destnum1=ofset1;
destnum2=ofset2;
destnum3=destnum4=0;
document.images["img"+basenum].src=pegact.src;
document.images["img"+(basenum+destnum1)].src=emptysel.src;
document.images["img"+(basenum+destnum2)].src=emptysel.src;
selectnum=true;
}
function movePeg(num,ofset) {
pos[num+ofset]=1;
pos[num+ofset/2]=pos[num]=0
basenum=num;
destnum=ofset;
numMoves++;
}
function win() {
var cnt=0;
for(var i=0; i<pos.length; i++) {
if (pos[i]!=-1) cnt+=pos[i];
}
if (cnt==1 && autosolve) {
if (confirm('You let the \'Solve\' function do it. Want to try it yourself?'))
newGame();
}
else if (cnt==1 && pos[24]==1) {
finished=true;
if (confirm('You found the best solution! Do you want to restart?')) newGame();
}
else if (cnt==1) {
finished=true;
if (confirm('You did it! Do you want to restart?')) newGame();
}
else {
var legalMoves=false;
var num=0;
while (num<pos.length && !legalMoves) {
if (pos[num]==1 &&
(((num==2 || num==9 || num==14 || num==15 || num==16 || num==17 ||
num==18 || num==23 || num==24 || num==25 || num==30 || num==31 ||
num==32 || num==21 || num==22 || num==28 || num==29 || num==37 ||
num==44) && pos[num+1]==1 && pos[num+2]==0) ||
((num==4 || num==11 || num==19 || num==20 || num==16 || num==17 ||
num==18 || num==23 || num==24 || num==25 || num==30 || num==31 ||
num==32 || num==26 || num==27 || num==33 || num==34 || num==39 ||
num==46) && pos[num-1]==1 && pos[num-2]==0) ||
((num==2 || num==9 || num==14 || num==15 || num==16 || num==17 ||
num==18 || num==23 || num==24 || num==25 || num==30 || num==31 ||
num==32 || num==4 || num==11 || num==19 || num==20 || num==3 ||
num==10) && pos[num+7]==1 && pos[num+14]==0) ||
((num==33 || num==34 || num==39 || num==46 || num==16 || num==17 ||
num==18 || num==23 || num==24 || num==25 || num==30 || num==31 ||
num==32 || num==45 || num==38 || num==28 || num==29 || num==37 ||
num==44) && pos[num-7]==1 && pos[num-14]==0)))
legalMoves=true;
num++;
}
if (!legalMoves) {
finished=true;
if (confirm('No more moves Apprentice! Do you want to play again?')) newGame();
      }
   }
}
function newGame() {
if (autosolve && running) {}
else if (document.images) {
autosolve=false;
finished=false;
if (boardType=="Cross") {
for (var i=0; i<pos.length; i++) pos[i]=0;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[10]=pos[16]=pos[17]=pos[18]=pos[24]=pos[31]=1;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Plus") {
for (var i=0; i<pos.length; i++) pos[i]=0;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[10]=pos[17]=pos[22]=pos[23]=pos[24]=1;
pos[25]=pos[26]=pos[31]=pos[38]=1;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Fireplace") {
for (var i=0; i<pos.length; i++) pos[i]=0;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[2]=pos[3]=pos[4]=pos[9]=pos[10]=1;
pos[11]=pos[16]=pos[17]=pos[18]=1;
pos[23]=pos[25]=1;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Up Arrow") {
for (var i=0; i<pos.length; i++) pos[i]=0;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[3]=pos[9]=pos[10]=pos[11]=pos[15]=1;
pos[16]=pos[17]=pos[18]=pos[19]=1;
pos[24]=pos[31]=pos[37]=pos[38]=1;
pos[39]=pos[44]=pos[45]=pos[46]=1;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Pyramid") {
for (var i=0; i<pos.length; i++) pos[i]=0;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[10]=pos[16]=pos[17]=pos[18]=pos[22]=1;
pos[23]=pos[24]=pos[25]=pos[26]=1;
pos[28]=pos[29]=pos[30]=pos[31]=1;
pos[32]=pos[33]=pos[34]=1;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Diamond") {
for (var i=0; i<pos.length; i++) pos[i]=1;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[2]=pos[4]=pos[14]=pos[20]=pos[24]=0;
pos[28]=pos[34]=pos[44]=pos[46]=0;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
else if (boardType=="Solitaire") {
for (var i=0; i<pos.length; i++) pos[i]=1;
pos[0]=pos[1]=pos[5]=pos[6]=-1;
pos[7]=pos[8]=pos[12]=pos[13]=-1;
pos[24]=0;
pos[35]=pos[36]=pos[40]=pos[41]=-1;
pos[42]=pos[43]=pos[47]=pos[48]=-1;
}
numMoves=0;
running=true;
changeBoard();
running=false;
solveArray();
display(pos);
}
else
alert("Your browser does not support the 'document.images' property.You\n" +
"should upgrade to at least Netscape 3.0 or Internet explorer 4.0.");
}
function initArray() {
this.length=initArray.arguments.length;
for (var i=0; i<this.length; i++) {
this[i] = initArray.arguments[i];
   }
}
function drawPreview(start,end) {
i=start;
j=end;
baseref=jumps[start];
offset=jumps[start+1];
pos[baseref]=pos[baseref+offset/2]=0;
pos[baseref+offset]=1;
document.images["img"+baseref].src=pegact.src;
document.images["img"+(baseref+offset)].src=emptysel.src;
solveRunning=setTimeout('drawJump(i,j)',delaynum);
}
function drawJump(start,end) {
i=start; j=end;
baseref=jumps[start];
offset=jumps[start+1];
document.images["img"+baseref].src=empty.src;
document.images["img"+(baseref+offset/2)].src=empty.src;
document.images["img"+(baseref+offset)].src=peg.src;
if (start+2==end) {
document.getElementById("SolveButton").value="Solve";
running=false;
finished=true;
setTimeout('win()',delaynum);
}
else solveRunning=setTimeout('drawPreview(i+2,j)',delaynum);
}
function solve() {
if (!document.images)
alert("Your browser does not support the 'document.images' property.You\n" +
"should upgrade to at least Netscape 3.0 or Internet explorer 4.0.");
else if (autosolve && running) {
clearTimeout(solveRunning);
document.getElementById("SolveButton").value="Solve";
running=false;
}
else {
document.getElementById("SolveButton").value=" Stop ";
newGame();
autosolve=true;
running=true;
solveRunning=setTimeout('drawPreview(0,jumps.length)',delaynum);
   }
}
function changeBoard() {
formName=document.getElementById("optionsSelect");
if (!running) {
boardType=formName.options[formName.options.selectedIndex].value;
newGame();
}
else {
optlength=formName.options.length;
for (var m=0; m<optlength; m++) {
if (formName.options[m].value==boardType) {
formName.options.selectedIndex=m;
break;
         }
      }
   }
}
function solveArray() {
if (boardType=="Cross") {
jumps = new initArray(17,-2,31,-14,18,-2,15,2,10,14);
}
else if (boardType=="Plus") {
jumps = new initArray(23,-2,25,-2,10,14,24,-2,21,2,
38,-14,23,2,26,-2);
}
else if (boardType=="Fireplace") {
jumps = new initArray(17,2,4,14,25,-14,2,2,4,14,
19,-2,10,14,24,-2,9,14,22,2);
}
else if (boardType=="Up Arrow") {
jumps = new initArray(46,-14,31,2,45,-14,44,-14,30,2,33,-2,
18,-14,4,-2,16,2,2,14,15,2,18,-2,31,
-14,16,2,19,-2,10,14);
}
else if (boardType=="Pyramid") {
jumps = new initArray(23,14,25,14,28,2,34,-2,37,-14,39,-14,
16,14,18,-2,31,-2,29,-14,15,2,17,14,
26,-2,31,-14,10,14);
}
else if (boardType=="Diamond") {
jumps = new initArray(30,14,44,2,32,2,34,-14,18,-14,4,-2,
16,-2,14,14,46,-14,20,-2,2,14,28,2,
38,-14,17,-2,15,14,29,2,31,2,33,-14,
19,-2,24,-2,10,14,25,-2,22,2);
}
else if (boardType=="Solitaire") {
jumps = new initArray(38,-14,33,-2,46,-14,25,14,44,2,46,-14,
11,14,20,-2,17,2,34,-14,20,-2,
15,2,2,14,23,-14,4,-2,2,14,
37,-14,28,2,31,-2,14,14,28,2,
17,-2,15,14,29,2,31,2,33,-14,19,-2,
24,-2,10,14,25,-2,22,2);
   }
}
// End Peg Game



// Begin Allergy Wizard
// Allergy Quiz - ~/disease-info/diseases/allergy/kids/wizard/chapter1-5.aspx
var ans = new Array;
var done = new Array;
var yourAns = new Array;
var explainAnswer = new Array;

var score = 0;
ans[1] = "False";
ans[2] = "True";
ans[3] = "True";
ans[4] = "False";
ans[5] = "True";

explainAnswer[1]="Not all people have allergies.";
explainAnswer[2]="Allergies can make your nose and skin itch.";
explainAnswer[3]="Allergies can make it harder to breathe.";
explainAnswer[4]="Allergens are things you are allergic to such as animals, grass, and dustmites.";
explainAnswer[5]="Your doctor might give you medicine to help your allergies.";

function Engine(question, answer) {
yourAns[question]=answer;
}

function Score(){
var answerText = "How did you do?\n------------------------------------\n";
for(i=1;i<=5;i++){
   answerText=answerText+"\nQuestion :"+i+"\n";
  if(ans[i]!=yourAns[i]){
    answerText=answerText+"\nThe correct answer was "+ans[i]+"\n"+explainAnswer[i]+"\n";
  }
  else{
    answerText=answerText+" \nCorrect! \n";
    score++;
  }
}

answerText=answerText+"\n\nYour total score is : "+score+"\n";

//now score the user
answerText=answerText+"\nComment : ";
if(score<=0){
answerText=answerText+"Take the test again before you play the game.";
}
if(score>=1 && score <=2){
answerText=answerText+"Take the test again before you play the game.";
}
if(score>=3 && score <=3){
answerText=answerText+"Take the test again before you play the game.";
}
if(score>4){
answerText=answerText+"Congratulations! You have completed the first Allergy Wizard Chapter! You are ready to play the game.";
}

alert(answerText);

}

// Allergy Quiz Spanish
var ansSpan = new Array;
var doneSpan = new Array;
var yourAnsSpan = new Array;
var explainAnswerSpan = new Array;

var scoreSpan = 0;
ansSpan[1] = "Falso";
ansSpan[2] = "Cierto";
ansSpan[3] = "Cierto";
ansSpan[4] = "Falso";
ansSpan[5] = "Cierto";

explainAnswerSpan[1]="No todo el mundo tiene alergias.";
explainAnswerSpan[2]="Las alergias pueden hacer que te pique la nariz y la piel.";
explainAnswerSpan[3]="Las alergias pueden hacerte dificil la respiraci\u00F3n.";
explainAnswerSpan[4]="Al\u00E9rgenos son cosas a las que t\u00FA eres alergico, como los animales, la hierba y los \u00E1caros de polvo.";
explainAnswerSpan[5]="Puede ser que tu doctor te recete medicamentos para ayudarte con tus alergias.";


function EngineSpan(question, answer) {
yourAnsSpan[question]=answer;
}

function ScoreSpan() {
	var answerTextSpan = "\u00BFC\u00F3mo te ha salido?\n------------------------------------\n";
	for(i=1;i<=5;i++) {
		answerTextSpan=answerTextSpan+"\nPregunta :"+i+"\n";
		if(ansSpan[i]!=yourAnsSpan[i]) {
			answerTextSpan=answerTextSpan+"\nLa respuesta correcta era "+ansSpan[i]+"\n"+explainAnswerSpan[i]+"\n";
		} else {
			answerTextSpan=answerTextSpan+" \n\u00A1Has Acertado! \n";
			scoreSpan++;
		}
	}

	answerTextSpan=answerTextSpan+"\n\nHas sacado: "+scoreSpan+"\n";

	//now score the user
	answerTextSpan=answerTextSpan+"\nComentario : ";
	if(scoreSpan<=0) {
		answerTextSpan=answerTextSpan+"Hazlo otra vez antes de comenzar el juego.";
	}

	if(scoreSpan>=1 && scoreSpan <=2) {
		answerTextSpan=answerTextSpan+"Hazlo otra vez antes de comenzar el juego.";
	}

	if(scoreSpan>=3 && scoreSpan <=3) {
		answerTextSpan=answerTextSpan+"Hazlo otra vez antes de comenzar el juego.";
	}

	if(scoreSpan>4) {
		answerTextSpan=answerTextSpan+"ˇFelicitaciones! Has terminado el primero de los capítulos del Mago de las! Ahora estas listo para hacer el juego.";
	}

	alert(answerTextSpan);

}





// Maze
var nImgOffset = 0
var nLinkOffset = 2
var nMazeRows = 6
var nMazeCols = 9
var nwizardRow = 4
var nwizardCol = 1

var lwizardIntro = false
var nImgCols = nMazeCols * 2 + 1
var nImgRows = nMazeRows * 2 + 1


function SetGameStatus(elem) {
	nRow = GetRow(elem)
	nCol = GetCol(elem)
	nImg = GetImg(nRow, nCol)
	if (((Math.abs(nRow - nwizardRow) == 1 && nCol == nwizardCol)
			|| (nRow == nwizardRow && Math.abs(nCol - nwizardCol) == 1))
			&& (document.images[nImg].src.indexOf("/imgs/ewebeditor/white.gif") > -1)) {
		if (nRow < nwizardRow && document.images[nwizardImg - nImgCols].name == 'wall'
				|| nRow > nwizardRow && document.images[nwizardImg + nImgCols].name == 'wall'
				|| nCol < nwizardCol && document.images[nwizardImg - 1].name == 'wall'
				|| nCol > nwizardCol && document.images[nwizardImg + 1].name == 'wall') {
			status = ""
		} else {
			if (WizardLanguage == "spanish") {
				status = "Pulsa aqu\u00ED para mover al Mago de las Alergias."
			} else {
				status = "Click to move the Allergy Wizard here."
			}
		}
		return true
	}
	if (nRow == nwizardRow && nCol == nwizardCol && !lwizardIntro) {	
			if (WizardLanguage == "spanish") {
				status = "Pulsa aqu\u00ED para que el Mago de las Alergias te diga lo que hacer."
			} else {
				status = "Click to have the Allergy Wizard tell you what to do."
			}		
		return true
	}
	status = ""
	return true
}


function ClearStatus(msg) {
	status = ""
	return true
}


function ImagesLoaded() {
	return true
	for (i = 0; i < document.images.length; i++) {
		if (!document.images[i].complete) {
			return false
		}
	}
	return true
}


function Click(elem) {
	if (!ImagesLoaded()) {
		alert("Please wait for all Images to load.")
		return
	}
	var nClickRow = GetRow(elem)
	var nClickCol = GetCol(elem)
	
	if (Movewizard(nClickRow, nClickCol)) {
		ShowPath(elem)
	}
}


function Movewizard(row, col) {
	var nImg = GetImg(row, col)
	var nLastImg = GetImg(nwizardRow, nwizardCol)

	if ((status == "Click to move the Allergy Wizard here.") || (status == "Pulsa aqu\u00ED para mover al Mago de las Alergias.")) {
		document.images[nLastImg].src = "/imgs/ewebeditor/white.gif"
		document.images[nImg].src = "/imgs/ewebeditor/maze_wizard.gif"

		nwizardRow = row
		nwizardCol = col
		nwizardImg = GetImg(nwizardRow, nwizardCol)

		if (document.images[nwizardImg].name == 'Exit') {
			if (WizardLanguage == "spanish") {
				alert("\u00A1Bravo! Lo hemos logrado.")
			} else {
				alert("Hurray! We made it.")
			}
			
			window.location = "chapter1-maze.aspx"
		}

		return true

	} else {
		if ((status == "Click to have the Allergy Wizard tell you what to do.") || (status = "Pulsa aqu\u00ED para que el Mago de las Alergias te diga lo que hacer.")) {
			lwizardIntro = true
			
			if (WizardLanguage == "spanish") {
				alert("Hola. Soy el Mago de las Alergias.\nPuedes ayudarme a cruzar el laberinto?\nJust Pulsa en el cuadrito cerca de m\u00ED, y yo ire all\u00ED.")
			} else {
				alert("Hi. I'm the Allergy wizard.\nCan you help me get across this maze?\nJust click on a square next to me, and I'll go there.")
			}			
			return false
		}
	}
}


function ShowPath(elem) {
	var nRow = GetRow(elem)
	var nCol = GetCol(elem)
	var nImg = GetImg(nRow, nCol)
	
	if (document.images[nImg - nImgCols].name == 'door') {
		document.images[nImg - nImgCols].src = "/imgs/ewebeditor/white.gif"
		document.images[nImg - nImgCols * 2].src = "/imgs/ewebeditor/white.gif"
		ShowDoors(nImg - nImgCols * 2)
	}
	if (document.images[nImg + 1].name == 'door' && nCol < nMazeCols) {
		document.images[nImg + 1].src = "/imgs/ewebeditor/white.gif"
		document.images[nImg + 2].src = "/imgs/ewebeditor/white.gif"
		ShowDoors(nImg + 2)
	}
	if (document.images[nImg + nImgCols].name == 'door' && nRow < nMazeRows) {
		document.images[nImg + nImgCols].src = "/imgs/ewebeditor/white.gif"
		document.images[nImg + nImgCols * 2].src = "/imgs/ewebeditor/white.gif"
		ShowDoors(nImg + nImgCols * 2)
	}
	if (document.images[nImg - 1].name == 'door' && nCol > 1) {
		document.images[nImg - 1].src = "/imgs/ewebeditor/white.gif"
		document.images[nImg - 2].src = "/imgs/ewebeditor/white.gif"
		ShowDoors(nImg - 2)
	}
	if (document.images[nImg].name == 'Exit') {
		ShowDoors(nImg)
	}
}


function ShowDoors(img) {
	if (document.images[img - 1].name == 'door') {
		document.images[img - 1].src = "/imgs/ewebeditor/white.gif"
	}
	if (document.images[img + 1].name == 'door') {
		document.images[img + 1].src = "/imgs/ewebeditor/white.gif"
	}
	if (document.images[img - nImgCols].name == 'door') {
		document.images[img - nImgCols].src = "/imgs/ewebeditor/white.gif"
	}
	if (document.images[img + nImgCols].name == 'door') {
		document.images[img + nImgCols].src = "/imgs/ewebeditor/white.gif"
	}
}


function GetElem(row, col) {
	return (row - 1) * nMazeCols + (col - 1)
}


function GetImg(row, col) {
	return (row - 1) * nImgCols * 2 + nImgCols + 1 + (col - 1) * 2 + nImgOffset
}


function GetRow(elem) {
	return Math.round(elem / nMazeCols - .5) + 1
}


function GetCol(elem) {
	return elem % nMazeCols + 1
}

nwizardImg = GetImg(nwizardRow, nwizardCol)
