	window.onload = init;
	document.getElementById('btnclr1').onclick = newBoard;
	document.getElementById('btn1').onclick = answer;
	document.getElementById('btn2').onclick = check1;

	var btnClr = document.getElementById('btnclr1');
	var btnReponses = document.getElementById('btn1');
	var btnValider = document.getElementById('btn2');

	var screen1 = document.getElementById('question');
	var screen2 = document.getElementById('answer');
	
	var sc = 1;

var counter=1;
function init() {
	btnReponses.disabled=true;
	btnReponses.setAttribute('style', "color:#D4D0C8");
	btnValider.disabled=true;
	btnValider.setAttribute('style', "color:#D4D0C8");
}
var selectedImage;
function select(image) {
	var images = document.getElementsByClassName('img');
	var index = 0, length = images.length;
	for (; index < length; index++) {
		images[index].setAttribute('onclick', 'select(this);');
	}
	selectedImage = image.id;
	image.classList.add('selected');
	image.setAttribute('style','border:2px solid #FFFFFF;');
	image.setAttribute('onclick','return false;');
	var str = selectedImage
	str = selectedImage.substring(5);
	var x1 = document.getElementById(str);
	x1.innerText='Vrai';
	btnValider.disabled=false;
	btnValider.setAttribute('style', "color:#000000");
}

function check1() {
	sc = 1;
	var images1 = document.getElementsByClassName('screen');
	for(var i=1; i <= images1.length; i++) {
	var sElement = document.getElementById('screen'+i);
	var sElementClass = sElement.getAttribute('class')
	if (sElementClass == 'screen selected') {
		var getAnswer = document.getElementById('n'+i);
		var corAnswer = document.getElementById('ans'+i);
				console.log(getAnswer.innerText)
				console.log(corAnswer.innerText)
			if (getAnswer.innerText == corAnswer.innerText) {
				sElement.setAttribute("style","border: 2px solid #008000;border-radius: 10px;color:#008000;");
			} else {
				sElement.setAttribute("style","border: 2px solid #FF0000;border-radius: 10px;color:#FF0000;");
			}
		}
	}
	btnReponses.disabled=false;
	btnReponses.setAttribute('style', "color:#000000");
}

function answer() {
	var que1 = document.getElementById('question');
	var ans1 = document.getElementById('answer');
	if (sc == 1) {
		que1.setAttribute('style', 'display:none')
		ans1.setAttribute('style', 'display:block')
		btnValider.disabled=true;
		btnValider.setAttribute('style', "color:#D4D0C8");
	sc += 1;
	} else {
		que1.setAttribute('style', 'display:block')
		ans1.setAttribute('style', 'display:none')
		btnValider.disabled=true;
		btnValider.setAttribute('style', "color:#D4D0C8");
		sc -= 1;
	}

	
}


function newBoard() {
	var que1 = document.getElementById('question');
	var ans1 = document.getElementById('answer');
		que1.setAttribute('style', 'display:block')
		ans1.setAttribute('style', 'display:none')
	var images1 = document.getElementsByClassName('screen');
	for(var i=1; i <= images1.length; i++) {
		var sElement = document.getElementById('screen'+i);
		sElement.removeAttribute('style');
		sElement.setAttribute('onclick', 'select(this)');
		sElement.setAttribute('class', 'screen');
		var eElement = document.getElementById('n'+i);
		eElement.innerText = 'Faux';
	}
	btnReponses.disabled=true;
	btnReponses.setAttribute('style', "color:#D4D0C8");
	btnValider.disabled=true;
	btnValider.setAttribute('style', "color:#D4D0C8");
}