// Slot machine controlls

// 
function doneswitchon(){
	document.getElementById('donebtn').style.backgroundImage = 'url(images/spin_over.gif)';	
//	switchani = setTimeout("doneswitchback()",350);
}


function setBet(betting_amount, newbetting){
	
	if(rolling == false){
		
		if(newbetting != true){
			newbet = betvalue+betting_amount;
		}else{
			newbet = betting_amount;
		}

		if(newbet <= maxbet){

			if(newbet >=minimumbetting && newbet <= tempgold){
				
				betvalue = newbet;
				document.getElementById("betbox").innerHTML = newbet;
				
				if(betting_amount > 0){
					setMessage('Bet changed to '+newbet+minicurrency[currencyselection]);
				}
				savePrefs()	;
				
			}else if(newbet > tempgold){
				setMessage('You can\'t bet more than your total '+minicurrency[currencyselection]);
				
			}else{
				setMessage('The minimum bet is '+minimumbetting+minicurrency[currencyselection])	
			}
		}else{
			// max bet	
			
			setMessage('The maximum bet is '+maxbet+minicurrency[currencyselection]);
			if(tempgold > maxbet ){
				betvalue = maxbet;
			}else{
				betvalue = tempgold;
			}
			setgold();			
			savePrefs()	;			
		}
	}else{
		setMessage('Cheater :) You can\'t change bets while spinning...')	
		
		
	}
}

function rollem () {
	if(displayscroller){
		clearTimeout(displayscroller);
		// skjul PLUS +	
		document.getElementById("plus").style.display = 'none';		
		// skjul PLUS +		
	}
	if(roll_count+1 > 0){
		roll_count++;
	}else{
		roll_count = 1;
	}
	savePrefs();

	
	if(rolling == false){
		max_count_a = 10+(Math.floor(Math.random()*(max_counter_d-15)));
		max_count_b = 10+(Math.floor(Math.random()*(max_counter_d-15)));
		max_count_c = 10+(Math.floor(Math.random()*(max_counter_d-15)));
		
		checkgold = Math.floor(tempgold); // hidden field		
	
			if (betvalue<1 || betvalue == "") {alert("You cannot bet less that 1.   "); return;
			}
			
			if(checkgold < Math.floor(betvalue) && checkgold > 0){
	//			alert('checkgold: '+checkgold)
				betvalue = checkgold;
				setBet(0); 
				return;
			}
			if (checkgold == 0) {
				//alert("Your bet "+document.slots.bet.innerHTML+" is larger than your remaining gold "+document.getElementById("gold_score").innerHTML+".  "); return;
				//alert('get 1000 new credits by visiting blog.kevinandersson.dk');
				//alert('get 1000 new credits by visiting blog.kevinandersson.dk');
				setMessage('Get '+addgold+' gold by visiting my blog. Click the link on the backside.');
				return;
			}
			
			if (betvalue>1) {
				document.slots.banner.value="Bet is "+betvalue+minicurrency[currencyselection];
			}
			
			else {
				document.slots.banner.value="Bet is "+betvalue+" "+minicurrency[currencyselection];
			}
			
			counter_a =0;
			counter_b =0;
			counter_c =0;
			counter_d =0;
			
			
	
			rolling = true;
			// Switch to animation
			if(hold1 == false){
			//document.slots.slot1.src= "blurred/Animation.gif"; 			
			}
			if(hold2 == false){
			//document.slots.slot2.src= "blurred/Animation.gif"; 							
			}
			if(hold3 == false){
			//document.slots.slot3.src= "blurred/Animation.gif"; 							
			}			
			spinem();
			doneswitchon();

	}else{
		setMessage( 'Wait for the spinners :)');
	}

}



function spinem() {
	
		
	if(hold1== false && counter_a < max_count_a){
		turns1=antal+Math.floor((Math.random() * antal));
		
		counter_a ++;
		
		for (a=0 ;a<turns1 ;a++)	{
			if(counter_a < max_count_a){
			/* Add  */ // 	
			document.slots.slot1.src= "blurred/"+slotitem[a % (antal)]+".png"; 		
			}
	
		}
		if(counter_a >= max_count_a){
			//alert('yep')
			current = slotitem[turns1 % (antal)];
			document.slots.slot1.src = "normal/"+current+".png";
			//Modulus Arithmetic - hvad er tilbage efter 0 / med antal-1	
			slot1_now = current;				
		}
	}else if(hold1 == true){
			counter_a = max_count_a;
	}
	if(hold2== false && counter_b < max_count_b){
		counter_b ++;	
		turns2=antal+Math.floor((Math.random() * antal))
		
		for (b=0; b<turns2; b++)	{
			if(counter_b < max_count_b){
			/* Add  */ // 		
			document.slots.slot2.src="blurred/"+slotitem[b % (antal)]+".png"; 
	
			}
		}
		if(counter_b >= max_count_b){
			current = slotitem[turns2 % (antal)];
			document.slots.slot2.src="normal/"+current+".png"; 
			slot2_now = current;				
		}
		
	}
	else if(hold2 == true){
			counter_b = max_count_b;
	}
	
	if(hold3 == false && counter_c < max_count_c){
		counter_c ++;	
		turns3=antal+Math.floor((Math.random() * antal))
		for (c=0;c<turns3;c++){
			if(counter_c < max_count_c){
			/* Add  */ // 	
			document.slots.slot3.src="blurred/"+slotitem[c % (antal)]+".png"; 
			}
		}
		if(counter_c == max_count_c){
				current = slotitem[turns3 % (antal)];
				//alert(current)
				document.getElementById('spic3').src= "normal/"+current+".png";
				//alert('document.getElementById(slot3)'+document.getElementById('spic3'))
				slot3_now = current;					
		}	
	}
	else if(hold3 == true){
			counter_c = max_count_c;
	}
	
	
	
		if (counter_d <= max_counter_d) {
			spinnertimer = setTimeout("spinem();",120);
	//		setTimeout("spinem(counter(2));",100);
	//		setTimeout("spinem(counter(3));",100);		
			
		} 		
	
	
		
	//	if(counter_d == max_counter_d){
		if(counter_a >= max_count_a && counter_b >= max_count_b && counter_c >= max_count_c){
			//alert(counter_a);
				clearTimeout(spinnertimer);
				normalize();	
				//alert('norm')
				doneswitchback();
				checkmatch();
				
		
		
		}
		counter_d++;	

}



function normalize(){
	// add fruitcount
	savePrefs()	
	fruitcount[slot1_now]++;
	fruitcount[slot2_now]++;
	fruitcount[slot3_now]++;
//	alert(slot3_now)
	// check for strawberries
	
	var totalgold = Math.floor(document.getElementById("total_gold").value); // hidden field					
	
	
	
	if(fruitcount[2] >= 10){
		
			//alert(fruitcount[2]+' of '+slotnames[2]); // show fruits
			fruitcount[2] = 0;
			old_count = fruitcount[2];
			document.getElementById('extra_5_content').innerHTML = '';
			document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_2.png)';
			waittimeronscreen = 2000;			
			showextra(5)
			winning = 1000;
			totalgold += winning;
			document.getElementById("total_gold").value	 =  totalgold;
			setMessage( "You got a STRAWBERRY WIN! <br>You won "+winning+minicurrency[currencyselection]);
			tempgold = totalgold;
			setgold();
			savePrefs()	;
			

	}
	else if(fruitcount[2] < 25 && fruitcount[2] > 0 && old_count != fruitcount[2]){
		old_count = fruitcount[2];
	// show count
		document.getElementById('extra_5_content').innerHTML = '<div class="small_extra">(Extra)</div>'+fruitcount[2]+' x <img src="normal/2.png" />';
		document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
		waittimeronscreen = 500;		
		showextra(5)	
	}
	// fruitcake
	// 2xbanana + 2xwatermelon + 2xapple with a 50%percent chance of getting 1500	
	else if(fruitcount[6] == 2 && fruitcount[4] == 2 && fruitcount[5] == 2 && Math.floor((Math.random() * 2)) == 1){

		fruitcount[2] = 0;
		fruitcount[4] = 0;
		fruitcount[5] = 0;		
	// show count
		waittimeronscreen = 2000;

		document.getElementById('extra_5_content').innerHTML = '<img id="cake" src="images/fruitcake.png" /><div class="small_extra">Fruitcake <br>+1500'+minicurrency[currencyselection]+'</div>';
		document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
		showextra(5)	
		winning = 1500;
		totalgold += winning;
		document.getElementById("total_gold").value	 =  totalgold;
		tempgold = totalgold;
		setgold();
		savePrefs()	;
	}

	
	// alert(fruitcount[slot1_now]+' of '+slotnames[slot1_now]); // show fruits
	
	
	//alert('> normalizet')
	// extra winnings
	else if(Math.floor((Math.random() * 25)) == 1){
				current = slotitem[a % (antal)];
				document.getElementById('extra_5_content').innerHTML = '<div class="small_extra">(Extra win)</div>+50'+minicurrency[currencyselection];				
				document.slots.slot1.src= "normal/"+current+".png";			
				slot1_now = current;
				document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
				waittimeronscreen = 2000;				
				showextra(5)
				//alert('super bonus')
				winning = 50;
				totalgold += winning;
				document.getElementById("total_gold").value	 =  totalgold;
				setMessage( "Can't take it anymore! Here, have "+winning+minicurrency[currencyselection]);
				tempgold = totalgold;
				setgold();
				savePrefs()	;
	}	
	else if(Math.floor((Math.random() * 500)) == 1){
				current = slotitem[a % (antal)];
				document.getElementById('extra_5_content').innerHTML = '';				
				document.slots.slot1.src= "normal/"+current+".png";			
				slot1_now = current;
				document.getElementById('extra_5').style.backgroundImage = 'url(images/ekstra_5.png)';
				waittimeronscreen = 2000;				
				showextra(5)
				//alert('super bonus')
				winning = 25000;
				totalgold += winning;
				document.getElementById("total_gold").value	 =  totalgold;
				setMessage( '<div class="small_extra">(Extra win)</div>You got a SUPER WIN!<br> You won '+winning+minicurrency[currencyselection]);
				tempgold = totalgold;
				setgold();
				savePrefs()	;
	}
	else if(Math.floor((Math.random() * 80)) == 1){
				current = slotitem[a % (antal)];
				document.getElementById('extra_5_content').innerHTML = '<div class="small_extra">(Extra win)</div>+250'+minicurrency[currencyselection];				
				document.slots.slot1.src= "normal/"+current+".png";			
				slot1_now = current;
				document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
				showextra(5)
				//alert('super bonus')
				winning = 250;
				totalgold += winning;
				document.getElementById("total_gold").value	 =  totalgold;
				setMessage( "Fruitfestival "+winning+minicurrency[currencyselection]);
				tempgold = totalgold;
				setgold();
				savePrefs()	;
	}		
	else if(Math.floor((Math.random() * 50)) == 1 && totalgold > Math.floor((10*betvalue)*2)){
				current = slotitem[a % (antal)];
				loss = 10*betvalue;				
				document.getElementById('extra_5_content').innerHTML = '<div class="small_extra">Rotten fruits! <br>-'+loss+minicurrency[currencyselection]+'</div>';				
				document.slots.slot1.src= "normal/"+current+".png";			
				slot1_now = current;
				document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
				waittimeronscreen = 2000;
				showextra(5)
				//alert('super bonus')

				winning = -loss;
				totalgold += winning;
				document.getElementById("total_gold").value	 =  totalgold;
				setMessage( "Can't take it anymore! Here, have "+winning+minicurrency[currencyselection]);
				tempgold = totalgold;
				setgold();
				savePrefs()	;
	}	
	else if(Math.floor((Math.random() * 30)) == 1 && totalgold > 500){
				current = slotitem[a % (antal)];
				document.getElementById('extra_5_content').innerHTML = '<div class="small_extra">Unhappy slotmachine! <br>-250'+minicurrency[currencyselection]+'</div>';				
				document.slots.slot1.src= "normal/"+current+".png";			
				slot1_now = current;
				document.getElementById('extra_5').style.backgroundImage = 'url(images/extra_blank.png)';
				waittimeronscreen = 2000;
				showextra(5)
				//alert('super bonus')

				winning = -250;
				totalgold += winning;
				document.getElementById("total_gold").value	 =  totalgold;
				setMessage( "Can't take it anymore! Here, have "+winning+minicurrency[currencyselection]);
				tempgold = totalgold;
				setgold();
				savePrefs()	;
	}		
				
	
	if(hold1 == true || hold2 == true || hold3 == true || holded == 1){
			holded ++;
			
			//alert ('something on hold')
	}
	//alert(holded)
	if(holded == 2){
		holded = 0;		
	}

	
}


//*********************************************************
/*
Fruits:
0. lemon
1. grapes
2. strawberry
3. cherries
4. banana
5. watermelon
6. apple
7. coconut
8. peach
9. blackberry
10. orange
11. kiwi
12. lime
13. special orange
14. BAR
15. Joker

*/
//*********************************************************
// slot 1, slot 2, slot 3, text, amount, multiplied by bet (0 = steady)
var x = 'any';
var win_array = new Array(
						  [[0,0,x], 	"Two lemons", 			0, 5],
						  [[0,0,0], 	"Three lemons", 		0, 20],						  
						  [[1,1,x], 	"Two grapes", 			0, 5],
						  [[1,1,1], 	"Three grapes", 		0, 20],
						  [[2,2,x], 	"Two strawvberries",	0, 5],
						  [[2,2,2], 	"Three strawberries", 	0, 20],
						  [[3,3,x], 	"Two cherries", 		0, 5],
						  [[3,3,3], 	"Three cherries", 		0, 20],
						  [[4,4,x], 	"Two bananas", 			0, 5],
						  [[4,4,4], 	"Three bananas", 		0, 20],
						  [[5,5,x], 	"Two watermelons", 		0, 5],
						  [[5,5,5], 	"Three watermelons", 	0, 20],
						  [[6,6,x], 	"Two apples", 			0, 5],
						  [[6,6,6], 	"Three apples", 		0, 20],
						  [[7,7,x], 	"Two coconuts", 		0, 5],
						  [[7,7,7], 	"Three coconuts", 		0, 20],
						  [[8,8,x], 	"Two peaches", 			0, 5],
						  [[8,8,8], 	"Three peaches", 		0, 20],
						  [[9,9,x], 	"Two blackberries",		0, 5],
						  [[9,9,9], 	"Three blackberries", 	0, 20],						  
						  [[10,10,x], 	"Two oranges", 			0, 5],
						  [[10,10,10], 	"Three oranges", 		0, 20],						  
						  [[11,11,x], 	"Two kiwis", 			0, 5],
						  [[11,11,11], 	"Three kiwis", 			0, 20],						  
						  [[12,12,x], 	"Two lime", 			0, 5],
						  [[12,12,12], 	"Three lime",			0, 20],						  
						  [[14,14,x], 	"Double bars", 0, 10],						  
						  [[14,14,14], 	"Tripple bars ", 		0, 50],						  
	
						  [[13,0,0], 	"Double up lemons", 	0, 5],
						  [[13,1,1], 	"Double up grapes", 	0, 5],
						  [[13,2,2], 	"Double up strawberries", 	0, 5],
						  [[13,3,3], 	"Double up cherries", 	0, 5],
						  [[13,4,4], 	"Double up bananas", 	0, 5],
						  [[13,5,5], 	"Double up watermelons",0, 5],
						  [[13,6,6], 	"Double up apples", 	0, 5],
						  [[13,7,7], 	"Double up coconuts", 	0, 5],
						  [[13,8,8], 	"Double up peaches", 	0, 5],
						  [[13,9,9], 	"Double up blackberries", 0, 5],
						  [[13,10,10], 	"Double up oranges", 	0, 5],
						  [[13,11,11], 	"Double up kiwis", 		0, 5],
						  [[13,12,12], 	"Double up lime", 		0, 5],
						  [[13,14,14], 	"Double up BARS", 		0, 5],

						  
						  						  
						  
	
						  [[15,x,x], 	"Lucky joker",		0, 2],						  
						  [[x,15,x], 	"Lucky joker",	 	0, 2],						  
						  [[x,x,15], 	"Lucky joker", 		0, 2],						  							  
						  [[15,15,x], 	"Joker mania *blip*", 	0, 20],						  						  
						  [[15,x,15], 	"Joker mania *blip*", 	0, 20],
						  [[x,15,15], 	"Joker mania *blip*", 	0, 20],
						  
						  [[13,13,x], 	"Two Special oranges", 	0, 5],
						  [[13,13,13], 	"Three Special oranges",0, 20],				  						  

						  [[14,1,1], 	"Lucky BAR grapes", 	0, 25],						  	
						  [[14,2,2], 	"Lucky BAR strawberries", 0, 25],						  	
						  [[14,3,3], 	"Lucky BAR cherries", 	0, 25],						  	
						  [[14,4,4], 	"Lucky BAR bananas", 	0, 25],						  	
						  [[14,5,5], 	"Lucky BAR watermelons", 0, 25],						  	
						  [[14,6,6], 	"Lucky BAR apples", 	0, 25],						  	
						  [[14,7,7], 	"Lucky BAR coconuts", 	0, 25],						  							  
						  [[14,8,8], 	"Lucky BAR peaches", 	0, 25],						  	
						  [[14,9,9], 	"Lucky BAR blackberries", 0, 25],						  	
						  [[14,10,10], 	"Lucky BAR oranges", 	0, 25],						  	
						  [[14,11,11], 	"Lucky BAR kiwis", 		0, 25],						  	
						  [[14,12,12], 	"Lucky BAR limes", 		0, 25]						  	

	
							  

						  );



function checkmatch()	{ 
//alert(slotnames[15]);
var totalgold = Math.floor(document.getElementById("total_gold").value)+0; // hidden field

// bar bar bar (14)
//alert('checking match')
//alert('holded is:'+holded)

var all_slots = new Array([slot1_now, slot2_now, slot3_now]);
//alert(all_slots[0])
//
multiplier = 1;
if(slot1_now == 13 || slot2_now == 13 || slot3_now == 13){
	multiplier = 2;
	

}
// check for jokers
if(all_slots[0][0] == 15 || all_slots[0][1] == 15 || all_slots[0][2] == 15){
	// three of a kind
	
	
	// a pair of jokers 
	// x-j-j
	if(all_slots[0][0] == 15 && all_slots[0][1] == 15){
		all_slots[0][0] = all_slots[0][2];
		all_slots[0][1] = all_slots[0][2];			
	}
	// a pair jokers 
	// j-x-j
	else if(all_slots[0][0] == 15 && all_slots[0][2] == 15){
		all_slots[0][0] = all_slots[0][1];
		all_slots[0][2] = all_slots[0][1];					
	}
	// a pair jokers 
	// j-j-x
	else if(all_slots[0][1] == 15 && all_slots[0][2] == 15){
		all_slots[0][1] = all_slots[0][0];
		all_slots[0][2] = all_slots[0][0];					
	}	
	
	
	
	// joker in slot 3 and a pair
	else if(all_slots[0][0] == all_slots[0][1]){
		// slot 3
		all_slots[0][2] = all_slots[0][1];
	}
	// joker in slot 1 and a pair
	else if(all_slots[0][1] == all_slots[0][2] ){
		// slot 1		
		all_slots[0][0] = all_slots[0][2];
	}
	// joker in slot 2 and a pair
	else if(all_slots[0][0] == all_slots[0][2]){
		//slot 2
		all_slots[0][1] = all_slots[0][0];
	}
	
	
	
	// joker in slot 1
	else if(all_slots[0][0] == 15){
		all_slots[0][0] = all_slots[0][1]; 
	}
	// joker in slot 2
	else if(all_slots[0][1] == 15){
		all_slots[0][1] = all_slots[0][0]; 
	}	
	
	
	
}


//alert(win_array[0][0][0]+' / '+all_slots[0])
var count = 0;
var winning = 0;
var selectedwin = 0;
for (fruit in win_array){
//	for(slot=0; slot<2; slot++){
		// third slot
		if(
		   	(win_array[fruit][0][0] == all_slots[0][0] || win_array[fruit][0][0] == x || all_slots[0][0] == 15)  
			&& 
			(win_array[fruit][0][1] == all_slots[0][1] || win_array[fruit][0][1] == x || all_slots[0][1] == 15) 
			&& 
			(win_array[fruit][0][2] == all_slots[0][2] || win_array[fruit][0][2] == x || all_slots[0][2] == 15) 
			){

			
			//alert(win_array[0][0][0]+' / '+all_slots[0][0])
			if(win_array[fruit][3] != 0){
				// bet x multiplier
				winning = betvalue*win_array[fruit][3];
				selectedwin = fruit;
			}else{
				winning = win_array[fruit][2];	
				selectedwin = fruit;
			}
			//alert(winning)
//			alert('Match: '+win_array[fruit][1]+' Slot: '+slot+'  win_array[fruit][slot][0]: '+win_array[fruit][0]+'  all_slots[slot]: '+all_slots[0])	
			}
}
//alert('win: '+winning)
winning *= multiplier;
if(winning != 0){
//	alert('winning: '+win_array[selectedwin]);
//	alert('winning: '+winning);
	holded = 1;

	totalgold += winning;	
	tempgold = totalgold;	
	setgold();
	savePrefs()	;
	// reset message
	//top_mover = true;
	clearTimeout(movetimer);
	document.getElementById("plus").style.display = 'none';
	movemessagedown();
	var imagestring = '<img src="mini/'+win_array[selectedwin][0][0]+'.png" alt="Mini"><img src="mini/'+win_array[selectedwin][0][1]+'.png" alt="Mini"><img src="mini/'+win_array[selectedwin][0][2]+'.png" alt="Mini">';
	if(multiplier > 1){
		// images

		setMessage(win_array[selectedwin][1]+imagestring+'<br>You won '+(winning/2)+minicurrency[currencyselection]+' x '+multiplier);		
	}else{
		setMessage(win_array[selectedwin][1]+imagestring+'<br>You won '+winning+minicurrency[currencyselection]);
	}
}else{
	
	holders = 0;
	if(personality == false){
		setMessage("You lost "+betvalue+minicurrency[currencyselection]);						
	}else{
		setMessage(nomatchtext[Math.floor((Math.random() * nomatchtext.length))]+" You lost "+betvalue+minicurrency[currencyselection]);			
	}	
	savePrefs();
}




// check match
// set message
// settemp gold
// set holded
// set gold

//winning = betvalue*20;
//totalgold += winning*multiplier;
//document.getElementById("total_gold").value	 =  totalgold;
//tempgold = totalgold;
//holded = 1;

resetHolders();
hold1 = false;
hold2 = false;
hold3 = false;		
//holders = 0;
rolling = false;
//alert('Checking match');

}


function resetHolders(){

	if(holded == 0){
		document.getElementById('holda').style.backgroundImage = "url('images/noholdglow.png')";
		document.getElementById('holdb').style.backgroundImage = "url('images/noholdglow.png')";
		document.getElementById('holdc').style.backgroundImage = "url('images/noholdglow.png')";	
	}
	if(holded == 1){
		//alert('holded is 1')
		// de er holdte - gør dem disabled

		document.getElementById('holda').style.backgroundImage = "url('images/nohold_disabled.png')";			
		document.getElementById('holdb').style.backgroundImage = "url('images/nohold_disabled.png')";
		document.getElementById('holdc').style.backgroundImage = "url('images/nohold_disabled.png')";
	}	
}

function getCredits(){
	if(window.widget){
		widget.openURL('http://blog.kevinandersson.dk');
	totalvisits++;
	}

	if(tempgold < minimumtohave){
		totalgold = tempgold+addgold; // hidden field
	
		//document.getElementById("gold_score").innerHTML = totalgold;
		//document.getElementById("gold_score").innerHTML = totalgold;
		document.getElementById("total_gold").value	 =  totalgold;
		tempgold = totalgold;
		setgold();
	}
	
	//alert('totalvisits: '+totalvisits);
}



function hold(holdclip){
//	alert(holdclip);
//	alert('hold: '+holded);
//	alert('holders: '+holders)
//	alert(document.getElementById('holdb').style.backgroundImage)						
//	alert(document.getElementById('holdb'))						
//	alert(document.getElementById('holdc'))									
	if(rolling == false){
	if(holded == 0 || holded >= 2){
		holded = 0;
		if(holdclip == 1){
			
			if(hold1 == false){
				if(holders <= 1){
					holders++;
					hold1 = true;

					document.getElementById('holda').style.backgroundImage = 'none';
				}else{
					setMessage('You can only hold 2 at the same time');
				
				}
			}else{
				holders--;				
				hold1 = false;
				document.getElementById('holda').style.backgroundImage = 'url(images/noholdglow.png)';
			}
		}
		if(holdclip == 2){
			if(hold2 == false){
				if(holders <= 1){
					holders++;				
					hold2 = true;
					document.getElementById('holdb').style.backgroundImage = 'none';			
				}else{
					setMessage('You can only hold 2 at the same time');
				
				}
			}else{
				holders--;				
				hold2 = false;
				document.getElementById('holdb').style.backgroundImage = 'url(images/noholdglow.png)';
			}
		}
		if(holdclip == 3){
			if(hold3 == false){
				if(holders <= 1){
					holders++;						
					hold3 = true;
					document.getElementById('holdc').style.backgroundImage = 'none';
				}else{
					setMessage('You can only hold 2 at the same time');
				
				}				
			}else{
				holders--;				
				hold3 = false;
				document.getElementById('holdc').style.backgroundImage = 'url(images/noholdglow.png)';
			}
		}	
	}else{
//		alert('not possible, you need to take a spin first')	
		setMessage( "It's not possible to hold, you need to take a spin first.");
	}
}else{
	setMessage( "No hold while spinning my friend...");
}
	
}

function setgold(){
		
		if(parseFloat(document.getElementById("gold_score").innerHTML) > tempgold){
			// træk fra score
			difference = parseFloat(document.getElementById("gold_score").innerHTML) - tempgold;
			if(difference <= 50 ){
			checker = 5;
			}
			else if(difference < 100 && difference > 50){
				checker = 10;
			}
			else if(difference > 100 && difference < 1000){
				checker = 100;
			}else if(difference > 1000 && difference < 5000){
				checker = 200;				
			}else if(difference >= 5000 && difference < 10000){
				checker = 1000;	
			}
			else if (difference >= 10000 && difference < 100000){
				checker = 10000;
			}else if(difference > 100000 && difference < 1000000){
				checker = 100000;
			}else if(difference >= 1000000){
				checker = difference-500;
			}
			
			document.getElementById("gold_score").innerHTML = parseFloat(document.getElementById("gold_score").innerHTML)-checker;	
		}else{
			// læg til score
			// tempgold størst - vundet
			difference = tempgold-parseFloat(document.getElementById("gold_score").innerHTML) ;
			if(difference >= 1000000){
				checker = difference-500;
			}
			else if(difference > 100000 && difference < 1000000){
				checker = 100000;
			}
			if(difference  >= 10000 && difference  < 100000){
				checker = 10000;	
			}
			else if(difference  >= 5000 && difference  < 10000){
				checker = 1000;	
			} else if(difference  > 1000 && difference  < 5000){
				checker = 500;	
			}
			else if(difference  <= 1000 && difference > 100){
				checker = 100;	
				//alert('difference  <= 1000 && difference > 100')
			}
			else if(difference < 100 && difference > 50){
				checker = 10;
				
						
			}else{
				checker	= difference;
			}			
			document.getElementById("gold_score").innerHTML = parseFloat(document.getElementById("gold_score").innerHTML)+checker;
		}
		if(parseFloat(document.getElementById("gold_score").innerHTML) != tempgold){
			clearTimeout(timer);
			timer = setTimeout("setgold()",25);	
			//alert(amount)
		}
		// set the gold for later
		//document.getElementById("gold_score").innerHTML = tempgold;
		document.getElementById("total_gold").value	= tempgold;
		
		displayFact();

		
}


function stopplay () {

if (document.getElementById("gold_score").innerHTML < startgold) 

	{alert("You lost "+ (startgold-document.getElementById("gold_score").innerHTML) +minicurrency[currencyselection]);}

else 	{alert("You gained "+ (document.getElementById("gold_score").innerHTML-startgold) +minicurrency[currencyselection]);}

}
top_mover = false;
function setMessage(message){
//		document.getElementById("information").innerHTML = message;
		//alert(message.length)
		if(message.length > 50){
			top_mover = true;
			// show +
	
		}else{
			top_mover = false;	
		}
		mainmessage = message;
		alphavalue = 100;
		fontsizes = 90;
		init();
}

var hit = Array(false, false, false);
function displayFact(){
//	showInformation("<br>display fact..."+tempgold,true, 1, true); // text, fade in, extraicon, closebutton		

	if(tempgold >= 1500 && hit[0] == false){	
		hit[0] = true;
		showInformation("<br>You've made it over the first 1.500. You can now submit your score...",true, 1, true); // text, fade in, extraicon, closebutton		
	}
	/*
	if(tempgold >= 5000 && hit[1] == false){	
		hit[1] = true;
		showInformation("<br>You've made it over the first 5.000. Comon' submit your score...",true, 1, true); // text, fade in, extraicon, closebutton		
	}	
	if(tempgold >= 15000 && hit[2] == false){	
		hit[2] = true;
		showInformation("<br>15.000 is a lot! Remember to submit your score...",true, 1, true); // text, fade in, extraicon, closebutton		
	}
	*/
	
	if(hit[0] == false && tempgold <= 1500){
		hit[0] = true;
	}
}