// assesment.js (requires Prototype)

var questions = $$('.question');
questions.each(function(question, i) {
	// Hide the divs
	if(i>0){question.hide()}
	if(i<questions.size()-1){ // for all but the last question
		// Add the submit buttons
		var box = question.select('.boxBR')[0].insert('<a onclick="return false;" href="#" style="display:block; margin-top:25px;"><img src="/images/buttons/next.gif" alt="next" name="next001" width="71" height="47" border="0" id="next001" onMouseOver="MM_swapImage(\'next001\',\'\',\'../../images/buttons/next-over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a>');
		box.select('a')[0].observe('click', function(){
			// check if a choice was selected
			if(this.up('.boxBR').select(':checked').any()){
				// go to the next question
				var thisQuestion = this.up('.question');
				var nextQuestion = thisQuestion.next('.question');
				thisQuestion.hide();
				nextQuestion.show();
			} else{
				// display an error
				box.insert('<p style="color:red">Please select an answer</p>');
			}
		});
	} else {
		// This is where script for the last question goes
	}
});


