function checkAnswer(tbox){
	a = ""
	a = a + tbox.value
	q = tbox.id;
	if('p'+a == q){
		document.getElementById('res' + q).innerText = 'Correct';
		document.getElementById('res' + q).style.backgroundColor = 'green';
	}
	else{
		if(a.length > 0){
			document.getElementById('res' + q).innerText = 'Wrong';
			document.getElementById('res' + q).style.backgroundColor = 'red';
		}
	}		
}

switch(chartNum){
	case 1:
		var points = new Array(37);
		points[0] = 'Empty';
		points[1] = 'In-Dahng';
		points[2] = 'Kwan-Ja-Nol-Ee';
		points[3] = 'Dong-Ja-Ryo';
		points[4] = 'In-Joong';
		points[5] = 'Ji-Chang';
		points[6] = 'Hohn-Soo';
		points[7] = 'In-Young';
		points[8] = 'Kyun-Jung';
		points[9] = 'Chun-Duhl';
		points[10] = 'Joong-Boo';
		points[11] = 'Ja-Goong';
		points[12] = 'Ohg-Yea';
		points[13] = 'Keug-Chun';
		points[14] = 'Dahn-Joong';
		points[15] = 'Bee-Nwe';
		points[16] = 'Koo-Mee';
		points[17] = 'Yoo-Gn';
		points[18] = 'Sang-Wahn';
		points[19] = 'Kee-Moon (Torso)';
		points[20] = 'Soh-Hae';
		points[21] = 'Kog-Tah';
		points[22] = 'Soo-Sahm-Rhee';
		points[23] = 'Jang-Moon';
		points[24] = 'Kee-Hae';
		points[25] = 'Boo-Sah';
		points[26] = 'Hap-Kog';
		points[27] = 'Oh-Rhee';
		points[28] = 'Bok-Toh';
		points[29] = 'Poong-Shi';
		points[30] = 'Kee-Moon (Leg)';
		points[31] = 'Hyul-Hae';
		points[32] = 'Dohk-Bee';
		points[33] = 'Um-Nung-Chun';
		points[34] = 'Johk-Sahm-Rhee';
		points[35] = 'Sahm-Um-Kyo';
		points[36] = 'Tae-Choong';
		break;
	case 2:
		var points = new Array(30);
		points[0] = 'Empty';
		points[1] = 'Kwan-Ja-Nol-Ee';
		points[2] = 'Dong-Ja-Ryo';
		points[3] = 'Chung-Hwe';
		points[4] = 'Noh-Shik';
		points[5] = 'Yee-Poong';
		points[6] = 'Chun-Yong';
		points[7] = 'Ji-Chang';
		points[8] = 'Hohn-Soo';
		points[9] = 'Boo-Dohl';
		points[10] = 'Dae-Choo';
		points[11] = 'Kyun-Jung';
		points[12] = 'Shin-Joo';
		points[13] = 'Chun-Johng';
		points[14] = 'Shin-Doh';
		points[15] = 'Shim-Yoo';
		points[16] = 'Chun-Yuhng';
		points[17] = 'Bee-Yoo';
		points[18] = 'Soh-Hae';
		points[19] = 'Kyung-Moon';
		points[20] = 'Myung-Moon';
		points[21] = 'Chun-Jung';
		points[22] = 'Hap-Kog';
		points[23] = 'Un-Moon';
		points[24] = 'Poong-Shi';
		points[25] = 'Yahng-Kwan';
		points[26] = 'Wee-Joong';
		points[27] = 'Seung-Geun';
		points[28] = 'Chong-Ah-Rhee';
		points[29] = 'Seung-Sahn';
		break;
	case 3:
		var points = new Array(12);
		points[0] = 'Empty';
		points[1] = 'Nwe-Hoh';
		points[2] = 'Chun-Joo';
		points[3] = 'Ah-Moon';
		points[4] = 'Dae-Choo';
		points[5] = 'Kyun-Jung';
		points[6] = 'Shin-Joo';
		points[7] = 'Chun-Johng';
		points[8] = 'Shin-Doh';
		points[9] = 'Shim-Yoo';
		points[10] = 'Bee-Yoo';
		points[11] = 'Kyung-Moon';
		points[12] = 'Myung-Moon';
		break;
}

//Randomize array
function Shuffle(Q){
	var r, t, j
	for(j=Q.length-1;j>0;j--){
		r=Random(j+1); 
		t=Q[j]; 
		Q[j]=Q[r];
		Q[r]=t
	}
	return Q
}
function Random(n){
	return Math.floor(n*(Math.random()%1));
}

var ranNums = new Array();
var b = 0;
while(b < points.length-1){
	ranNums.push(b+1);
	b++;
}

ranNums = Shuffle(ranNums);
i = 0;
while(i < points.length-1){
	document.writeln('<tr>');
	document.writeln('<td><input type=text maxlength=2 style="WIDTH: 20" id=p'+ranNums[i]+' onblur="checkAnswer(this);"></td>');
	document.writeln('<td>'+points[ranNums[i]]+'</td>');
	document.writeln('<td width=50><div id="resp'+ranNums[i]+'"></div></td>');
	i++;
	if(i != points.length-1){
		document.writeln('<td><input type=text maxlength=2 style="WIDTH: 20" id=p'+ranNums[i]+' onblur="checkAnswer(this);"></td>');
		document.writeln('<td>'+points[ranNums[i]]+'</td>');
		document.writeln('<td width=50><div id="resp'+ranNums[i]+'"></div></td>');
		document.writeln('</tr>');
		i++;
	}
}
