var currVideo = null;
function showVideo(newVideo) {
	// if currVideo is null this is our first time in
	if(currVideo == null)
	currVideo = 'vid1';

	// if currVideo and newVideo are different then hid the current video
	if(currVideo != newVideo)
	{
	var objCurrVideo = document.getElementById(currVideo);
	objCurrVideo.stop();
	objCurrVideo.style.display = "none";
	}

	// remember out new video
	currVideo = newVideo;

	// play the new video
	var objNewVideo = document.getElementById(newVideo);
	objNewVideo.play();

	// show the new video
	objNewVideo.style.display = "block";
}

function competition_questions() {
	var totalquestions = parseFloat(document.getElementById("totalquestions").value);
	var correct_response = document.getElementById("correct");
	var incorrect_response = document.getElementById("incorrect");
	var tcs = document.getElementById("termsconditions");
	var z = "";
	var swt = 0;
	var a = 0;
	var correctanswer = "";
	var b = 0;
	
	// hide responses
	correct_response.className = "response hs";
	incorrect_response.className = "response hs";

	// ensure that at least one radio button checked per question
	for (var i = 1; i <= totalquestions; i++) {
		z = document.getElementsByName("questions" + i);	
		
		for (var y = 0; y < z.length; y++) {
			if (z[y].checked == true) {
				
				swt++;
			}
			if (swt > 0) {
				swt = 0;
				a++;
			}
		}
	}
	if (a != totalquestions) {
		alert("You must answer all questions");
	} else {
		swt = 0;
		// check to make sure that terms and conditions are read
		if (tcs.checked == true) {
			for (var i = 1; i <= totalquestions; i++) {
				correctanswer = String(document.getElementById("answer" + i).value);
				z = document.getElementsByName("questions" + i);
				//alert(i + " Total answers: " + z.length);
				for (var y = 0; y < z.length; y++) {
					if (z[y].checked == true) {
						if (z[y].value == correctanswer) {
							swt++;
						}
					}
					if (swt > 0) {
						swt = 0;
						b++;
					}
				}
			}
			if (b != totalquestions) {
				incorrect_response.className = "response sh";
				correct_response.className = "response hs";
			} else {
				correct_response.className = "response sh";
				incorrect_response.className = "response hs";
			}
		} else {
			alert("You must read the Terms and Conditions");
		}
	}
}