try {MILKMOUSTACHE;} catch (e) {MILKMOUSTACHE = {};}

MILKMOUSTACHE.quiz = {
	UNCHOSEN_ANSWER_IMAGE: '/media/img/-inactive.png',
	CHOSEN_ANSWER_IMAGE: '/media/img/active.png',

	init: function() {
		$('input[name=answer]').hide();
		$('div.answerBtn img').click(
			function() {
				MILKMOUSTACHE.quiz.answerSelected($(this));
			}
		);
		MILKMOUSTACHE.quiz.sameHeightAnswers();
	},

	answerSelected: function(imgClicked) {
		$('input', imgClicked.parent().prev()).attr('checked', true);
		$('div.answerBtn img').attr('src',
			MILKMOUSTACHE.quiz.UNCHOSEN_ANSWER_IMAGE);
		imgClicked.attr('src', MILKMOUSTACHE.quiz.CHOSEN_ANSWER_IMAGE);
	},

	sameHeightAnswers: function() {
		var maxHeight = 0;
		$('div.answer').each(
			function() {
				var thisHeight = $(this).height();
				maxHeight < thisHeight ? (maxHeight = thisHeight): null;
			}
		).height(maxHeight);
	}
}

$(MILKMOUSTACHE.quiz.init);
