/**
 * @author federico
 */
function visualizza_voto(voto) {
	var voti = ["Scarso", "Niente di speciale", "Degno di nota", "Bello", "Strepitoso!", ""];
	for(i = 0; i<voto; i++) {
		$("#star"+i).attr("src", "images/star.png");
	}
	for(i = voto; i<6; i++) {
		$("#star"+i).attr("src", "images/star0.png");
	}
	$("#commento").html(voti[voto-1]);
}

function vota(voto) {		
	$.ajax( {
		async : true,
		cache : false,
		dataType : 'html',
		type : 'POST',
		url : "votazione.php",
		data : {
			voto : voto,
			id_scheda : $("#id_scheda").val()
		},
		beforeSend : function(XMLHttpRequest) {
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		success : function(data, textStatus, XMLHttpRequest) {
			$("img.star").removeAttr("onmouseover");
			$("img.star").removeAttr("onmouseout");
			$("a.star").removeAttr("onclick");
			$("#commento").html(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert(textStatus);
		}
	});
	
	return false;
}

function pubblica() {
	$.ajax( {
		async : true,
		cache : false,
		dataType : 'html',
		type : 'POST',
		url : "/gestione_schede/pubblica",
		data : {
			pubblica : $("input:checked").val(),
			id : $("#id_scheda").val()
		},
		beforeSend : function(XMLHttpRequest) {
			carica_start();
		},
		complete : function(XMLHttpRequest, textStatus) {
			carica_stop();
		},
		success : function(data, textStatus, XMLHttpRequest) {
			alert(data);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert(textStatus);
		}
	});
}
