var result = 0;
var colors = new Array("red", "blue", "green", "orange", "brown", "purple");

function rollDices() {
	result = 0;
	document.getElementById("petalsCheck").style.display = "none";
	document.getElementById("petalsQuestion").style.display = "block";
	
	document.getElementById("petalsAnswer").value = "";
	
	document.getElementById("petalsAnswer").focus();
	
	for (i = 1; i < 6 ; i++) {
		rand = parseInt(Math.random()*6 + 1)
		switch(rand) {
			case(3): result += 2; break;
			case(5): result += 4; break;
		}
		dice = document.getElementById("petalsDice" + i);
		dice.src = "http://traugutt.net/lo/pliki/petals/dice" + rand + ".gif";
		dice.style.background = colors[parseInt(Math.random() * colors.length)]
	}
}

function checkAnswer() {
	document.getElementById("petalsCheck").style.display = "block";
	document.getElementById("petalsQuestion").style.display = "none";
	
	answer = document.getElementById("petalsGoodWrong");
	document.getElementById("nrOfPetals").lastChild.nodeValue = result;
	if (document.getElementById("petalsAnswer").value == result) {
		
		answer.className = "goodAnswer";
		answer.lastChild.nodeValue = "DOBRZE!";
	} else {
		answer.className = "wrongAnswer";
		answer.lastChild.nodeValue = "¬LE!";
	}
	document.getElementById("rollButton").focus();
	
}


