var timer;

function startClock() {
	updateClock();
	timer = new PeriodicalExecuter(updateClock,1);
}

function updateClock() {
	cdt--;

	var tmin = Math.floor(cdt/60);
	var tsec = cdt % 60;

	if (tmin < 10)
		tmin = "0"+tmin;

	if (tsec < 10)
		tsec = "0"+tsec;

	document.getElementById('quiz_clock').innerHTML = tmin+":"+tsec;

	if (cdt == 60)
	{
		Effect.Shake("quiz_clock",{duration:0.5});
	}

	if (cdt == 12)
	{
		Effect.Pulsate("quiz_clock",{duration:2.0});
	}

	if (cdt <= 0)
	{
		timer.stop();
		Effect.DropOut("quiz_clock",{duration:1.0});
		$('qsubmit').value = "2";
		$('quiz_qa').submit();
	}
}

function check_answers()
{
	if($('qsubmit').value != 2)
	{
		var elements = new Array();

		var e_list = $('quiz_qa').getInputs('radio');
		for(var i = 0; i < e_list.length; i++)
		{
			elements[i] = e_list[i].name;
		}
		elements = elements.uniq();

		var answers = $$('input:checked[type="radio"]');
		if(answers.length != elements.length)
		{
			return confirm("You haven't answered all the questions on this page! Hit OK to skip these questions or Cancel to try again.");
		}
	}

	return true;
}


