﻿choixtableau = "t0";
tb1 = "mada";
tb2 = "mada";
tb3 = "mada";
tb4 = "mada";
tb5 = "mada";
tb6 = "mada";
tb7 = "mada";
tb8 = "mada";
tb9 = "mada";
tb10 = "mada";
victoire = 0;

function resetableaux() {
document.getElementById("t1").border = "2";
document.getElementById("t1").bgColor = "pink";
document.getElementById("t1").style.borderColor = "";
document.getElementById("t2").border = "2";
document.getElementById("t2").bgColor = "pink";
document.getElementById("t2").style.borderColor = "";
document.getElementById("t3").border = "2";
document.getElementById("t3").bgColor = "pink";
document.getElementById("t3").style.borderColor = "";
document.getElementById("t4").border = "2";
document.getElementById("t4").bgColor = "pink";
document.getElementById("t4").style.borderColor = "";
document.getElementById("t5").border = "2";
document.getElementById("t5").bgColor = "pink";
document.getElementById("t5").style.borderColor = "";
document.getElementById("t6").border = "2";
document.getElementById("t6").bgColor = "pink";
document.getElementById("t6").style.borderColor = "";
document.getElementById("t7").border = "2";
document.getElementById("t7").bgColor = "pink";
document.getElementById("t7").style.borderColor = "";
document.getElementById("t8").border = "2";
document.getElementById("t8").bgColor = "pink";
document.getElementById("t8").style.borderColor = "";
document.getElementById("t9").border = "2";
document.getElementById("t9").bgColor = "pink";
document.getElementById("t9").style.borderColor = "";
document.getElementById("t10").border = "2";
document.getElementById("t10").bgColor = "pink";
document.getElementById("t10").style.borderColor = "";

choixtableau = "t0";
tb1 = "mada";
tb2 = "mada";
tb3 = "mada";
tb4 = "mada";
tb5 = "mada";
tb6 = "mada";
tb7 = "mada";
tb8 = "mada";
tb9 = "mada";
tb10 = "mada";
victoire = -1;
}

function changetableau(tableau) {

var choixtableauprec = choixtableau;
choixtableau = tableau;

switch(choixtableau) {
 case "t1":
	if (tb1 == "mada" && (choixtableauprec == "t0" || tb2 == "attente")) {
	tb1 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb1 == "attente" && tb2 == "attente") {
		document.getElementById("t1").style.borderColor = "white";
		document.getElementById("t2").style.borderColor = "white";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t2":
	if (tb2 == "mada" && (choixtableauprec == "t0" || tb1 == "attente")) {
	tb2 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb1 == "attente" && tb2 == "attente") {
		document.getElementById("t1").style.borderColor = "white";
		document.getElementById("t2").style.borderColor = "white";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t3":
	if (tb3 == "mada" && (choixtableauprec == "t0" || tb4 == "attente")) {
	tb3 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb3 == "attente" && tb4 == "attente") {
		document.getElementById("t3").style.borderColor = "lightyellow";
		document.getElementById("t4").style.borderColor = "lightyellow";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t4":
	if (tb4 == "mada" && (choixtableauprec == "t0" || tb3 == "attente")) {
	tb4 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb3 == "attente" && tb4 == "attente") {
		document.getElementById("t3").style.borderColor = "lightyellow";
		document.getElementById("t4").style.borderColor = "lightyellow";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t5":
	if (tb5 == "mada" && (choixtableauprec == "t0" || tb6 == "attente")) {
	tb5 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb5 == "attente" && tb6 == "attente") {
		document.getElementById("t5").style.borderColor = "lightgrey";
		document.getElementById("t6").style.borderColor = "lightgrey";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t6":
	if (tb6 == "mada" && (choixtableauprec == "t0" || tb5 == "attente")) {
	tb6 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb5 == "attente" && tb6 == "attente") {
		document.getElementById("t5").style.borderColor = "lightgrey";
		document.getElementById("t6").style.borderColor = "lightgrey";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t7":
	if (tb7 == "mada" && (choixtableauprec == "t0" || tb8 == "attente")) {
	tb7 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb7 == "attente" && tb8 == "attente") {
		document.getElementById("t7").style.borderColor = "lightskyblue";
		document.getElementById("t8").style.borderColor = "lightskyblue";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t8":
	if (tb8 == "mada" && (choixtableauprec == "t0" || tb7 == "attente")) {
	tb8 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb7 == "attente" && tb8 == "attente") {
		document.getElementById("t7").style.borderColor = "lightskyblue";
		document.getElementById("t8").style.borderColor = "lightskyblue";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t9":
	if (tb9 == "mada" && (choixtableauprec == "t0" || tb10 == "attente")) {
	tb9 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb9 == "attente" && tb10 == "attente") {
		document.getElementById("t9").style.borderColor = "aqua";
		document.getElementById("t10").style.borderColor = "aqua";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
 case "t10":
	if (tb10 == "mada" && (choixtableauprec == "t0" || tb9 == "attente")) {
	tb10 = "attente";
	document.getElementById(tableau).border = "10";
	document.getElementById(tableau).bgColor = "aqua";
	if (tb9 == "attente" && tb10 == "attente") {
		document.getElementById("t9").style.borderColor = "aqua";
		document.getElementById("t10").style.borderColor = "aqua";
		choixtableau = "t0";
		}
	}
	else resetableaux();
 break;
}

victoire = victoire + 1;
if (victoire == "10") if (confirm("出来ました！おめでとう！\n同じテーマで別出題しますか？")) location.reload();

	}

