// Interaction controls
function openLink(){
	if(window.widget && todays_link != '' && todays_link != undefined && today_opened == false){
		widget.openURL(todays_link);
		totalvisits++;
		//today_opened = true;
	}
}




function doneswitchback(){
	document.getElementById('donebtn').style.backgroundImage = 'none';
	tempgold -= Math.floor(betvalue);
	setgold();	
//	clearTimeout(switchani);
	
}
function checkVersionBtn(){
	getXMLdata();
	document.getElementById('check_version').style.backgroundImage = 'url(images/update_down.png)';	
	switchani = setTimeout("checkVersionBack()",350);	
}
function checkVersionBack(){
	document.getElementById('check_version').style.backgroundImage = 'none';	
}

function personalitySwitch(){
	if(personality == true){
		personality = false;
		document.getElementById('personalityswitch').style.backgroundImage = 'url(images/switch_up.png)';	
	}else{
		personality = true;		
		document.getElementById('personalityswitch').style.backgroundImage = 'none';			
	}
	savePrefs();
}

function resswitchback(){
	document.getElementById('resetprefs').style.backgroundImage = 'none';
	clearTimeout(switchani);
	
}

function submitHighscoreCheck(){
//	alert('submitting highscores');
	if(useridentify != 0){
	typer = true;
	showInformation('<span class="small">Are you sure you want to submit the highscore? The points you submit will be removed from your score.<br/><input id="score_typer" name="submit" type="text" value="'+tempgold+'" onKeyUp="checkMaxscore();" size="12"><div class="centered"><a href="#" onclick="hideInformation();"><img src="images/no.png" alt="Done"></a><a href="#" onclick="submitHighscore();"><img src="images/yes.png" alt="Done"></a></div></span>',true, 1, false); // text, fade in, extraicon, closebutton
	}else{
		;
		showInformation('<span><br />You need to login to submit your highscore. Press <img src="images/usericon.png" alt="Done"> to login to the Fruitz server. </span>',true, 1, false); // text, fade in, extraicon, 
	}			
}

function showUserLogin(){
	if(useridentify == 0){
	typer = true;
	
	showInformation('<span class="small">Username:<br/><input id="user_name" name="user_name" type="text" value=""  size="12"><br/>Password:<br/><input id="password_inp" name="password_inp" type="password" value=""  size="12"><a href="#" onclick="userLogin();"><img src="images/login.png" alt="Login"></a><div id="fejl" class="small"></div><div class="centered"> <a href="" onclick="fruitzCreateUser();" >Create new user</a>.</div></span>',true, 1, false,true); // text, fade in, extraicon, closebutton	
	}else{
	showInformation('<br/><span>You are logged in.<br/><a href="#" onclick="logOut();"> Log out...</a></span>',true, 1, false); // text, fade in, extraicon, closebutton		
	}
}

function showBetting(){
		typer = true;
	showInformation('<span class="small">What is your bet? <br/><input id="score_typer" name="submit" type="text" value="'+document.getElementById("betbox").innerHTML+'" onKeyUp="checkMaxscore();" size="12"><br/><br/><a href="#" onclick="setValueBet();"><img src="images/done.png" alt="Done"></a></span>',true, 1, false); // text, fade in, extraicon, closebutton
	
}

function setValueBet(){
	betting = parseInt(document.getElementById('score_typer').value);
	//alert(betting)
	setBet(betting, true);
	hideInformation();
}


function logOut(){
	useridentify = 0;
	document.getElementById('submithigh').style.backgroundImage = 'url(images/submit_grey.png)';
	showInformation('<br/><span>You are now logged out.</span>',true, 1, false);	
}

function fruitzHome(){
	widget.openURL('http://fruitz.kevinandersson.dk');
}

function fruitzCreateUser(){
	//widget.openURL('http://fruitz.kevinandersson.dk/registration/register/');
	window.open('http://fruitz.kevinandersson.dk/registration/register/');

}

function showResetScore(){
//	alert('submitting highscores');

	showInformation('<span class="small">Are you sure you want to reset your score? Your points will be reset to 250 '+minicurrency[currencyselection]+'<br/><a href="#" onclick="hideInformation();"><div class="centered"><img src="images/no.png" alt="Done"></a><a href="#" onclick="resetScore();"><img src="images/yes.png" alt="Done"></a></div></span>',true, 1, false); // text, fade in, extraicon, closebutton			
}