
	var serv = null;

	
	//Controllo la presenza dell'oggetto, per verificare quale browser sta utilizzando l'utente
	if (XMLHttpRequest) 
	{
		serv = new XMLHttpRequest();
	} 
	else if (ActiveXObject) 
	{
		serv = new ActiveXObject('Microsoft.XMLHTTP');
	}


	function isArray(obj)
	{
		return obj.constructor == Array;
	}

	
	

	function hotel_stella_illumina(id_stella, azione)
	{
		//Ciclo sulle STELLE
		for (i = 1; i <= 5; i++)
		{
			if ($("#star_" + i).attr("accesa") == 0)
			{
				if (i <= id_stella)
					$("#star_" + i).attr("src", "images/star_on.png");
				else			
					$("#star_" + i).attr("src", "images/star_off.png");
			}
		}
	}


	function hotel_stella_accendi(id_stella)
	{		
		//Ciclo sulle STELLE
		for (i = 1; i <= 5; i++)
		{
			if (i <= id_stella)
				$("#star_" + i).attr("accesa", "1");
			else			
				$("#star_" + i).attr("accesa", "0");			
		}


		//Imposto il numero delle stelle dell'hotel
		$("#n_stelle").val(id_stella);
	}


	function hotel_gallery_aggiorna_descrizione_foto(order)
	{
		//Inizializzazione variabili
		if (order == '')
			order = $('#gallery').sortable('serialize');
		
		
		order = yykk_trim(order);
		array_foto = new Array();

		//Genero l'array delle foto
		parametri = order.split('&');

		//Ciclo sullarray delle foto
		for (i = 0; i< parametri.length; i++)
		{
			valore = parametri[i].split('=');
			array_foto[i] = valore[1];
		}


		//Ciclo sullarray delle foto
		ordinamento = 1
		for (i = 0; i< array_foto.length; i++)
		{
			//Aggiorno la Descrizione dell'Ordinamento
			$("#ordinamento_des_" + array_foto[i]).html("FOTO N° " + ordinamento);

			//DECREMENTO l'identificativo dell'ordinamento
			ordinamento = ordinamento + 1;
		}
	}


	function hotel_gallery_modifica_foto(id_foto)
	{
		//Creo l?URL per la chaiamata AJAX
		yykk_url = "frontend_query_execute.php?pagina=gestioneimpostazioni&action=pho_mod&id=" + id_foto + 
					  "&ordinamento_des=" + $("#ordinamento_des_" + id_foto).html();


		$.ajax(
		{
			async: false,
			url : yykk_url,
			success : function (data)
			{
				$("#photo_" + id_foto).html(data);				
			}
		});
	}


	function hotel_gallery_nuova_foto()
	{
		//Controllo il numero delle Foto inserite
		if (parseInt($("#n_foto").val()) < parseInt($("#num_max_foto").val()))
		{
			//Controllo il valore dell'attributo CLASS del DIV dei MESSAGGI
			if ($("#yykk_messaggio").attr('class').indexOf('error') >= 0)
			{
				$("#yykk_messaggio").removeClass('msg-error');
				$("#yykk_messaggio").addClass('msg-info');

				$("#yykk_messaggio").html("<p>Trascinare le Foto per ORDINARLE</p>");
			}		


			//Creo l'URL per generare il Layout del Nuovo BOX FOTO
			yykk_url = "frontend_query_execute.php?pagina=gestioneimpostazioni&action=pho_new&id_hotel=" + $("#id_hotel").val();


			$.ajax(
			{
				async: false,
				url : yykk_url,
				success : function (data)
				{
					$("#gallery").append(data);
				}
			});


			$('#gallery').sortable('disable');
		}
		else
		{
			$("#yykk_messaggio").removeClass('msg-info');
			$("#yykk_messaggio").addClass('msg-error');
			
			$("#yykk_messaggio").html("<p>ERRORE, Non è POSSIBILE inserire più di " + $("N_FOTO").val() + " immagini in questa PhotoGallery</p>");
			$('html,body').animate({scrollTop: $("#yykk_messaggio").offset().top},'slow');
		}
	}



	/* FUNZIONE PER CONTROLLARE SE UNA VARIABILE E' UN ARRAY */
	function is_array(obj) 
	{
		return (obj.constructor.toString().indexOf("Array") == -1)
	}

	
	//Funzione per recuperare i dati leggendoli dal database
	function get_provincie(eleTarg, id_regione)
	{
		if (serv)
		{
			var target = document.getElementById(eleTarg);
			
			serv.open("POST", "get_dati.php?id_regione=" + id_regione);			
			serv.onreadystatechange = function() {
				if (serv.readyState == 4 && serv.status == 200) {
					set_provincie(target, serv.responseXML);
				}
			}
			
			serv.send(null);
		}	
	}


	//Funzione per recuperare i dati leggendoli dal database
	function get_comuni(eleTarg, id_provincia)
	{
		if (serv)
		{
			var target = document.getElementById(eleTarg);
			
			serv.open("POST", "get_dati.php?id_provincia=" + id_provincia);
			serv.onreadystatechange = function() {
				if (serv.readyState == 4 && serv.status == 200) {
					set_citta(target, serv.responseXML);
				}
			}
			
			serv.send(null);
		}
	}

	
	function set_provincie(target, xmlDoc) 
	{
		var opzione = document.createElement('option');
		var num = xmlDoc.documentElement.childNodes.length;
		var elem = xmlDoc.documentElement;
		var i;

		delete_select_option(target);
		
		var opzione = new Option("Seleziona la provincia del cliente", "");
		target.options.add(opzione, -1);
		
		for (i = 0; i < num; i++) 
		{
			var dati = elem.getElementsByTagName("nome")[i].childNodes[0].nodeValue;			
			var array_dati = dati.split(':');			
			
			var opzione = new Option(array_dati[0], array_dati[1]);

			target.options.add(opzione, -1);
		}
	}

	
	function set_citta(target, xmlDoc) 
	{
		var opzione = document.createElement('option');
		var num = xmlDoc.documentElement.childNodes.length;
		var elem = xmlDoc.documentElement;
		var i;

		delete_select_option(target);
		
		var opzione = new Option("Seleziona il comune del cliente", "");
		target.options.add(opzione, -1);
		
		for (i = 0; i < num; i++) 
		{
			var testo = elem.getElementsByTagName("nome")[i].childNodes[0].nodeValue;						
			var opzione = new Option(testo, testo);

			target.options.add(opzione, -1);
		}
	}

	
	function modifica_citta()
	{
		var citta = document.frm_modifica.citta.value;
		document.frm_modifica.citta_estero.value = citta;
	}
	
	
	function delete_select_option(target) 
	{
		var i;
		
		for (i=target.length-1; i>=0; i--) 
			target.remove(i);
	}
	
	
	function clienti_ricerca_submit(querystring)
	{
		//Recupero il valore del campo "Nome"
		if (document.frm_ricerca1.nome.value != '')
			document.frm_ricerca2.nome_js.value = document.frm_ricerca1.nome.value;
		
		
		//Recupero il valore del campo "Cognome"
		if (document.frm_ricerca1.cognome.value != '')
			document.frm_ricerca2.cognome_js.value = document.frm_ricerca1.cognome.value;


		//Recupero il valore del campo "Città"
		if (document.frm_ricerca1.citta.value != '')
			document.frm_ricerca2.citta_js.value = document.frm_ricerca1.citta.value;
	
	
		//Eseguo il SUBMIT del secondo FORM
		document.frm_ricerca2.submit();
	}
	
	
	function clienti_inserimento_localita_display()
	{
		//Controllo se la nazione selezionata è "ITALIA"
		if (document.frm_modifica.nazione.value == '28')
		{
			document.getElementById('dati_italia').style.display = "block";
			document.getElementById('dati_estero').style.display = "none";			
		}
		else
		{
			document.getElementById('dati_italia').style.display = "none";
			document.getElementById('dati_estero').style.display = "block";		
		}
	}
	
	
	function clienti_check_campi()
	{
		errore = "";
		
		
		//Controllo sui campi obbligatori
		if (document.frm_modifica.nome.value == '')
			errore = errore + "<p>ERRORE, Valorizzare il campo NOME </p>";
			
		if (document.frm_modifica.cognome.value == '')
			errore = errore + "<p>ERRORE, Valorizzare il campo COGNOME </p>";
			
		if (document.frm_modifica.telefono.value == '')
			errore = errore + "<p>ERRORE, Valorizzare il campo TELEFONO </p>";
		
		if (document.frm_modifica.email.value == '')
			errore = errore + "<p>ERRORE, Valorizzare il campo E-MAIL </p>";
		
		if (document.frm_modifica.lingua.value == '')
			errore = errore + "<p>ERRORE, Valorizzare il campo LINGUA </p>";


		//Controllo il contenuto della variabile "ERRORE"
		if (errore != "")
		{
			document.getElementById('msg_error').innerHTML = errore;
			
			document.getElementById('msg_error').style.display = "block";
			document.getElementById('msg_info').style.display = "none";
			
			return false;
		}
		else
		{
			document.getElementById('msg_error').style.display = "none";
			document.getElementById('msg_info').style.display = "block";
			
			return true;
		}
	}


	function clienti_check_csv()
	{
		if ($("#file_csv").val() != '')
		{
			yykk_file = $("#file_csv").val();
			estensione = yykk_file.substr(yykk_file.length - 3);


			//Controllo l'estensione del FILE
			if ((estensione == 'csv') || (estensione == 'CSV'))
			{
				$("#yykk_messaggio").removeClass('msg-error');
				$("#yykk_messaggio").addClass('msg-info');

				$("#yykk_messaggio").html("<p>Seleziona il FILE dei CLIENTI da Importare</p>");

				return true;
			}
			else
			{
				$("#yykk_messaggio").removeClass('msg-info');
				$("#yykk_messaggio").addClass('msg-error');

				$("#yykk_messaggio").html("<p>ERRORE, E' possibile importare solo File con estensione \".CSV\"</p>");

				return false;
			}
		}
		else
			return false;
	}





	function hotel_aggiungi_periodi(operazione)
	{	
		switch (operazione)
		{
			case 'load':
				$.ajax(
				{
					async: false,
					url : "ajax_aggiungi_periodi_hotel.php?id_hotel=" + $("#hotel_id").val(),
					success : function (data)
					{
						$("#box_periodi").append(data);
					}
				});


				//Valorizzo il numero dei BOX
				$("#num_box").val($("#box_periodi").children().size());
				break;

			default:
				//Controllo che le date del periodo siano valorizzate
				if (($("#data_inizio" + $("#num_box").val()).val() != '') && ($("#data_fine" + $("#num_box").val()).val() != ''))
				{
					//Recupero il numero del BOX che devo creare
					periodi_num_box = parseInt($("#num_box").val()) + 1;


					if (periodi_num_box >= 2)
						data_fine = $("#data_fine" + $("#num_box").val()).val();
					else
						data_fine = '';


					$.ajax(
					{
						url : "ajax_aggiungi_periodi_hotel.php?num_box=" + periodi_num_box + "&data=" + data_fine,
						success : function (data)
						{
							$("#box_periodi").append(data);
							$("#num_box").val(periodi_num_box);
						}
					});


					//Visualizzo il messaggio di ERRORE
					$("#yykk_messaggio").removeClass('msg-error');
					$("#yykk_messaggio").addClass('msg-info');
					
					$("#yykk_messaggio").html('<p>Inserimento dati Hotel</p>');
				}
				else
				{
					$("#yykk_messaggio").removeClass('msg-info');
					$("#yykk_messaggio").addClass('msg-error');
					
					$("#yykk_messaggio").html('<p>ERRORE, per inserire un altro periodo inserire entrambe le date</p>');
				}
				
				break;
		}
	}


	function hotel_periodi_elimina(num_box, id_periodo)
	{
		//Verifico se l'utente vuole effettivamente eliminare il PERIODO
		if (window.confirm('ATTENZIONE: Sei sicuro di eliminare il periodo selezionato ?'))
		{
			//Recupero il valore dell'identificativo del listino			
			hotel = $("#id_hotel").val();
			periodi_num_box = $("#num_box").val();


			yykk_url = "query_execute.php?pagina=gestioneimpostazioni&action=per_elp&id=" + id_periodo;

			$.ajax(
			{				
				url : "" + yykk_url,
				success : function ()
				{
					$("#periodi_" + periodi_num_box).remove();
					$("#num_box").val(parseInt(periodi_num_box) - 1);
				}
			});

			
			/*
			//Controllo il valore dell'dentificativo del listino
			if (id_listino != '')
			{
				if (serv)
				{
					serv.open("POST", "query_execute.php?pagina=gestioneimpostazioni&action=per_elp&id=" + id_periodo);
					serv.onreadystatechange = function() 
					{
						if (serv.readyState == 4 && serv.status == 200)
						{
							//Non faccio niente
						}
					}
					
					serv.send(null);
				}		
			}
		
			document.getElementById('box_periodi').removeChild(document.getElementById(num_box));
			*/
		}
	}





	function periodi_load(id_listino)
	{
		if (id_listino == '0')
			yykk_url = "ajax_aggiungi_periodi.php?num_box=1";
		else
			yykk_url = "ajax_aggiungi_periodi.php?id=" + id_listino;
			
		
		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data) 
			{
				$("#box_periodi").append(data);
			}
		});
	}
	
	
	function periodi_aggiungi()
	{		
		//Recupero l'elenco dei DIV
		var elenco_div = document.getElementsByTagName("div");
		
		//Inizializzo il contatore
		count = 0;
		
		
		//Ciclo sugli elementi presenti nell'array
		for (var i=0; i < elenco_div.length ;i++)
		{
			yykk_div = elenco_div[i];
			div_id = yykk_div.getAttribute("id");
		
			
			//Controllo il valore del div
			if (div_id != null)
			{
				if (div_id.substring(0, 8) == 'periodi_')
					count = parseInt(div_id.substring(8));
			}
		}

		
		//Recupero il numero del BOX che devo creare
		num_box = parseInt(count + 1);
		
		
		if (num_box >= 2)		
			data_fine = document.getElementById("data_fine" + count).value;
		else
			data_fine = '';
		

		$.ajax(
		{
			url : "ajax_aggiungi_periodi.php?num_box=" + num_box + "&data=" + data_fine,
			success : function (data) 
			{
				$("#box_periodi").append(data);
			}
		});
	}
	
	
	function periodi_elimina(num_box, id_periodo)
	{
		//Verifico se l'utente vuole effettivamente eliminare il PERIODO
		if (window.confirm('ATTENZIONE: Sei sicuro di eliminare il periodo selezionato ?'))
		{
			//Recupero il valore dell'identificativo del listino
			id_listino = document.frm_modifica.id_listino.value;


			//Controllo il valore dell'dentificativo del listino
			if (id_listino != '')
			{
				if (serv)
				{
					serv.open("POST", "query_execute.php?pagina=listino&action=per_elp&id=" + id_periodo);
					serv.onreadystatechange = function() 
					{
						if (serv.readyState == 4 && serv.status == 200)
						{
							//Non faccio niente
						}
					}
					
					serv.send(null);
				}		
			}
		
			document.getElementById('box_periodi').removeChild(document.getElementById(num_box));
		}
	}	
	
	
	
	
	
	function richieste_ricerca_submit()
	{
		//Recupero il valore del campo "nome"
		if (document.frm_ricerca1.nome.value != '')
			document.frm_ricerca2.nome_js.value = document.frm_ricerca1.nome.value;
		
		
		//Recupero il valore del campo "cognome"
		if (document.frm_ricerca1.cognome.value != '')
			document.frm_ricerca2.cognome_js.value = document.frm_ricerca1.cognome.value;


		//Recupero il valore del campo "anno"
		if (document.frm_ricerca1.anno.value != '')
			document.frm_ricerca2.anno_js.value = document.frm_ricerca1.anno.value;
			
		//Recupero il valore del campo "lingua"
		if (document.frm_ricerca1.lingua.value != '')
			document.frm_ricerca2.lingua_js.value = document.frm_ricerca1.lingua.value;
	
	
		//Eseguo il SUBMIT del secondo FORM
		document.frm_ricerca2.submit();
	}
	
	

	
	
	function richieste_camere_load_tipi(num_box)
	{	
		hotel = $("#id_hotel").val();


		//Recupero numero ADULTI
		if ($("#num_adulti_" + num_box).val() != '')
			adulti = $("#num_adulti_" + num_box).val();
		else
			adulti = 0;


		//Recupero numero BAMBINI		
		if ($("#num_bambini_" + num_box).val() != '')
			bambini = $("#num_bambini_" + num_box).val();
		else
			bambini = 0;		


		culla = (($("#culla_" + num_box).attr('checked') == true) ? 1 : 0);


		//Mi calcolo il numero dei posti LETTO
		n_posti_letto = parseInt(adulti) + parseInt(bambini) - parseInt(culla);


		//Controllo la lingua
		if ($("#lingua").val() != '')
			lingua = $("#lingua").val();
		else
			lingua = 'it';


	
		if (serv)
		{
			var target = document.getElementById('id_camere_tipo_' + num_box);


			serv.open("POST", "get_dati.php?hotel=" + hotel + "&n_posti_letto=" + n_posti_letto + "&n_adulti=" + adulti + "&lingua=" + lingua);
			serv.onreadystatechange = function() {
				if (serv.readyState == 4 && serv.status == 200) {					
					set_camere_tipo(target, serv.responseXML);
				}
			}
			
			serv.send(null);
		}	
	}

	
	function set_camere_tipo(target, xmlDoc) 
	{
		var opzione = document.createElement('option');
		var num = xmlDoc.documentElement.childNodes.length;
		var elem = xmlDoc.documentElement;
		var i;

		delete_select_option(target);
		
		
		lingua = ($("#lingua").val() == undefined ? 'it' : document.getElementById('lingua').value);
		
		switch (lingua)
		{
			case 'it':
				testo = "seleziona il tipo di camera ";
				break;
			case 'de':
				testo = "Zimmer auswählen ";
				break;
			case 'en':
				testo = "select type of room ";
				break;
			case 'fr':
				testo = "sélectionnez le type de chambre ";
				break;
			default:
				testo = "seleziona il tipo di camera ";
				lingua = 'it';
				break;
		}
		
		
		var opzione = new Option(testo, "");
		target.options.add(opzione, -1);	
		
		for (i = 0; i < num; i++) 
		{
			var dati = elem.getElementsByTagName("nome")[i].childNodes[0].nodeValue;
			
			var array_dati = dati.split(':');			
			
			var opzione = new Option(array_dati[0], array_dati[1]);

			target.options.add(opzione, -1);
		}
	}	
	
	
	function richieste_camera_supplementi(num_box, id_camere_tipo)
	{
		if (id_camere_tipo != '')
		{
			hotel = $("#id_hotel").val();
			yykk_lingua = $("#lingua").val();

			adulti = $("#num_adulti_" + num_box).val();
			bambini = $("#num_bambini_" + num_box).val();
			culla = (($("#culla_" + num_box).attr('checked') == true) ? 1 : 0);
			camere_numeri = ($("#id_camere_numeri").val() == undefined ? '' : $("#id_camere_numeri").val());


			//Mi calcolo il numero dei posti LETTO
			n_posti_letto = parseInt(adulti) + parseInt(bambini) - parseInt(culla);			
		
		
			yykk_url = "get_dati.php?id_camere_tipo=" + id_camere_tipo + '&id_hotel=' + hotel + '&num_box=' + num_box + '&id_camere_numeri=' + camere_numeri + '&lingua=' + yykk_lingua;



			$.ajax(
			{
				url : "" + yykk_url,
				success : function (data)
				{
					//Carico i dati nel DIV
					$("#supplementi_" + num_box).html(data);
					$("#supplementi_" + num_box).css("display", "block");
				}
			});
		}
		else
		{
			$("supplementi_" + num_box).css("display", "none");
			$("supplementi_" + num_box).html("&nbsp;");
		}
	}

	
	
	//Funzione per recuperare i dati del cliente leggendolo dal database
	function richieste_get_clienti()
	{
		var id_cliente = $("#cliente_registrato").val();		
		yykk_url = "ajax_get_cliente.php?id=" + id_cliente;


		$.ajax(
		{
			url : "" + yykk_url,			
			success : function (xmlData)
			{
				//Ciclo sui CLIENTI
				$(xmlData).find('clienti').each(function()
				{
					
					$("#nome").val($(this).find('nome').text());
					$("#cognome").val($(this).find('cognome').text());
					
					$("#telefono").val($(this).find('telefono').text());
					$("#email").val($(this).find('email').text());

					$("#newsletter").attr("checked", ($(this).find('newsletter').text() == '0' ? false : true));
					
					$("#nazione").val($(this).find('nazione').text());
					$("#lingua").val($(this).find('lingua').text());
				});
			}
		});
	}
	
	
	function richieste_filtra_clienti()
	{		
		cognome = document.frm_modifica.cognome_filtra.value;
		nome = document.frm_modifica.nome_filtra.value;
		

		//Controllo che almeno uno dei due parametri sia impostato
		if ((cognome != '') || (nome != ''))
		{
			if (serv)
			{
				var target = document.getElementById('cliente_registrato');

				serv.open("POST", "get_dati.php?cognome=" + cognome + "&nome=" + nome);				
				serv.onreadystatechange = function() {
					if (serv.readyState == 4 && serv.status == 200) {
						set_filtra_cliente(target, serv.responseXML);
					}
				}

				serv.send(null);
			}
		}
	}
	
	
	function set_filtra_cliente(target, xmlDoc) 
	{
		var opzione = document.createElement('option');
		var num = xmlDoc.documentElement.childNodes.length;
		var elem = xmlDoc.documentElement;
		var i;

		delete_select_option(target);
		
		var opzione = new Option("Inserisci Nuovo Cliente", "0");
		target.options.add(opzione, -1);
		
		for (i = 0; i < num; i++) 
		{			
			var dati = elem.getElementsByTagName("nome")[i].childNodes[0].nodeValue;
			var array_dati = dati.split(':');			
			
			var opzione = new Option(array_dati[0], array_dati[1]);
			
			target.options.add(opzione, -1);
		}		
	}	

	
	function set_dati_cliente(xmlDoc)
	{
		var elem = xmlDoc.documentElement;
		var i;
		

		if (elem.getElementsByTagName("nome")[0] != undefined)
		{
			if (elem.getElementsByTagName("nome")[0].childNodes[0] !== undefined)
			{
				var nome = elem.getElementsByTagName("nome")[0].childNodes[0].nodeValue;
				document.getElementById("nome").value = nome;
			}
			else
				document.getElementById("nome").value = '';
		
			
			if (elem.getElementsByTagName("cognome")[0].childNodes[0] !== undefined)
			{
				var cognome = elem.getElementsByTagName("cognome")[0].childNodes[0].nodeValue;			
				document.getElementById("cognome").value = cognome;
			}
			else
				document.getElementById("cognome").value = '';
			
			
			if (elem.getElementsByTagName("codice_fiscale")[0].childNodes[0] !== undefined)
			{
				var codice_fiscale = elem.getElementsByTagName("codice_fiscale")[0].childNodes[0].nodeValue;		
				document.getElementById("codice_fiscale").value = codice_fiscale;
			}
			else
				document.getElementById("codice_fiscale").value = '';
		
		
			if (elem.getElementsByTagName("nazione")[0].childNodes[0] !== undefined)
			{
				var nazione = elem.getElementsByTagName("nazione")[0].childNodes[0].nodeValue;			
				document.getElementById("nazione").value = nazione;
			}
			else
				document.getElementById("nazione").value = '';
			
			
			/*
			if (elem.getElementsByTagName("regione")[0].childNodes[0] !== undefined)
			{
				var regione = elem.getElementsByTagName("regione")[0].childNodes[0].nodeValue;			
				document.getElementById("regione").value = regione;
			}
			else
				document.getElementById("regione").value = '';
			*/
			
			
			if (elem.getElementsByTagName("provincia")[0].childNodes[0] !== undefined)
			{
				var provincia = elem.getElementsByTagName("provincia")[0].childNodes[0].nodeValue;
				document.getElementById("provincia").value = provincia;
			}
			else
				document.getElementById("provincia").value = '';
			
			
			if (elem.getElementsByTagName("citta")[0].childNodes[0] !== undefined)
			{
				var citta = elem.getElementsByTagName("citta")[0].childNodes[0].nodeValue;			
				document.getElementById("citta").value = citta;
			}
			else
				document.getElementById("citta").value = '';

			
			if (elem.getElementsByTagName("indirizzo")[0].childNodes[0] !== undefined)
			{
				var indirizzo = elem.getElementsByTagName("indirizzo")[0].childNodes[0].nodeValue;			
				document.getElementById("indirizzo").value = indirizzo;
			}
			else
				document.getElementById("indirizzo").value = '';

			
			if (elem.getElementsByTagName("cap")[0].childNodes[0] !== undefined)
			{
				var cap = elem.getElementsByTagName("cap")[0].childNodes[0].nodeValue;			
				document.getElementById("cap").value = cap;
			}
			else
				document.getElementById("cap").value = '';

			
			if (elem.getElementsByTagName("telefono")[0].childNodes[0] !== undefined)
			{
				var telefono = elem.getElementsByTagName("telefono")[0].childNodes[0].nodeValue;			
				document.getElementById("telefono").value = telefono;
			}
			else
				document.getElementById("telefono").value = '';
			
			
			if (elem.getElementsByTagName("cellulare")[0].childNodes[0] !== undefined)
			{
				var cellulare = elem.getElementsByTagName("cellulare")[0].childNodes[0].nodeValue;			
				document.getElementById("cellulare").value = cellulare;
			}
			else
				document.getElementById("cellulare").value = '';
			
			
			if (elem.getElementsByTagName("fax")[0].childNodes[0] !== undefined)
			{
				var fax = elem.getElementsByTagName("fax")[0].childNodes[0].nodeValue;			
				document.getElementById("fax").value = fax;
			}
			else
				document.getElementById("fax").value = '';
			

			if (elem.getElementsByTagName("email")[0].childNodes[0] !== undefined)
			{
				var email = elem.getElementsByTagName("email")[0].childNodes[0].nodeValue;			
				document.getElementById("email").value = email;
			}
			else
				document.getElementById("email").value = '';
			
			
			if (elem.getElementsByTagName("newsletter")[0].childNodes[0] !== undefined)
			{
				var newsletter = elem.getElementsByTagName("newsletter")[0].childNodes[0].nodeValue;
				
				if (newsletter == '1')
					document.getElementById("newsletter").checked = true;
				else
					document.getElementById("newsletter").checked = false;				
			}
			else
				document.getElementById("newsletter").checked = false;

			
			if (elem.getElementsByTagName("lingua")[0].childNodes[0] !== undefined)
			{
				var lingua = elem.getElementsByTagName("lingua")[0].childNodes[0].nodeValue;			
				document.getElementById("lingua").value = lingua;
			}
			else
				document.getElementById("lingua").value = '';
				

			for (i = 1; i <= document.getElementById("num_profilazioni").value; i++)
			{
				if (elem.getElementsByTagName("prf_" + i).item(0).childNodes[0] !== undefined)
				{
					if(elem.getElementsByTagName("prf_" + i).item(0).childNodes[0].nodeValue == 1)
						document.getElementById("prf_" + i).checked = true;
					else 
						document.getElementById("prf_" + i).checked = false;
				}
			}
		}
		else
		{
			document.getElementById("nome").value = '';
			document.getElementById("cognome").value = '';
			document.getElementById("codice_fiscale").value = '';
			
			document.getElementById("nazione").value = '0';
			document.getElementById("regione").value = '';
			document.getElementById("provincia").value = '';
			document.getElementById("citta").value = '';
			
			document.getElementById("indirizzo").value = '';
			document.getElementById("cap").value = '';
			
			document.getElementById("telefono").value = '';			
			document.getElementById("cellulare").value = '';
			document.getElementById("fax").value = '';
			document.getElementById("email").value = '';
			
			document.getElementById("newsletter").checked = false;

			
			for(i=1; i<=document.getElementById("num_profilazioni").value; i++)
			{
				document.getElementById("prf_"+i).checked = false;
			}
		}		
	}
	
	
	function newsletter_load_box(id_newsletter)
	{
		if (id_newsletter == '')
			yykk_url = "ajax_aggiungi_box.php?num_box=1";
		else
			yykk_url = "ajax_aggiungi_box.php?id=" + id_newsletter;
			
		
		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data)
			{
				//alert(data);
				$("#box_dettagli").append(data);
			}
		});
	}	
	
	
	function newsletter_aggiungi_box()
	{
		//Recupero l'elenco dei DIV
		var elenco_div = document.getElementsByTagName("div");
		
		//Inizializzo il contatore
		count = 0;
		
		
		//Ciclo sugli elementi presenti nell'array
		for (var i=0; i < elenco_div.length ;i++)
		{
			yykk_div = elenco_div[i];
			div_id = yykk_div.getAttribute("id");
		
			
			//Controllo il valore del div
			if (div_id != null)
			{
				if (div_id.substring(0, div_id.length - 1) == 'box_newsletter_')
					count = parseInt(div_id.substring(div_id.length - 1));
			}
		}

		
		//Recupero il numero del BOX che devo creare
		num_box = parseInt(count + 1);
		
		
		lingua = 'it';
		

		$.ajax(
		{
			url : "ajax_aggiungi_box.php?num_box=" + num_box + "&lingua=" + lingua,
			success : function (data) 
			{
				$("#box_dettagli").append(data);
			}
		});
	}
	
	
	function newsletter_elimina_box(num_box, id_newsletter_box)
	{		
		//se il dettaglio richiesta da eliminare è nel db
		if (id_newsletter_box != '')
		{
			if (confirm("Sei sicuro di eliminare il BOX selezionato ?"))
			{
				$.ajax(
				{
					url : "ajax_elimina_box_newsletter.php?id=" + id_newsletter_box,
					success : function (data) 
					{
						document.getElementById('box_dettagli').removeChild(document.getElementById('box_newsletter_' + num_box));
					}
				});
			}
		}
		else
		{
			if (confirm("Sei sicuro di eliminare il BOX selezionato ?"))
				document.getElementById('box_dettagli').removeChild(document.getElementById('box_newsletter_' + num_box));	
		}
	}	


	function newsletter_elimina_foto_box(nome_div, id_newsletter_dettagli, num_box, url)
	{
		//Recupero il valore dell'identificativo della NEWSLETTER
		id_newsletter = document.getElementById('id').value;
		
		
		radio_value = 0;
		all_radio = document.getElementsByName('id_layout_box_' + num_box);
		for (i=0; i < all_radio.length; i++) 
		{
			if (all_radio[i].checked)
				radio_value = all_radio[i].value;
		}		


		image_box = document.getElementById('img_div_' + id_newsletter_dettagli);
		
		
		if (confirm("Sei sicuro di eliminare la foto ?"))
		{
			$.ajax(
			{
				url : "query_execute.php?pagina=newsletter&action=elf&id=" + id_newsletter + "&idd=" + id_newsletter_dettagli,
				success : function (data)
				{
					//Controllo il valore del radio button
					switch (radio_value)
					{
						case '1':
						case '2':				
							$("#img_div_" + id_newsletter_dettagli).attr("src", url + "/images/img_logo_ds.jpg");
							break;
						case '3':
						case '4':
							$("#img_div_" + id_newsletter_dettagli).attr("src", url + "/images/img_logo_td.jpg");
							break;
					}
					
					$("#button_del_image_" + id_newsletter_dettagli).css('display', 'none');
				}
			});
		}
	}
	
	
	function newsletter_modifica_layout_box(num_box, id_newsletter_dettagli, id_newsletter_layout_box)
	{
		//Controllo il valore dell'identificativo dei DETTAGLI
		if (id_newsletter_dettagli != '0')
		{		
			if (confirm("Sei sicuro di voler modifica il LAYOUT del BOX ?"))
			{
				$.ajax(
				{				
					url : "ajax_modifica_layout_box.php?num_box=" + num_box + "&idd=" + id_newsletter_dettagli + "&idlb=" + id_newsletter_layout_box,
					success : function (data)
					{
						$("#dialog_" + id_newsletter_dettagli).html(data);
					}
				});
			}
		}
	}
	
	
	function richieste_aggiungi_camera()
	{
		if (serv)
		{
			if(document.getElementById('num_max_box').value != 0)
				num_box = parseInt(document.getElementById('num_max_box').value) + 1;
			else
				num_box = 1;

				
			//Recupero la lingua
			if ($('#lingua').val() == undefined)
				yykk_lingua = 'it';
			else			
				yykk_lingua = (document.getElementById('lingua').value == '' ? 'it' : document.getElementById('lingua').value);


			yykk_hotel = ($('#id_hotel').val() == undefined ? '1' : $('#id_hotel').val());


			serv.open("POST", "ajax_aggiungi_camera.php?num_box=" + num_box + "&lingua=" + yykk_lingua + "&id_hotel=" + yykk_hotel);
			serv.onreadystatechange = function() 
			{
				if (serv.readyState == 4 && serv.status == 200) 
				{
					//Controllo il risultato
					if (serv.responseText != '')
					{
						//Creo l'elemento da appendere al DIV padre
						var div=document.createElement("DIV");
						div.setAttribute("id","camera_" + num_box);
						div.innerHTML = serv.responseText;
						
						document.getElementById('box_camere').appendChild(div);
						
						//document.getElementById('box_camere').innerHTML += serv.responseText;
						
						//Scrivo il numero del box nel campo hidden del form
						document.getElementById('num_max_box').value = num_box;
					}
				}
			}
			
			serv.send(null);
		}	
	}
	
	
	function richieste_elimina_camera(num_box, id_dettagli_richieste)
	{		
		//se il dettaglio richiesta da eliminare è nel db
		if (id_dettagli_richieste != '')
		{
			if (serv)
			{		
				serv.open("POST", "ajax_elimina_box_camera.php?id=" + id_dettagli_richieste);
				serv.onreadystatechange = function() {
					if (serv.readyState == 4 && serv.status == 200) 
					{
						document.getElementById('box_camere').removeChild(document.getElementById('camera_' + num_box));

						
						//Aggiorno il valore del campo hidden del form
						document.getElementById('num_max_box').value = richieste_conta_camere_div();
					}
				}
				
				serv.send(null);
			}
		}
		else
		{
			document.getElementById('box_camere').removeChild(document.getElementById('camera_' + num_box));


			//Aggiorno il valore del campo hidden del form
			document.getElementById('num_max_box').value = richieste_conta_camere_div();			
		}
	}
	
	
	function richieste_conta_camere_div()
	{
		contatore = 0;
		lista_div = document.getElementsByTagName('div');
		
		
		//Ciclo su tutti i DIV del documento
		for (i=0; i < lista_div.length; i++)
		{
			id = lista_div[i].getAttribute("id");
			
			//Controllo che l'identificativo del DIV sia valorizzato
			if (id != null)
			{
				//Controllo il nome del DIV
				if (id.indexOf("camera_") != -1)
				{
					//Recupero identificativo della camera
					yykk_valore = id.replace("camera_", '');
					
					//Controllo il valore dell'identificativo della camera
					if (yykk_valore > contatore)
						contatore = yykk_valore;
				}
			}
		}
		
		return contatore;
	}
	
	
	//Funzione per recuperare i dati leggendoli dal database
	function richieste_get_disposizioni_camera(eleTarg, id_camere_tipo, num_box)
	{
		if (serv)
		{
			var target = document.getElementById(eleTarg);

			serv.open("POST", "ajax_get_disposizione.php?id_camere_tipo=" + id_camere_tipo + "&num_box=" + num_box);
			serv.onreadystatechange = function() {
				if (serv.readyState == 4 && serv.status == 200) {
					set_disposizione(target, serv.responseXML, num_box);
				}
			}
			
			serv.send(null);
		}
	}

	
	function set_disposizione(target, xmlDoc, num_box) 
	{
		var opzione = document.createElement('option');
		var num = xmlDoc.documentElement.childNodes.length;
		var elem = xmlDoc.documentElement;
		var i;

		delete_select_option(target);
		
		var opzione = new Option("Seleziona la disposizione della camera", "");
		target.options.add(opzione, -1);
		
		for (i = 0; i < num; i++) 
		{
			var id = elem.getElementsByTagName("id_"+num_box)[i].childNodes[0].nodeValue;
			var nome = elem.getElementsByTagName("nome_"+num_box)[i].childNodes[0].nodeValue;

			var opzione = new Option(nome, id);

			target.options.add(opzione, -1);
		}
	}
	
	
	/* FUNZIONI GESTIONE DEL FORM CAMERE */
	function check_listino_camere_value()
	{
		//Inizializzo il FLAG
		flag_visualizza = false;



		//Controllo che siamo in modifica
		if ($("#action").val() == 'ins')
			flag_visualizza = true;		
		else
		{
			//Controllo il valore del campo LISTINO
			if ($("#listino_cal_sup").val() == 1)
			{
				//Controllo se si tratta della camera di RIFERIMENTO
				if (parseInt($("#riferimento").val()) == 1)
				{
						alert('ATTENZIONE: Non è possibile trasformare il LISTINO della camera da CALENDARIO a SUPPLEMENTO, per la CAMERA di RIFERIMENTO');
						$("#listino_cal_sup option[value='0']").attr('selected', 'selected');				
				}
				else
				{
					//Controllo il numero di CAMERE
					if (parseInt($("#num_camere").val()) <= 1)
					{
						alert('ATTENZIONE: Non è possibile trasformare il LISTINO della camera da CALENDARIO a SUPPLEMENTO, poichè non ne esistono altre a CALENDARIO per questa TIPOLOGIA');
						$("#listino_cal_sup option[value='0']").attr('selected', 'selected');
					}
					else
					{				
					
						if (window.confirm('ATTENZIONE: Trasformare il LISTINO di una camera da CALENDARIO a SUPPLEMENTO\ncancellerà i PREZZI presenti nel Listino, sei sicuro ?') == true)
						{
							flag_visualizza = true;
							$("#num_camere").val(parseInt($("#num_camere").val()) - 1);
						}
						else
							$("#listino_cal_sup option[value='0']").attr('selected', 'selected');
					}					
				}
			}
			else
			{
				$("#num_camere").val(parseInt($("#num_camere").val()) + 1);
				flag_visualizza = true;
			}
		}


		//Controllo se devo visualizzare il DIV del SUPPLEMENTO
		if (flag_visualizza)
		{
			//Recupero il valore della combo
			valore = document.frm_modifica.listino_cal_sup.value;

			//Controllo sul valore recuperato
			switch (valore)
			{
				case '':
				case '0':
					document.getElementById('listino_supplemento').style.display = 'none';
					break;

				case '1':
					yykk_url = "query_execute.php?pagina=listino&action=del_prz&id_camere_tipo=" + $("#id").val();


					//Elimino con AJAX tutti dati del listino
					$.ajax(
					{
						url: yykk_url
						/*
						success: function(data)
						{
							$('.result').html(data);
							alert('Load was performed.');
						}
						*/
					});


					//Visualizzo il DIV del SUPPLEMENTO
					document.getElementById('listino_supplemento').style.display = 'block';
					break;
			}
		}
	}
	
	
	function change_disp_value()
	{
		valore1 = document.frm_modifica.n_posti_letto.value;
		valore2 = document.frm_modifica.disposizione_posti_letto.value;
	
		
		//Controllo che i due valori siano uguali
		if (valore1 == valore2)
		{
			var array_div = document.getElementsByTagName("div");
			
			//DIV da visualizzare
			my_div = 'div_disp_' + valore1;
			

			for(i=0; i < array_div.length; i++)
			{					
				//Controllo se ho trovato il mio DIV
				if (array_div[i].getAttribute("id") == my_div)
					array_div[i].style.display = 'block';
				else
				{
					if (array_div[i].getAttribute("id") == null)
						valore = 'inner-container';					
					else
						valore = array_div[i].getAttribute("id");
						
					
					valore = valore.substring(0, parseInt(valore.length - 1));
				
					if (valore == 'div_disp_')
						array_div[i].style.display = 'none';
				}
			} 
		}
		else
		{
			document.frm_modifica.disposizione_posti_letto.value = 0;		
			document.frm_modifica.disposizione_posti_letto.focus();
		}
	}

	
	function visualizza_listino_camera(id_listino_camera)
	{
		//Recupero l'elenco dei DIV
		var elenco_a = document.getElementsByTagName("a");
		var elenco_div = document.getElementsByTagName("div");		


		//Ciclo sugli elementi presenti nell'array
		for (var i=0; i < elenco_div.length ;i++)
		{
			yykk_div = elenco_div[i];
			div_id = yykk_div.getAttribute("id");
		
			
			//Controllo il valore del div
			if (div_id != null)
			{
				if (div_id.substring(0, 14) == 'listino_camera')
				{
					if (div_id == id_listino_camera)
						yykk_div.style.display = 'block';
					else				
						yykk_div.style.display = 'none';
				}
			}
		}

		
		//Ciclo sugli elementi presenti nell'array
		for (var i=0; i < elenco_a.length ;i++)
		{
			yykk_a = elenco_a[i];
			a_id = yykk_a.getAttribute("id");
		
			
			//Controllo il valore del div
			if (a_id != null)
			{
				if (a_id.substring(0, 14) == 'listino_camera')
				{
					if (a_id == id_listino_camera)
						yykk_a.className = 'active';
					else				
						yykk_a.className = '';
				}
			}
		}						
	}
	
	
	

	/* FUNZIONI ALLA ELIMINAZIONE DELLE FOTO */
	
	function camere_elimina_foto(id_camere_tipo)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=camere&action=elf&id="+id_camere_tipo);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}
	
	
	function camerefoto_elimina_foto(nome, id_foto)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=camere&action=pho_elf&nome=" + nome + "&idf=" + id_foto);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show_' + id_foto + '_1').style.display="none";
						document.getElementById('show_' + id_foto + '_2').style.display="none";						
					}
				}
				
				serv.send(null);
			}
		}	
	}

	
	function photogallery_elimina_foto(id_foto_gallery, id_foto)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=photo&action=ele_elf&id=" + id_foto_gallery + "&idf=" + id_foto);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}
	
	
	function hotel_elimina_foto(id_hotel)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=impostazioni_hotel&action=elf&id="+id_hotel);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}
	
	
	function lastminute_elimina_foto(id_offerte)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=lastminute&action=elf&id="+id_offerte);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}
	
	
	function offerte_elimina_foto(id_offerte)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=offerte&action=elf&id="+id_offerte);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}	
	
	
	function servizi_elimina_foto(id_servizi)
	{
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{		
				serv.open("POST", "query_execute.php?pagina=camere&action=ser_elf&id="+id_servizi);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine:";
					}
				}
				
				serv.send(null);
			}
		}	
	}	
	
	
	
	/* FUNZIONI RELATIVE A NEWSLETTER */
	
	//Funzione che elimina una singola foto dalla newsletter
	function newsletter_elimina_foto(id_newsletter,image_num) 
	{ 
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{
				serv.open("POST", "query_execute.php?pagina=newsletter&action=elf&id="+id_newsletter+"&image_num="+image_num);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1_'+image_num).style.display="none";
						document.getElementById('show2_'+image_num).style.display="none";
						document.getElementById('label_img'+image_num).innerHTML = "Foto BOX #"+image_num;
					}
				}
				
				serv.send(null);
			}
		}
	}
	
	
	//FUNZIONE VECCHIA DI FILTRO DEGLI INDIRIZZI
	//Funzione che calcola il numero di indirizzi a cui inviare la newsletter in base al filtro di ricerca del form
	function newsletter_filtra_ricerca() 
	{ 	
		var id_newsletter=document.getElementById("id").value;
		var lingua=document.getElementById("lingua").value;
		var nome=document.getElementById("nome").value;
		var cognome=document.getElementById("cognome").value;
		var nazione=document.getElementById("nazione").value;
		var provincia=document.getElementById("provincia").value;
		var citta=document.getElementById("citta").value;


		for(i = 1; i <= document.forms['frm_invia'].elements['cliente'].length; i++)
		{
			if (document.forms['frm_invia'].elements['cliente' + i].checked)
				var cliente=document.forms['frm_invia'].elements['cliente' + i].value;
		}

		
		var adulti=document.getElementById("adulti").value;
		var bambini=document.getElementById("bambini").value;
		var eta_da=document.getElementById("anni_da").value;
		var eta_a=document.getElementById("anni_a").value;
		

		var dal=document.getElementById("da").value;
		var al=document.getElementById("a").value;

		
		for(i = 1; i <= document.forms['frm_invia'].elements['prenotato'].length; i++)
		{
			if (document.forms['frm_invia'].elements['prenotato' + i].checked)
				var prenotato=document.forms['frm_invia'].elements['prenotato' + i].value;
		}
		
		
		for(i = 1; i <= document.forms['frm_invia'].elements['offerta'].length; i++)
		{
			if (document.forms['frm_invia'].elements['offerta' + i].checked)
				var offerta=document.forms['frm_invia'].elements['offerta' + i].value;
		}

		
		//Controllo se esistono le profilazioni
		if (document.forms['frm_invia'].elements['profilazioni[]'] != undefined)
		{
			var profilazioni = '';
			var i=0;
			for (j = 0; j < document.forms['frm_invia'].elements['profilazioni[]'].length; j++)
			{			
				if (document.forms['frm_invia'].elements['profilazioni[]'][j].checked)
				{
					profilazioni = profilazioni + '&profilazioni[]=' + document.forms['frm_invia'].elements['profilazioni[]'][j].value;
					i=i+1;
				}
			}

			if (i == 0)
				profilazioni = '&profilazioni=';
		}
		else
			profilazioni = '';



		if (serv)
		{
			serv.open("POST", "filtra_clienti_newsletter.php?pagina=newsletter&action=cnt&id=" + id_newsletter + "&lingua=" + lingua + 
									"&nome=" + nome + "&cognome=" + cognome + "&nazione=" + nazione + "&provincia=" + provincia + 
									"&citta=" + citta + "&cliente=" + cliente + "&adulti=" + adulti + "&bambini=" + bambini + 
									"&eta_da=" + eta_da + "&eta_a=" + eta_a + "&dal=" + dal +"&al=" + al +"&offerta=" + offerta + 
									"&prenotato=" + prenotato + profilazioni);

			serv.onreadystatechange = function() 
			{
				if (serv.readyState == 4 && serv.status == 200)
				{
					if(serv.responseText)
						num = parseInt(serv.responseText);
					else num = 0;
					
					if(num != 0)
					{
						if (confirm("Sei sicuro di inviare la newsletter a "+ num +" cliente/i ?")) 
						{
							document.frm_invia.submit();
						}
					}
					else
					{
						alert("La ricerca non ha prodotto alcun risultato!");
						return false;
					}
				}
			}
			
			serv.send(null);
		}
	}
	
	
	//Funzione che calcola il numero di indirizzi a cui inviare la newsletter in base al filtro di ricerca del form
	function newsletter_filtra_invio()
	{
		//Recupero l'identificativo della NEWSLETTER SELEZIONATA
		id_newsletter = document.getElementById("id").value;

		
		//Recupero il valore selezionato per il campo CLIENTE
		for(i = 1; i <= document.forms['frm_invia'].elements['cliente'].length; i++)
		{
			if (document.forms['frm_invia'].elements['cliente' + i].checked)
				cliente = document.forms['frm_invia'].elements['cliente' + i].value;
		}

		
		
		//Controllo se esistono le profilazioni
		if (document.forms['frm_invia'].elements['profilazioni[]'] != undefined)
		{
			var profilazioni = '';
			var i = 0;
			
			for (j = 0; j < document.forms['frm_invia'].elements['profilazioni[]'].length; j++)
			{			
				if (document.forms['frm_invia'].elements['profilazioni[]'][j].checked)
				{
					profilazioni = profilazioni + '&profilazioni[]=' + document.forms['frm_invia'].elements['profilazioni[]'][j].value;
					i++;
				}
			}

			if (i == 0)
				profilazioni = '&profilazioni=';
		}
		else
			profilazioni = '';
			
		
		
		//Recupero i valori relativi ai campi delle RICHIESTE associate al CLIENTE
		adulti = document.getElementById("adulti").value;
		bambini = document.getElementById("bambini").value;
		
		eta_da = document.getElementById("anni_da").value;
		eta_a = document.getElementById("anni_a").value;
		

		dal = document.getElementById("da").value;
		al = document.getElementById("a").value;

		
		//Recupero il valore che mi identifitiva se la RICHIESTA è anche una prenotazione
		for(i = 1; i <= document.forms['frm_invia'].elements['prenotato'].length; i++)
		{
			if (document.forms['frm_invia'].elements['prenotato' + i].checked)
				prenotato = document.forms['frm_invia'].elements['prenotato' + i].value;
		}
		
		
		/*
		//Recupero il valore che mi identifica se la RICHIESTA fa riferimento ad un'offerta
		for(i = 1; i <= document.forms['frm_invia'].elements['offerta'].length; i++)
		{
			if (document.forms['frm_invia'].elements['offerta' + i].checked)
				var offerta=document.forms['frm_invia'].elements['offerta' + i].value;
		}
		*/


		yykk_url = "filtra_clienti_newsletter.php?pagina=newsletter&action=cnt&id=" + id_newsletter + 					  
					  "&cliente=" + cliente + "&adulti=" + adulti + "&bambini=" + bambini + 
					  "&eta_da=" + eta_da + "&eta_a=" + eta_a + "&dal=" + dal +"&al=" + al +
					  "&prenotato=" + prenotato + profilazioni;


		$.ajax(
		{
			url : yykk_url,
			success : function (data) 
			{
				//Chiedo conferma sull'invio della NEWSLETTER
				if (confirm("Sei sicuro di inviare la newsletter a " + data + " cliente/i ?")) 
				{
					document.frm_invia.submit();
				}											
			}
		});
	}


	function newsletter_filtra_test() 
	{
		document.frm_invia.action.value = 'tst';
		document.frm_invia.submit();
	}	
	

	
	/* FUNZIONI RELATIVE A NEWS ED EVENTI */
	
	//Funzione che elimina la foto dalla news
	function news_elimina_foto(id_news) 
	{ 
		if (confirm("Sei sicuro di eliminare la foto?")) 
		{
			if (serv)
			{
				serv.open("POST", "query_execute.php?pagina=news&action=elf&image=1&id="+id_news);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show1').style.display="none";
						document.getElementById('show2').style.display="none";
						document.getElementById('label_img').innerHTML = "Immagine :";
					}
				}
				
				serv.send(null);
			}
		}
	}
	
	//Funzione che elimina il file dalla news
	function news_elimina_file(id_news) 
	{ 
		if (confirm("Sei sicuro di eliminare il file?")) 
		{
			if (serv)
			{
				serv.open("POST", "query_execute.php?pagina=news&action=elf&image=0&id="+id_news);
				serv.onreadystatechange = function() 
				{
					if (serv.readyState == 4 && serv.status == 200)
					{
						document.getElementById('show3').style.display="none";
						document.getElementById('show4').style.display="none";
						document.getElementById('label_file').innerHTML = "File :";
					}
				}
				
				serv.send(null);
			}
		}
	}
	
	
	/* FUNZIONI RELATIVE AI SUPPLEMENTI/SCONTI */
	
	
	//Funzione che restituisce il nome del servizio selezionato e lo mette nell'input del nome
	function supplementi_servizi_nome() 
	{ 	
		var id_servizi = document.getElementById("id_servizi").value;
		
		if (serv)
		{
			serv.open("POST", "ajax_nome_servizio.php?id="+id_servizi);
			serv.onreadystatechange = function() 
			{
				if (serv.readyState == 4 && serv.status == 200)
				{
					if(serv.responseText)
						nome = serv.responseText;
					else
						nome = '';
					
					document.getElementById('nome').value = nome;
				}
			}
			
			serv.send(null);
		}
	}
	
	
	//Funzione che controlla se il nome del supplemento è stato modificato e se è diverso da quelli codificati nella tabella dei servizi
	function supplementi_controlla_nome() 
	{ 	
		var nome = document.getElementById("nome").value;
		
		if (serv)
		{
			serv.open("POST", "ajax_nome.php?nome="+nome);
			serv.onreadystatechange = function() 
			{
				if (serv.readyState == 4 && serv.status == 200)
				{
					if(serv.responseText)
					{
						if(serv.responseText != '0')
						{
							id = serv.responseText;
							document.getElementById('id_servizi').value = id;
						}
						else
						{
							id = 0;
							document.getElementById('id_servizi').value = id;
						}
					}
					
				}
			}
			
			serv.send(null);
		}
	}
	
	
	
	
	/* FUNZIONI RELATIVE AL REPERIMENTO DEI DATI IN BASE ALLA DATA */
	
	function booking_update_camere_quadro(hotel, anno, mese)
	{
		//Creo l'URL per la chiamata AJAX
		yykk_url = "ajax_booking.php?action=quadro&hotel=" + hotel + "&anno=" + anno + "&mese=" + mese;
		
		
		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data) 
			{
				//Ricarico il quadro camere
				$("#camere_quadro_elenco").html(data);
				

				//Recupero l'elenco degli elenchi puntati
				elenco_ol = $("ol");				

				//Eseguo un refresh sugli elementi SELECTABLE
				$.each(elenco_ol, function(key, value) 
				{
					ol_id = this.id;
					ol_id = ol_id.replace(' ', '');
					
					$("#" + ol_id).selectable();
				});
			}
		});	
	}
	
	
	function booking_arrivi_partenze(data, hotel)
	{
		//Creo l'URL per la chiamata AJAX
		yykk_url = "ajax_booking.php?action=arrivi&data=" + data + "&hotel=" + hotel;


		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data) 
			{
				$("#arrivi_partenze_dati").html(data);
			}
		});
	}


	function booking_camere_riempi_periodo(ncamera)
	{
		//Creo l'URL per la chiamata AJAX
		yykk_url = "ajax_booking.php?action=riempi" + "&hotel=" + $("#id_hotel").val() +
					  "&ncamera=" + ncamera + "&periodo=" + $("#mese_anno_sel").val();


		//Chiamata per aggiornare il database
		$.ajax(
		{
			url : "" + yykk_url
		});


		//Devo SELEZIONARE tutti i selectable della CAMERA
		$(".ui-selectable-default").each(function()
		{
			//Controllo il valore degli attributi
			if ($(this).attr('yykk_ncamera') == ncamera)
				$(this).addClass('ui-selected');			
		});		
	}


	function booking_camere_svuota_periodo(ncamera)
	{
		//Creo l'URL per la chiamata AJAX
		yykk_url = "ajax_booking.php?action=svuota" + "&hotel=" + $("#id_hotel").val() +
					  "&ncamera=" + ncamera + "&periodo=" + $("#mese_anno_sel").val();


		//Chiamata per aggiornare il database
		$.ajax(
		{
			url : "" + yykk_url
		});


		//Devo DESELEZIONARE tutti i selectable della CAMERA
		$(".ui-selectable-default").each(function()
		{
			//Controllo il valore degli attributi
			if ($(this).attr('yykk_ncamera') == ncamera)			
				$(this).removeClass('ui-selected');			
		});
	}


	function booking_camere_disponibilita(operazione, hotel, ncamera, data)
	{
		//Creo l'URL per la chiamata AJAX
		yykk_url = "frontend_query_execute.php?pagina=booking&action=" + operazione + 
					  "&id_hotel=" + hotel + "&id_camere_numeri=" + ncamera + 
					  "&id_data=" + data;		

		//Chiamata per aggiornare il database
		$.ajax(
		{
			url : "" + yykk_url
		});


		//Devo DESELEZIONARE tutti i selectable della CAMERA
		$("li[yykk_data=").addClass('ui-selected');
	}





	/* FUNZIONI RELATIVE ALLA FUNZIONALITA' BOOKING - GESTIONE CAMERE NUMERI */

	function booking_camere_numeri_aggiungi()
	{
		//Recupero il numero del BOX
		num_box = parseInt($("#num_box_camere").val()) + 1;


		yykk_url = "get_dati.php?num_camere_box=" + num_box;


		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data)
			{
				//alert(data);
				$("#elenco_num_camere").append(data);
				$("#num_box_camere").val(parseInt($("#num_box_camere").val()) + 1);
			}
		});
	}	


	function booking_camere_numeri_rimuovi(id_div)
	{
		$("#num_box_camere").val(parseInt($("#num_box_camere").val()) - 1);		
		$("#" + id_div).remove();
	}


	function booking_camere_numeri_occupa()
	{
		//Recupero il numero del BOX
		anno = $("#anno_listino").val();
		hotel = $("#id_hotel").val();


		//Controllo che la SELCT sia stata valorizzata
		if (anno != '')
		{
			if (confirm("Sei sicuro di OCCUPARE tutte le CAMERE nel periodo del Listino selezionato ?"))
			{
				yykk_url = "frontend_query_execute.php?pagina=booking&action=dsp_mui" + "&id_hotel=" + hotel + "&anno_listino=" + anno;


				$.ajax(
				{
					url : "" + yykk_url,
					success : function (data)
					{
						alert( data );
					}
				});
			}
		}
		else
			alert("ERRORE, Scegli il Listino dal menù a tendina");
	}





	/* FUNZIONI RELATIVE ALLA VALIDAZIONE UTENTI */

	function validate_username()
	{
		if (serv)
		{
			username = document.frm_modifica.username.value;
			
			serv.open("POST", "get_dati.php?username=" + username);
			serv.onreadystatechange = function() {
				if (serv.readyState == 4 && serv.status == 200) {
					//Controllo il risultato
					if (serv.responseText != 'no')
					{
						document.getElementById('msg_info').className = "msg msg-error";
						document.getElementById('msg_info').innerHTML = "<p>Cambia il valore del campo \"USERNAME\", l'utente ->" + serv.responseText + "<- è già presente all'interno del database.</p>";
						
						document.frm_modifica.username.value = '';
						document.frm_modifica.username.focus();
					}
				}
			}
			
			serv.send(null);
		}	
	}
	
	
	function validate_mail_it()
	{
		//Mi carico l'espressione regolare
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		var email = document.frm_newsletter.email.value;

		
		//Inizilizzo la stringa per il messaggio di errore
		errore = '';


		//Recupero il DIV per inserire il messaggio di errore
		div_errore = document.getElementById('campo_errore');
		

		//Controllo se la mail è corretta
		if ((email != '') && (email != 'mail@example.com'))
		{
			if (! espressione.test(email))
				errore = errore + "ERRORE, Inserire una E-MAIL valida";
		}
		else
			errore = errore + "ERRORE, Inserire una E-MAIL valida";



		if (errore == '')
			return true;
		else
		{
			div_errore.innerHTML = errore;
			div_errore.style.display = 'block';
			
			return false;
		}			
	}


	function validate_mail_de()
	{
		//Mi carico l'espressione regolare
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		var email = document.frm_newsletter.email.value;

		
		//Inizilizzo la stringa per il messaggio di errore
		errore = '';


		//Recupero il DIV per inserire il messaggio di errore
		div_errore = document.getElementById('campo_errore');
		

		//Controllo se la mail è corretta
		if ((email != '') && (email != 'mail@example.com'))
		{
			if (! espressione.test(email))
				errore = errore + "FEHLER, Bitte beachten Sie die E-Mail ist nicht gültig!";
		}
		else
			errore = errore + "FEHLER, Bitte beachten Sie die E-Mail ist nicht gültig!";



		if (errore == '')
			return true;
		else
		{
			div_errore.innerHTML = errore;
			div_errore.style.display = 'block';
			
			return false;
		}
	}	
	
	
	function validate_mail_en()
	{
		//Mi carico l'espressione regolare
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		var email = document.frm_newsletter.email.value;

		
		//Inizilizzo la stringa per il messaggio di errore
		errore = '';


		//Recupero il DIV per inserire il messaggio di errore
		div_errore = document.getElementById('campo_errore');
		

		//Controllo se la mail è corretta
		if ((email != '') && (email != 'mail@example.com'))
		{
			if (! espressione.test(email))
				errore = errore + "ERROR, You entered an email not valid!";
		}
		else
			errore = errore + "ERROR, You entered an email not valid!";



		if (errore == '')
			return true;
		else
		{
			div_errore.innerHTML = errore;
			div_errore.style.display = 'block';
			
			return false;
		}
	}


	function validate_mail_fr()
	{
		//Mi carico l'espressione regolare
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		var email = document.frm_newsletter.email.value;

		
		//Inizilizzo la stringa per il messaggio di errore
		errore = '';


		//Recupero il DIV per inserire il messaggio di errore
		div_errore = document.getElementById('campo_errore');
		

		//Controllo se la mail è corretta
		if ((email != '') && (email != 'mail@example.com'))
		{
			if (! espressione.test(email))
				errore = errore + "ERREUR, l'e-mail entré n'est pas valide!";
		}
		else
			errore = errore + "ERREUR, l'e-mail entré n'est pas valide!";



		if (errore == '')
			return true;
		else
		{
			div_errore.innerHTML = errore;
			div_errore.style.display = 'block';
			
			return false;
		}
	}

	
	function validate_richieste_form()
	{
		msg = '';
		num_adulti = document.getElementById('num_adulti');
		da = document.getElementById('da');
		a = document.getElementById('a');
		nome = document.getElementById('nome');
		cognome = document.getElementById('cognome');
		nazione = document.getElementById('nazione');
		regione = document.getElementById('regione');
		provincia = document.getElementById('provincia');
		citta = document.getElementById('citta');
		email = document.getElementById('email');

		
		//Controllo se è stato selezionato un valore per il campo "adulti"
		if (num_adulti.value == "")
			msg = msg  + "<p>Selezionare un valore per il campo \"adulti\".</p>";
		
		//Controllo se è stato selezionato un valore per il campo "periodo - da" e se è corretto
		if (da.value == "")
			msg = msg  + "<p>Selezionare una data per il campo \"periodo - da\".</p>";
		else
		{
			var filter =/^(0[1-9]|[1-2]\d|3[0-1])\/(0[1-9]|1[0-2])\/([0-9][0-9][0-9][0-9])$/;
			if (!filter.test(da.value))
				msg = msg  + "<p>Inserire un valore corretto per il campo \"periodo - da\".</p>";
		}
			
		//Controllo se è stato selezionato un valore per il campo "periodo - a" e se è corretto
		if (a.value == "")
			msg = msg  + "<p>Selezionare una data per il campo \"periodo - a\".</p>";
		else
		{
			var filter =/^(0[1-9]|[1-2]\d|3[0-1])\/(0[1-9]|1[0-2])\/([0-9][0-9][0-9][0-9])$/;
			if (!filter.test(a.value))
				msg = msg  + "<p>Inserire un valore corretto per il campo \"periodo - a\".</p>";
		}
		
		if ( (da.value != '') && (a.value != '') )
		{
			da_split = da.value.split("/");
			var da = new Date(da_split[2],da_split[1]-1,da_split[0]);
			a_split = a.value.split("/");
			var a = new Date(a_split[2],a_split[1]-1,a_split[0]);
			
			if(a <= da) 
				msg = msg  + "<p>il valore del campo \"periodo - da\" non può essere successivo o uguale al valore del campo \"periodo - a\".</p>";
		}
		
		//Controllo se è stato selezionato un valore per il campo "nome"
		if (nome.value == "")
			msg = msg  + "<p>Inserire il campo \"nome\".</p>";
		
		//Controllo se è stato selezionato un valore per il campo "cognome"
		if (cognome.value == "")
			msg = msg  + "<p>Inserire il campo \"cognome\".</p>";
			
		//Controllo se è stato selezionato un valore per il campo "nazione"
		if (nazione.value == "")
			msg = msg  + "<p>Selezionare un valore per il campo \"nazione\".</p>";
		
		//Controllo se è stato selezionato un valore per il campo "email" e se è corretto
		if (email.value == "")
			msg = msg  + "<p>Inserire il campo \"email\".</p>";
		else
		{
			var filter =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(!filter.test(email.value))
				msg = msg  + "<p>Inserire un valore corretto per il campo \"email\".</p>";
		}
			

		//Controlo se devo visualizzare un messaggio di errore
		if (msg != '')
		{
			document.getElementById('msg_info').className = "msg msg-error";
			document.getElementById('msg_info').innerHTML = msg;
			document.getElementById('msg_info').style.display = 'block';
			
			return false;
		}
		else
			return true;
	}
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
	/* FUNZIONI RELATIVE ALLA FUNZIONALITA' CONTENUTI */
	
	function contenuti_load_box(id_contenuti)
	{
		if (id_contenuti == '')
			yykk_url = "ajax_aggiungi_contenuti.php?op=vis&num_box=1";
		else
			yykk_url = "ajax_aggiungi_contenuti.php?op=vis&id=" + id_contenuti;
			
		
		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data)
			{
				//alert(data);
				$("#box_dettagli").append(data);
			}
		});
	}	
	
	
	function contenuti_aggiungi_box()
	{
		//Recupero l'elenco dei DIV
		var elenco_div = document.getElementsByTagName("div");
		
		//Inizializzo il contatore
		count = 0;
		
		
		//Ciclo sugli elementi presenti nell'array
		for (var i=0; i < elenco_div.length ;i++)
		{
			yykk_div = elenco_div[i];
			div_id = yykk_div.getAttribute("id");
		
			
			//Controllo il valore del div
			if (div_id != null)
			{
				if (div_id.substring(0, div_id.length - 1) == 'box_contenuti_')
					count = parseInt(div_id.substring(div_id.length - 1));
			}
		}

		
		//Recupero il numero del BOX che devo creare
		num_box = parseInt(count + 1);
		
		
		lingua = 'it';
		

		$.ajax(
		{
			url : "ajax_aggiungi_contenuti.php?op=vis&num_box=" + num_box + "&lingua=" + lingua,
			success : function (data) 
			{
				$("#box_dettagli").append(data);
			}
		});
	}
	
	
	function contenuti_elimina_box(num_box, id_newsletter_box)
	{		
		//se il dettaglio richiesta da eliminare è nel db
		if (id_newsletter_box != '')
		{
			if (confirm("Sei sicuro di eliminare il BOX selezionato ?"))
			{
				$.ajax(
				{
					url : "ajax_aggiungi_contenuti.php?op=del&id=" + id_newsletter_box,
					success : function (data) 
					{
						document.getElementById('box_dettagli').removeChild(document.getElementById('box_contenuti_' + num_box));
					}
				});
			}
		}
		else
		{
			if (confirm("Sei sicuro di eliminare il BOX selezionato ?"))
				document.getElementById('box_dettagli').removeChild(document.getElementById('box_contenuti_' + num_box));	
		}
	}	


	function contenuti_elimina_foto_box(nome_div, id_contenuti_dettagli, num_box, url)
	{
		//Recupero il valore dell'identificativo della NEWSLETTER
		id_contenuti = document.getElementById('id').value;
		

		radio_value = 0;
		all_radio = document.getElementsByName('id_layout_box_' + num_box);
		for (i=0; i < all_radio.length; i++) 
		{
			if (all_radio[i].checked)
				radio_value = all_radio[i].value;
		}		

		
		if (confirm("Sei sicuro di eliminare la foto ?"))
		{
			$.ajax(
			{
				url : "query_execute.php?pagina=gestionecontenuti&action=elf&id=" + id_contenuti + "&idd=" + id_contenuti_dettagli,
				success : function (data)
				{
					/*
					//Controllo il valore del radio button
					switch (radio_value)
					{
						case '1':
						case '2':				
							$("#img_div_" + id_contenuti_dettagli).attr("src", url + "/images/img_logo_ds.jpg");
							break;
						case '3':
						case '4':
							$("#img_div_" + id_contenuti_dettagli).attr("src", url + "/images/img_logo_td.jpg");
							break;
					}
					*/
					
					$("#button_del_image_" + num_box).css('display', 'none');
				}
			});
		}
	}
	
	
	function contenuti_modifica_layout_box(num_box, id_contenuti_dettagli, id_contenuti_layout_box)
	{
		//Controllo il valore dell'identificativo dei DETTAGLI
		if (id_contenuti_dettagli != '0')
		{
			if (confirm("Sei sicuro di voler modifica il LAYOUT del BOX ?"))
			{
				$.ajax(
				{
					url : "ajax_aggiungi_contenuti.php?op=mod_box&num_box=" + num_box + "&idd=" + id_contenuti_dettagli + "&idlb=" + id_contenuti_layout_box,
					success : function (data)
					{
						$("#dialog_" + id_contenuti_dettagli).html(data);
					}
				});
			}
		}
	}


	function contenuti_load_layout()
	{
		//Controllo il valore del CHECKBOX
		if ($("#contenuti_landing").attr('checked'))
			landing = 1;
		else
			landing = 0;


		yykk_url = "ajax_aggiungi_contenuti.php?op=lay_loa&contenuti_landing=" + landing;
		
		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data)
			{
				if (data != '')
				{
					$("#contenuti_layout").html(data);
					$("#contenuti_layout").css("display", "block");
				}
				else
				{
					$("#contenuti_layout").css("display", "none");
				}
			}
		});
	}


	function contenuti_load_offerte()
	{	
		yykk_url = "ajax_aggiungi_contenuti.php?op=mod_off&id_lingue=" + $("#id_lingue").val();

		$.ajax(
		{
			url : "" + yykk_url,
			success : function (data)
			{
				$("#offerte_allegate").html(data);
			}
		});
	}


	function contenuti_check_allegaform()
	{
		//Ciclo sui CHECKBOX delle OFFERTE
		n_offerte = 0;
		$("#offerte_allegate").find("input[type='checkbox']").each(function(i)
		//$("#offerte_allegate").find("input").each(function(i)
		{
			//Controllo 
			if ($(this).attr('checked') == true)
				n_offerte = n_offerte + 1;
		});


		//Controllo quante OFFERTE sono state allegate alla pagina
		if (n_offerte > 1)
		{
			$("#allega_form").attr("checked", false);
			$("#allega_form").attr("disabled", true);
		}
		else
			$("#allega_form").attr("disabled", false);
	}
