// Javascript for interactive



function startquiz()
{
	setCookie('right', '');
	
}

function results()
{

var res = getCookie('right');

if (res == 0) {
document.write("There are no results stored for your quiz. Please click the button below to start the quiz.");
return;
}

var i;
var ans = res.split(",");
var q;
var a;
var c;
var b = new Array();
var count=0;

for (i = 0; i< ans.length; i++)
{
	q=ans[i];
	c=q.split("=");

	if (b[c[0]] == undefined && c[1] != undefined)
	{
			b[c[0]] = c[1];
			if (c[1] == 1)
			{
				count++;
			}			
	}
}
if (count >= 9)
{
	document.write("Well done, you've scored " + count + " out of 10. Are all your colleagues as well informed? Could they benefit from our training?");
}
else if (count >= 7)
{
	document.write("Not bad, you've scored  " + count + " out of 10. Perhaps you could benefit from some training? And what about your colleagues, are they as well informed?");
}
else if (count >= 4)
{
	document.write("You scored  " + count + " out of 10, a little rusty perhaps? No problem, we can train you and your colleagues to be safe with gases.");
}
else
{
	document.write("You scored " + count + " out of 10, never mind. Perhaps you're new to gases or have never had the proper training? We can help.");
}
}

function check(qno, correct) 
{

var right = getCookie('right');
var ans = 0;

if (self.formchoices.q[0].checked) {ans=1;}
if (self.formchoices.q[1].checked) {ans=2;}
if (self.formchoices.q[2].checked) {ans=3;}
if (self.formchoices.q[3].checked) {ans=4;}
if (self.formchoices.q[4].checked) {ans=5;}

<!-- check an answer has been provided -->
if (ans==0) {
MM_showHideLayers('error','','show');
return(0);
}
else
{
	MM_showHideLayers('error','','hide'); <!-- hide error message -->
	if (ans == correct)
	{
		MM_showHideLayers('correct','','show','answer-info','','show','question-info','','hide','button-q','','hide','button-a','','show'); 
		right = right + qno + '=1,';
		setCookie('right', right);
	}
	else
	{
		MM_showHideLayers('incorrect','','show','answer-info','','show','question-info','','hide','button-q','','hide','button-a','','show');
		right = right + qno + '=0,';
		setCookie('right', right);
	}
	return(1);
}

}