// JavaScript Document

function verify_vote(form,name,email,province,postalcode,num) {
	jk_vote_online_10er_name = document.getElementById(name);
	jk_vote_online_10er_email = document.getElementById(email);
	jk_vote_online_10er_province = document.getElementById(province);
	jk_vote_online_10er_postalcode = document.getElementById(postalcode);
	
	if (
		(jk_vote_online_10er_name.value !== "") && (jk_vote_online_10er_name.value !== null) &&
		(jk_vote_online_10er_email.value !== "") && (jk_vote_online_10er_email.value !== null) &&
		(jk_vote_online_10er_province.value !== "") && (jk_vote_online_10er_province.value !== null) &&
		(jk_vote_online_10er_postalcode.value !== "") && (jk_vote_online_10er_postalcode.value !== null)
		
		)  {
		var validated = false
		x = document.forms[form].response.length;
		for (i = x - 1; i > -1; i--) {
			c = document.forms[form].response[i];
			if (c.checked) {
				validated = true;
			}
		}
		if (validated) {
			return true;
		}
		else {
			response_msg = "#jk-online-all-survey-select-response_" + num;
			$(response_msg).fadeIn("slow");
			return false;
		}
		return false;
	}
	else {
		signedup_msg = "#jk-online-all-survey-signed-up_" + num;
		$(signedup_msg).fadeIn("slow");
		return false;		
	}
}
	
$(document).ready(function(){
	$("#jk-online-all-survey-success").fadeIn("slow");
	$("#jk-online-all-survey-error").fadeIn("slow");
	$("#jk_online_10er_vote").click(function () {
		var validated = false
		/*for (i = document.jk_online_10er_form.response.length - 1; i > -1; i--) {
			if (document.jk_online_10er_form.response[i].checked) {
				validated = true;
			}
		}*/
		if ( (document.getElementById("response").value !== "") &&  (document.getElementById("response").value !== null) ){
			validated = true;
		}
		if (validated) {
			$("#jk_online_10er_1").hide("normal");
			$("#jk_online_10er_2").show("normal");
		}
		else {
			//DO SOMETHING IF THEY HAVEN'T CHECKED AN ANSWER
		}

	});
	
	$("#jk_online_10er_name").focus(function () {
		if (this.value == "Name") {
			$(this).val('');
		}
	});
	
	$("#jk_online_10er_name").blur(function () {
		if (this.value == "") {
			$(this).val('Name');
		}
	});
	
	$("#jk_online_10er_email").focus(function () {
		if (this.value == "Email") {
			$(this).val('');
		}
	});
	
	$("#jk_online_10er_email").blur(function () {
		if (this.value == "") {
			$(this).val('Email');
		}
	});
	
	$("#jk_online_10er_province").focus(function () {
		if (this.value == "Province") {
			$(this).val('');
		}
	});
	
	$("#jk_online_10er_province").blur(function () {
		if (this.value == "") {
			$(this).val('Province');
		}
	});
	
	$("#jk_online_10er_postalcode").focus(function () {
		if (this.value == "Postal") {
			$(this).val('');
		}
	});
	
	$("#jk_online_10er_postalcode").blur(function () {
		if (this.value == "") {
			$(this).val('Postal');
		}
	});
	
});

function select_survey_response(id, name, choices) {
	var response = document.getElementById("response");
	var image_source = document.getElementById(id).src;
	for(i = 1; i <= choices; i++) {
		z = "response" + i ;
		y = document.getElementById(z).src
		new_image_source = y.replace(/_on/, "_off");
		document.getElementById(z).src = new_image_source;
	}

	new_image_source = image_source.replace(/_off/, "_on");
	{
		document.getElementById(id).src = new_image_source;
		response.value = name;
		
	}
}


