﻿	var myFlag = 0	// Vlag, om te voorkomen dat imagemap aanklikbaar is
	var winList = new Array("##@$#, Revenche!!","Are you cheating on me?","Hmmm, don't be too smart, ok?"); 
	var looseList = new Array("Haha, please pay attention!","Haha, my mother in law even plays better!","Got any money left?"); 
	var budget = 200 // startbedrag is 200 euro
	
function check() { 
	if (budget > 0) {
		comment = ""; // commentaar tekst is leeg	
		document.getElementById("tekst").innerHTML = comment; // commentaar naar pagina
		document.mrGamble.src = "/images/shuffle.gif";  // gif animatie starten
		var the_timeout = setTimeout("stopAnim();",2000); // timer starten om gif animatie te stoppen
	} else {
		comment = "Ok, new changes for you!"; // commentaar tekst is leeg	
		document.getElementById("tekst").innerHTML = comment; // commentaar naar pagina
		document.mrGamble.src = "/images/still.gif";  // gif animatie starten
		document.play_button.myButton.value="Play € 50"; // buttontekst aanpassen
		budget = 200; // budget is weer 200 euro
		document.getElementById("geld").innerHTML = '&euro; '+ budget; 
	}
}
function stopAnim() {
	document.mrGamble.src = "/images/still.gif"; // gif animatie is vervangen door plaatje
	myFlag = 1; // Imagemap is aanklikbaar
}
function checkChoice(myChoice) {
	var ballPos = Math.floor((Math.random() * 3) + 1);  // random number tussen 1 en 3 = positie van het balletje
    var ballChoice = myChoice; // gekozen beker 
	if (myFlag == 1) { // als Imagemap aanklikbaar is
		if (ballPos == ballChoice){ // Als goede beker is gekozen
			var result = "/images/"+myChoice+"b.gif"; // maak variabele result met pad naar juiste gif
			document.mrGamble.src = result; // laat juiste gif zien
			comment = winList [Math.floor(Math.random() * winList.length)];  // commentaar tekst random uit winList
		    document.getElementById("tekst").innerHTML = comment; // commentaar naar pagina
			budget =  budget + 100 // inzet wordt verdubbeld en betaald
			document.getElementById("geld").innerHTML = '&euro; '+ budget;  // nieuw bedrag wordt op scherm gezet
		} else { // Als goede beker NIET is gekozen
			var result = "/images/"+myChoice+"l.gif"; // maak variabele result met pad naar juiste gif
			document.mrGamble.src = result; // laat juiste gif zien
			comment = looseList [Math.floor(Math.random() * looseList.length)]; // commentaar tekst
		    document.getElementById("tekst").innerHTML = comment; // commentaar naar pagina
			budget = budget - 50 // inzet wordt afgetrokken van budget
			document.getElementById("geld").innerHTML = '&euro; '+ budget; // nieuw bedrag wordt op scherm gezet
			if (budget == 0) { // als geld op is
				document.play_button.myButton.value= "Borrow € 200"; // button tekst veranderd, om geld te kunnen lenen
			}
		}
	myFlag = 0;	// Imagemap is NIET aanklikbaar
	}
}


