//smartsite site root: equivalent to ~/
var siteroot = (typeof(fullsiteroot) == "function") && (typeof(sitehost) == "function") ? fullsiteroot().replace(sitehost(), "") : "/";
//@cc_on try {document.execCommand("BackgroundImageCache", false, true);} catch (e) {}

var clickedItems = [];
var numClickedItems = 0;
var isSliderClicked = 'no';

function clicked(aInt) {
    if (clickedItems[aInt] === undefined) {
        if (aInt === 10 || aInt === 11 || aInt === 12) {
            clickedItems[aInt] = 1;
            if (isSliderClicked === 'no') {
                numClickedItems = numClickedItems + 1;
                isSliderClicked = 'yes';
            }
        } else {
            clickedItems[aInt] = 1;
            numClickedItems = numClickedItems + 1;
        }
        if (numClickedItems == 10) {
            document.getElementById('cornerBox').style.display = 'block';
        }
    }
}

function resetRadioButtons(){
	//Reset radio buttons
	var e=document.getElementsByTagName('input');
	var i=0;
	while(i!=e.length){
		if(e[i].type=='radio'){
			e[i].checked=false;
			i++;
		}
	}
}

function rollOver(which){ 
	which.src = which.src.replace("_of","_ov"); 
}

function rollOut(which){ 
	which.src = which.src.replace("_ov","_of"); 
}
function rollOverId(aId){
	which = document.getElementById(aId);
	which.src = which.src.replace("_of","_ov"); 
}

function rollOutId(aId){
	which = document.getElementById(aId);
	which.src = which.src.replace("_ov","_of"); 
}

function show(aId){
	document.getElementById(aId).style.display='block';
	document.getElementById('fact').style.height='0';
	document.getElementById('fact').style.height='auto';
}
function show_home(aId){
	document.getElementById(aId).style.display='block';
	document.getElementById('content').style.height='0';
	document.getElementById('content').style.height='auto';
}
function hide(aId){
	document.getElementById(aId).style.display='none';
}

function select_thorn(aThornId, aFlowerId){
	document.getElementById(aThornId).src = "/local/images/question_thorn_on.png";
	document.getElementById(aFlowerId).src = "/local/images/question_flower_of.png";
}
function select_flower(aFlowerId, aThornId){
	document.getElementById(aFlowerId).src = "/local/images/question_flower_on.png";
	document.getElementById(aThornId).src = "/local/images/question_thorn_of.png";
}
function random_quiz(){
	var randomnumber=Math.floor(Math.random()*5) + 1;
	if (document.getElementById('question'+randomnumber)) {
		document.getElementById('question'+randomnumber).style.display='block';
	}
}

function setValueJS(aParam) {
	param = aParam.substring(1,aParam.length-1);
	var splittedArray = param.split(",");
	if(splittedArray[0] == 1){
		document.getElementById('painscale').src = "/local/images/print/img_pain_"+currentLanguage+"_"+splittedArray[1]+".gif";
		clicked(10);
	}
	if(splittedArray[0] == 2){
		document.getElementById('sleepscale').src = "/local/images/print/img_sleep_"+currentLanguage+"_"+splittedArray[1]+".gif";
		clicked(11);
	}
	if(splittedArray[0] == 3){
		document.getElementById('activityscale').src = "/local/images/print/img_activity_"+currentLanguage+"_"+splittedArray[1]+".gif";
		clicked(12);
	}
}