// JavaScript Document
	$(document).ready(function() {
	
	    // form di ricerca
		$('#NAZIONE').change(function() {
			var nazione = $(this).val();
			//alert(nazione);
			if (nazione.indexOf("I__Ital") != -1) {    // olo se hanno scelto italia
			    popola_REGIONE(curLang,$(this).val());
			} else {
			    popola_REGIONE();
			}
		});
		$('#REGIONE').change(function() {
		    popola_PR(curLang,$('#NAZIONE').val(),$(this).val());
		});
		
		// agenda nella ricerca espositori
		$("a.in_agenda").click(function(event) {
	  		event.preventDefault();
	  		var theUrl = $(this).attr('href');
		    //alert('click '+theUrl);
		    jQuery.ajax({
		        type: "POST",
		        url: theUrl,
		        success: function(html){
		            if(html!=''){
		                //$('#'+id).html(html);
		                alert(html);
		            }
		        }
		    });
		});
	});

	function popola_REGIONE(curLang,nazione) {
	    var id = 'REGIONE';
	    if (!curLang) {
		    //$('#'+id+' option:not(option:first)').remove();
		    $('#'+id+' option').remove();
		} else {
		    var theUrl = '/php/ajax/e_popola_regione.php?LANG='+curLang+'&NAZIONE='+nazione;
			//alert(theUrl);
		    jQuery.ajax({
		        type: "POST",
		        url: theUrl,
		        success: function(html){
		            if(html!=''){
		                $('#'+id).html(html);
		            }
		        }
		    });
		}
		popola_PR(); // svuota la provincia
	} // popola_REGIONE

	function popola_PR(curLang,nazione,regione) {
	    var id = 'PR';
	    if (!curLang) {
		    //$('#'+id+' option:not(option:first)').remove();
		    $('#'+id+' option').remove();
		} else {
		    var theUrl = '/php/ajax/e_popola_pr.php?LANG='+curLang+'&NAZIONE='+nazione+'&REGIONE='+regione;
			//alert(theUrl);

		    jQuery.ajax({
		        type: "POST",
		        url: theUrl,
		        success: function(html){
		            if(html!=''){
		                $('#'+id).html(html);
		            }
		        }
		    });
		}
	} // popola_PR

