// JavaScript Document
function clearAnswers(obj) {
	document.getElementById('answer_choice_1').checked = false;
	document.getElementById('answer_choice_2').checked = false;
	document.getElementById('answer_choice_3').checked = false;
	obj.checked = true;
}

//func to check that at least one is checked
function verifyOneChecked() {
	var checkBox1 = document.getElementById("answer_hidden_choice_1").value;
	var checkBox2 = document.getElementById("answer_hidden_choice_2").value;
	var checkBox3 = document.getElementById("answer_hidden_choice_3").value;
	if(checkBox1 == "0" && checkBox2 == "0" && checkBox3 == "0") {
		alert("Please select an answer to submit the trivia.");
		return false;
	}
	return true;
}

//func to show lightbox
function showPopupLightbox(img_id) {
	//do jquery ajax call
	Modalbox.show("http://www.heisman.com/index.php/welcome/grabImage/" + img_id, {title: 'Heisman Photo Gallery', width: 600});
}

//func to swap out checkbox images and innote correct value
function checkboxTrivia(checkbox_id, disabledThird) {
	
	if(disabledThird == true) {
		var stringVal = "true"	
	}
	else {
		var stringVal = "false";	
	}
	
	document.getElementById('checkbox_result_1').innerHTML = "<a onclick=\"checkboxTrivia(1, " + stringVal + ")\" style=\"cursor: pointer;\"><img src=\"images/trivia_checkbox.gif\" alt=\"\" /></a>";
	document.getElementById('checkbox_result_2').innerHTML = "<a onclick=\"checkboxTrivia(2, " + stringVal + ")\" style=\"cursor: pointer;\"><img src=\"images/trivia_checkbox.gif\" alt=\"\" /></a>";
	if(!disabledThird) {
	document.getElementById('checkbox_result_3').innerHTML = "<a onclick=\"checkboxTrivia(3, " + stringVal + ")\" style=\"cursor: pointer;\"><img src=\"images/trivia_checkbox.gif\" alt=\"\" /></a>";
	}
	if(disabledThird) {
		var stopper = 3;	
	}
	else {
		var stopper = 2;	
	}
	for (var i = 1; i <= stopper; i++ ) {
		if(i != checkbox_id) {
			document.getElementById("answer_hidden_choice_" + i).value = "0";	
		}
	}
	
	//Get current value of checkbox hidden
	var divBox = "checkbox_result_" + checkbox_id;
	var checkBox = "answer_hidden_choice_" + checkbox_id;
	if(document.getElementById(checkBox).value == "0") {
		document.getElementById(checkBox).value = "1";	
		document.getElementById(divBox).innerHTML = "<a onclick=\"checkboxTrivia(" + checkbox_id + ", " + stringVal + ")\" style=\"cursor: pointer;\"><img src=\"images/trivia_not_checked.gif\" alt=\"\" /></a>";
	}
	else if(document.getElementById(checkBox).value == "1") {
		document.getElementById(checkBox).value = "0";	
		document.getElementById(divBox).innerHTML = "<a onclick=\"checkboxTrivia(" + checkbox_id + ", " + stringVal + ")\" style=\"cursor: pointer;\"><img src=\"images/trivia_checkbox.gif\" alt=\"\" /></a>";
	}
}