/**
 * @author neil.mckenzie
 */

var aQuestionAnswers = new Array([0,1], [0,1,2], [1], [1], [4]); // Correct Answers

var aWrongAnswers = new Array(false, false, false, false, false); // Wrong Answers

function areYouRight(nQuestion, nAnswer, oRadio){
	
	var aAnswersIndex = aQuestionAnswers[nQuestion];
	var nAnswerCount = aAnswersIndex.length;
	var bIsCorrect = false;
	for(var i = 0; i < nAnswerCount; i++){
		if(nAnswer == aAnswersIndex[i]){
			bIsCorrect = true;
			break;
		}
	}
	// if aQuestionAnswers is not equal too nAnswer	
	if (!bIsCorrect) {
		document.getElementById("overLayWrong").style.visibility = "visible";
		document.getElementById("overLayWrong").style.width = pageWidth() + "px";
		document.getElementById("overLayWrong").style.height = pageHeight() + "px"; 
		aWrongAnswers[nQuestion] = false;
		oRadio.checked = false;
	} else {
		aWrongAnswers[nQuestion] = true;
	}
	
}

function youAreCorrect()
{
	var n = 0;
	var nQuestionCount = aWrongAnswers.length;
	for( var i=0; i < nQuestionCount; i++) {
		if(aWrongAnswers[i]){
			n++;
		}
		
	}
	
	if(n == nQuestionCount){
		//yes!
document.getElementById("overLayRight").style.visibility = "visible";
document.getElementById("overLayRight").style.width = pageWidth() + "px";
document.getElementById("overLayRight").style.height = pageHeight() + "px";
		} else{
document.getElementById("overLayComplete").style.visibility = "visible";
document.getElementById("overLayComplete").style.width = pageWidth() + "px";
document.getElementById("overLayComplete").style.height = pageHeight() + "px";

	}
	
}

function cont()
{
document.getElementById("overLayComplete").style.visibility = "hidden";
document.getElementById("overLayWrong").style.visibility = "hidden";
}

// Reset form

function formReset()
{
document.getElementById("overLayWrong").style.visibility = "hidden";
document.getElementById("myForm").reset();
//document.getElementById("overLayComplete").style.visibility = "hidden";
}

function pageWidth(){
return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight(){
return  window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}

