var my_path = "./";
var myrules = {
	'.inline_quiz .wrong' : function(el){
		el.onclick = function(){
			image = el.getElementsByTagName('img')[0];
			image.src = my_path + 'x.gif';
			el.style.color = '#B30000';
		}
	},
	'.inline_quiz .right' : function(el){
		el.onclick = function(){
			image = el.getElementsByTagName('img')[0];
			image.src = my_path+'check.gif';
			el.style.color = '#007700';
			el.style.fontWeight = 'bold';
		}
	}
};

Behaviour.addLoadEvent(function() {
	//<![CDATA[
	// loading the stylesheet into the document header
	if(document.createStyleSheet) { // non-standard IE way of doing it
		document.createStyleSheet('styles_inline_quiz.css');
	} else { // do it the W3C DOM way
		var newCSS=document.createElement('link');
		newCSS.rel='stylesheet';
		newCSS.href=my_path+'styles_inline_quiz.css';
		newCSS.type='text/css';
		document.getElementsByTagName("head")[0].appendChild(newCSS);
	}
	//]]>
	answers = document.getElementsBySelector('.inline_quiz div');
	for (i = 0; i < answers.length ; i++) {
		answer = answers[i];
		var image = document.createElement('img');
		image.setAttribute("src",my_path+"box.gif");
		image.className = 'ilq_box';
		answer.insertBefore(image, answer.firstChild);
		answer.className = 'ilq_answer';
	}
	one_rights = document.getElementsBySelector('.inline_quiz_all div');
	for (i = 0; i < one_rights.length ; i++) {
		response = one_rights[i];
		var box = document.createElement('img');
		box.setAttribute("src",my_path+"box.gif");
		box.className = 'ilq_box';
		response.insertBefore(box, response.firstChild);
	}
	// Get the right responses for the "one correct" questions into an array
	var responses_right = document.getElementsBySelector('.inline_quiz_all .right');
	for (i = 0; i < responses_right.length ; i++) {
		cur_response = responses_right[i];
		cur_response.onclick = function(){
			me = this;
			var cur_question = me.parentNode; // select the question
			var the_responses = cur_question.getElementsByTagName('div'); // select all of the divs in the question
			for (k = 0; k < the_responses.length ; k++) {
				this_response = the_responses[k];
				cur_image = this_response.getElementsByTagName('img')[0];
				if(this_response.className=='right') {
					cur_image.src = my_path+'check.gif';
					this_response.style.color = '#2EB231';
					this_response.style.fontWeight = 'bold';
				} 
				else if(this_response.className=='wrong') {
					cur_image.src = my_path+'x.gif';
					this_response.style.color = '#ff0000';
				}
				else {
					// don't add onclick functionality to divs that are part of the question
				}
			}
		}
	}
	// Get the right responses for the "incorrect" questions into an array
	var responses_wrong = document.getElementsBySelector('.inline_quiz_all .wrong');
	for (i = 0; i < responses_wrong.length ; i++) {
		cur_response_wrong = responses_wrong[i];
		cur_response_wrong.onclick = function(){
			me = this;
			var cur_question = me.parentNode; // select the question
			var the_responses = cur_question.getElementsByTagName('div'); // select all of the divs in the question
			for (k = 0; k < the_responses.length ; k++) {
				this_response = the_responses[k];
				cur_image = this_response.getElementsByTagName('img')[0];
				if(this_response.className=='right') {
					cur_image.src = my_path+'check.gif';
					this_response.style.color = '#2EB231';
					this_response.style.fontWeight = 'bold';
				} 
				else if(this_response.className=='wrong') {
					cur_image.src = my_path+'x.gif';
					this_response.style.color = '#ff0000';
				}
				else {
					// don't add onclick functionality to divs that are part of the question
				}
			}
		}
	}
})

Behaviour.register(myrules);