/**
 * @author cristiano
 */

function Poll()
{
	this.script_page = "/vota.php";
	
	this.sendVote = function()
	{
		this.setLoadingSrc("/immagini/vote_loader.gif");
		this.setTarget(document.getElementById("php_response"));
		this.setLoadingTarget(document.getElementById("php_response"));
		
		var scelte = document.getElementsByName("choices");
		var chosen = false;
		
		this.params["id_sondaggio"] = document.getElementById("sondaggio").value;
		for (var i = 0; i < scelte.length; i++)
			if (scelte[i].checked)
			{
				chosen = true;
				this.params["voto"] = parseInt(scelte[i].value);
			}
		
		if (!chosen)
		{
			alert("E' necessario scegeliere almeno un'opzione.");
			scelte[0].focus();
		}
		else
			this.makeRequest(this.script_page);
	}
	
	this.gestisciRisposta = function(response)
	{
		
	}
}

Poll.prototype = new AjaxModule();
Poll.prototype.constructor = Poll;