	window.onload = init;
	document.getElementById('btnclr1').onclick = newBoard;
	document.getElementById('btn1').onclick = answer;
	document.getElementById('btn2').onclick = check;
	var counter=1;
	var sc=1;
	var btnClr = document.getElementById('btnclr1');
	var btnReponses = document.getElementById('btn1');
	var btnValider = document.getElementById('btn2');

function init() {
	document.getElementById("screen1").style.display = 'block';
	var audioElement1 = document.getElementById('a1');
			audioElement1.pause();
			audioElement1.currentTime = 0;
		btnClr.disabled=true;
		btnClr.setAttribute('style', "color:#D4D0C8");
		btnValider.disabled=true;
		btnValider.setAttribute('style', "color:#D4D0C8");
		btnReponses.disabled=true;
		btnReponses.setAttribute('style', "color:#D4D0C8");
}

var selectedImage;
function select(image) {
	//var images = document.querySelectorAll('img');
	var images = document.getElementsByClassName('img');
	var index = 0, length = images.length;
	for (; index < length; index++) {
		//images[index].classList.remove('selected');
		//images[index].removeAttribute('style');
	}
	selectedImage = image.id;
	image.classList.add('selected');
	btnValider.disabled=false;
	btnValider.setAttribute('style', "color:#000000");
	btnReponses.disabled=true;
	btnReponses.setAttribute('style', "color:#D4D0C8");
}
var right = 0;
var wrong = 0;
var checkCount = 0;

function newBoard() {
	sc = 1;
	if (counter < 3) {
		counter+=1;
	} else {
		counter = 1;
	}
	var screenElement = document.getElementsByClassName('screen');
	for(var i=1; i < screenElement.length+1; i++) {
		var screenElement1 = document.getElementById('screen'+i).style.display ='none';
		audioElement1 = document.getElementById('a'+i);
		audioElement1.pause();
		audioElement1.currentTime = 0;
	}
	var screenElement2 = document.getElementById('screen'+counter).style.display = 'block';
	var audioElement2 = document.getElementById('a'+counter);
	//console.log(audioElement2);
		audioElement2.pause();
		audioElement2.currentTime = 0;
	var images1 = document.getElementsByClassName('img');
	for(var i=1; i < images1.length+1; i++) {
		var image2 = document.getElementById('img'+i);
		image2.removeAttribute("style");
		image2.classList.remove('selected');
		image2.setAttribute("value", "false")
	}
	if (counter == 1) {
		var x1 = document.getElementById('img1').setAttribute("value", "true")
		var x2 = document.getElementById('img5').setAttribute("value", "true")
	} else if (counter == 2) {
		var x1 = document.getElementById('img3').setAttribute("value", "true")
	} else if (counter == 3) {
		var x1 = document.getElementById('img2').setAttribute("value", "true")
		var x2 = document.getElementById('img4').setAttribute("value", "true")
	}
		btnClr.disabled=true;
		btnClr.setAttribute('style', "color:#D4D0C8");
		btnValider.disabled=true;
		btnValider.setAttribute('style', "color:#D4D0C8");
		btnReponses.disabled=true;
		btnReponses.setAttribute('style', "color:#D4D0C8");
}
function check() {
	sc = 1;
	var images1 = document.getElementsByClassName('img selected');
	for(var i=0; i < images1.length; i++) {
		var ix=images1[i];
		if (ix.getAttribute('value') == "true") {
			ix.setAttribute("style","border: 3px solid #008000;border-radius: 10px;-moz-box-shadow: 4px 4px 8px #008000;-webkit-box-shadow: 4px 4px 8px #008000;-o-box-shadow: 4px 4px 8px #008000;box-shadow: 4px 4px 8px #008000;");
		} else {
			ix.setAttribute("style","border: 3px solid #FF0000;border-radius: 10px;-moz-box-shadow: 4px 4px 8px #FF0000;-webkit-box-shadow: 4px 4px 8px #FF0000;-o-box-shadow: 4px 4px 8px #FF0000;box-shadow: 4px 4px 8px #FF0000;");
		}
	}
		btnClr.disabled=false;
		btnClr.setAttribute('style', "color:#000000");
		btnReponses.disabled=false;
		btnReponses.setAttribute('style', "color:#000000");
}

function answer() { 
	var imageCount = document.getElementsByClassName('img');
	if (sc == 1) {
		btnClr.disabled = true;
		btnClr.setAttribute('style', 'color:#D4D0C8;');
		btnValider.disabled = true;
		btnValider.setAttribute('style', "color:#D4D0C8;");
		for(var i=0; i < imageCount.length; i++) {
			var ix=imageCount[i];
			ix.setAttribute('onclick', 'return false;');
			if (ix.getAttribute('value') == "true") {
					ix.setAttribute("style","border: 3px solid #008000;border-radius: 10px;-moz-box-shadow: 4px 4px 8px #008000;-webkit-box-shadow: 4px 4px 8px #008000;-o-box-shadow: 4px 4px 8px #008000;box-shadow: 4px 4px 8px #008000;");
			}
		}
	sc += 1
	} else {
		for(var i=0; i < imageCount.length; i++) {
			var ix=imageCount[i];
			ix.removeAttribute('style');
			ix.setAttribute('onclick', 'select(this)');
		}
		btnValider.disabled = false;
		btnValider.setAttribute('style', "color:#000000;");
		sc -= 1
		check();
	}
}
