function sondaggio_vota(sondaggio_id,tot_opz) {
	var i, valore;
	
	for( i=1;i<tot_opz;i++){
		var id = 'input_opz_'+i;
		var id_input = document.getElementById(id);
		
		if(id_input){
			if(id_input.checked==true){
				valore = i;
			}
		}
	}
	if(valore){
		voto = document.getElementById('input_opz_'+valore).value;
		http.open('get', '/ajax/sondaggi/vota.php?sondaggio_id='+sondaggio_id+'&voto='+voto);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
}
		
function aggiungi_opz(sondaggio_id){
	var nuova_opz;
	nuova_opz = document.getElementById('opz');
	opz = nuova_opz.value;
	http.open('get', '/ajax/sondaggi/nuova_opz.php?sondaggio_id='+sondaggio_id+'&nuova_opz='+opz);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
		
function apri_box(div_box) {
	var div = document.getElementById(div_box);
	visibile=(div.style.display!="none")
	if (visibile) {
		div.style.display="none";
	} else {
		div.style.display="block";
	}
}

function sondaggio_commenta(sondaggio_id, commento_id) {
	http.open('get', '/ajax/sondaggi/apri_commento_sondaggio.php?sondaggio_id='+sondaggio_id+'&commento_id='+commento_id);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function sondaggio_commento_segnala(sondaggio_id, commento_id) {
	http.open('get', '/ajax/apri_commento_sondaggio_segnala.php?sondaggio_id='+sondaggio_id+'&commento_id='+commento_id);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function chiudi_box(div){
	elem = document.getElementById(div);
	elem.style.display = 'none';
}
	
function show_box(div){
	elem = document.getElementById(div);
	elem.style.display = 'block';
}
function chiudi_segnala(div){
	elem = document.getElementById(div);
	elem.style.display = 'none';
}


function modera_commento_s(commento_id, stato){
	http.open('get', '/ajax/modera_commento_s.php?commento_id='+commento_id+'&stato='+stato);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

// **********************

function show_tendenza(sondaggio_id){
	http.open('get', '/ajax/sondaggi/tendenza.php?id='+sondaggio_id);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
