// --------------------------------------------------------------------------------
// poll_CheckVote.js
// Simon Anderson 24-Sep-2007
// Contains Javascript relevant to the poll form.
// --------------------------------------------------------------------------------


var qp_fieldPrefix = "tmpl_qp_Poll_ctl00_";


// --- Attach JS to document elements and execute simple statements. ---
ow_f_AppendLoadEvent(
function()
{
	if (document.getElementById(qp_fieldPrefix + "ow_btnVote") != null)
		ow_f_AddEvent(document.getElementById(qp_fieldPrefix + "ow_btnVote"), "click", qp_NoVote, false);
		
		// hide the progress indicator on load
	if (document.getElementById("qp_progress") != null)	
		document.getElementById("qp_progress").style.display="none";	
}
);


function qp_NoVote()
{	    
	var count = 0;
	if (document.getElementById("qp_frm") != null)
	{
		var inp = document.getElementById("qp_frm").getElementsByTagName("input");
		for (var i = 0; i < inp.length; i++)
			if (inp[i].type == "radio" && inp[i].checked)
				count ++;
	}
	if (count == 0)	{
		alert(document.getElementById(qp_fieldPrefix + "qp_cvNoVote").value);
		return false;
	}
    else {
        qp_HideShowFields(null);
	    return true;	
    }

}

// --- Hides and show specific div's on the page
// --- This function is called onClick of the submit button if the validation passes
// --- Hides the form, shows the progress graphic
function qp_HideShowFields(e) 
{
	document.getElementById("qp_frm").style.display="none";
	document.getElementById("qp_progress").style.display="block";
}