//JavaScript Document

$(document).ready(function(){
	$('.questions0 input[value = true]').click(function(){
		$(this).attr('checked','checked');
		$('.questions0 input[value = false]').removeAttr('checked');
	});
	$('.questions0 input[value = false]').click(function(){
		$(this).attr('checked','checked');
		$('.questions0 input[value = true]').removeAttr('checked');
	});

	$('.questions2 input[value = true]').click(function(){
		$(this).attr('checked','checked');
		$('.questions2 input[value = false]').removeAttr('checked');
	});
	$('.questions2 input[value = false]').click(function(){
		$(this).attr('checked','checked');
		$('.questions2 input[value = true]').removeAttr('checked');
	});

	$('.questions3 input[value = true]').click(function(){
		$(this).attr('checked','checked');
		$('.questions3 input[value = false]').removeAttr('checked');
	});
	$('.questions3 input[value = false]').click(function(){
		$(this).attr('checked','checked');
		$('.questions3 input[value = true]').removeAttr('checked');
	});

	$('.questions4 input[value = true]').click(function(){
		$(this).attr('checked','checked');
		$('.questions4 input[value = false]').removeAttr('checked');
	});
	$('.questions4 input[value = false]').click(function(){
		$(this).attr('checked','checked');
		$('.questions4 input[value = true]').removeAttr('checked');
	});

	$('.questions5 input[value = true]').click(function(){
		$(this).attr('checked','checked');
		$('.questions5 input[value = false]').removeAttr('checked');
	});
	$('.questions5 input[value = false]').click(function(){
		$(this).attr('checked','checked');
		$('.questions5 input[value = true]').removeAttr('checked');
	});

	$('.quizsubmit').click(function(){
		correct = $('.correct');
		$.each(correct,function(){
			obj = $(this);
			if(obj.attr('checked') == 'checked'){
				if(obj.attr('value') == 'true'){obj.parent().html('Right! The correct answer is true:');}
				if(obj.attr('value') == 'false'){obj.parent().html('Right! The correct answer is false:');}
			}else{
				if(obj.attr('value') == 'true'){obj.parent().html('Wrong! The correct answer is true:');}
				if(obj.attr('value') == 'false'){obj.parent().html('Wrong! The correct answer is false:');}
			}
		});
		noofcorrect = $('.correct').length;
		noofquestions = $('.questions').length;
		$('.correctcount').html('TOTAL CORRECT = '+noofcorrect+' out of '+noofquestions);
		return false;
	});

	$('.clearanswer').click(function(){
		$('.questions input').removeAttr("checked", "checked");
	});
});
