
function popolaSelectComuni(idSelect, provincia) {
	$.getJSON('../ajax/comuni.asp?provincia=' + provincia, function(data) {
		el = document.getElementById(idSelect);
		el.options.length = 0;
		el.options[0] = new Option('Comune', '');

		$.each(data, function () {
			el.options[el.options.length] = new Option(this.comune, this.comune);
		});
	});
}

function popolaSelectComuniBySigla(idSelect, sigla) {
	$.getJSON('../ajax/comuniBySigla.asp?sigla=' + sigla, function(data) {
		el = document.getElementById(idSelect);
		el.options.length = 0;
		el.options[0] = new Option('Comune', '');

		$.each(data, function () {
			el.options[el.options.length] = new Option(this.comune, this.comune);
		});
	});
}


function popolaSelectPdv(idSelect, comune) {
	$.getJSON('../ajax/pdv.asp?comune=' + comune, function(data) {
		el = document.getElementById(idSelect);
		el.options.length = 0;
		el.options[0] = new Option('Punto vendita', '');
		$.each(data, function () {
			el.options[el.options.length] = new Option(this.nome, this.id);
		});
	});
}

/* CONDIVIDI */

function condividi(from, to) {
	$.getJSON('../ajax/condividi.asp?from=' + from + '&amp;to=' + to, function(data) {
		
	});
	return false;
}

/* PREMI */

$(document).ready(function() {
	$(".voto").hover(
        function() {
			for (i=1;i<=parseInt($(this).attr("rel"));i++) {
				$(".voto[rel="+i+"]").css({background: "url(../images/catalogo_premi/vote_1.jpg) top left no-repeat"});
			}
			for(i=5;i>parseInt($(this).attr("rel")) ; i-- ) {
				$(".voto[rel="+i+"]").css({background: "url(../images/catalogo_premi/vote_0.jpg) top left no-repeat"});
			}
		},
		function() {
		}
	);
	$('#voto_premio').mouseout(function() {
		$(".voto").css({background: "url(../images/catalogo_premi/vote_0.jpg) top left no-repeat"});
	});
	$(".voto").click(function() {
		$(".voto").fadeOut(100, function()
		{
			$("#grazie").fadeIn(200);
		});
		var votazione= $(this).attr("rel");
		$.get("../ajax/voto.asp?id_catalogo="+$('#grazie').attr('rel')+"&voto="+$(this).attr('rel'));
	});
});

