

//LA FUNZIONE VA RICHIAMATA NEL TAG form IN QUESTO MODO:
//<form name="modulo" action="sendmail.asp" method="post" onsubmit="return controllo('modulo', 'nome,email,msg'); return false;">
//INDICANDO NELL' onsubmit= IL NOME DEL FORM STESSO E IL NOME DEI CAMPI DA CONTROLLARE SEPARATI DA VIRGOLA


function controllo(formnome, arr) {
	// Controllo dei campi form (text-textarea-radio-select-checkbox)
	 
	var col_array = arr.split(",");

	var part_num=0;
	
	while (part_num < col_array.length)
	{
		var nomecampo = col_array[part_num];
		//
		var tipocampo = document.forms[formnome].elements[nomecampo].type; 
				
// ############################################################

			// Campo testo
			if (tipocampo ==  'text' || tipocampo == 'password') {
			
				// Se campo testo email
				var valorecampo = document.forms[formnome].elements[nomecampo].value;
				//alert(valorecampo.length);
				if (nomecampo.indexOf("email") != -1 && (valorecampo.indexOf("@") == -1 || valorecampo.indexOf(".") == -1 || valorecampo < 8)) {
					alert('Formato email non valido');
					return false;
				
				} else {
					// Se campo testo non email
					if (!valorecampo) {
						if (nomecampo == 'foto') {
							alert('Devi caricare almeno una tua foto per continuare');
						} else {
							alert('Compila il campo ' + nomecampo);
						}
						return false;
					}
				}
						
			}
		

// ############################################################
				
		// Campo textarea
		else if (tipocampo ==  'textarea') {
				
				// Se campo textarea
				var valorecampo = document.forms[formnome].elements[nomecampo].value;
				if (!valorecampo) {
					alert('Compila il campo ' + nomecampo);
					return false;
				}
		
		}

// ############################################################
		
		// Campo checkbox
		else if (tipocampo ==  'checkbox') {
				
				// Se campo checkbox
				var valorecampo = document.forms[formnome].elements[nomecampo].checked;
				if (!valorecampo) {
					alert('Il Campo "' + nomecampo + '" deve essere obbligatoriamente selezionato per continuare');
					return false;
				}
						
		}

	
// ############################################################
		
		// Campo select
		else if (tipocampo ==  'select-one') {
			var valorecampo = document.forms[formnome].elements[nomecampo].value;
			if(!valorecampo){
				alert('Compila il campo ' + nomecampo);
				return false;
			}		
		}

// ############################################################
		
		// Campo radio
		//else {
		//	var valorecampo = document.modulo.sesso.value;
		//	if (!valorecampo) {
		//		alert('Campo ' + nomecampo + ' non selezionato');
		//	}
		
		//}

// ############################################################		


		part_num+=1;
	}
}

function acc_legge() {
	// Controllo accettazione leggi

	var consenso1 = document.forms['modulo'].elements['consenso1'].checked;
	var consenso2 = document.forms['modulo'].elements['consenso2'].checked;
	
	if (!consenso1) {
		alert('Per continuare devi autorizzare la pubblicazione delle foto selezionando la casella accanto al testo');
		return false;
	}
	if (!consenso2) {
		alert('Per continuare devi autorizzare la legge sul trattamento dei dati personali selezionando la casella accanto al testo');
		return false;
	}
}


function show(action, name)
		{
			element = document.getElementById(name);
			if(action=="1")
				element.style.display = "block";
			else if(action=="2")
				element.style.display = "none";
		}
	

function roll(mode,nome,over)
{
	if(mode=="over")
	{
		imgOver="imgg/"+nome+"_over.gif";
		document[nome].src=imgOver;
	}

	if(mode=="out")
	{
		imgOut="imgg/"+nome+".gif";
		document[nome].src=imgOut;
	}
}

function alza(action, name)
{
	element = document.getElementById(name);
	if(action=="1")
	{
		//element.style.height = "390px";
		element.style.display = "block";
	}
	else if(action=="2")
	{
		//element.style.height = "0px";
		element.style.display = "none";
	}
}

function AperturaDivGalleria(action, name, des)
{
	element = document.getElementById(name);
	//elementText = document.getElementById(name + '_text');
	if(action=="1")
	{
		element.style.height = "390px";
	//	elementText.innerHTML = '<marquee>' + des + '</marquee>';
	}
	else if(action=="2")
	{
		element.style.height = "0px";
	//	elementText.innerHTML = '';
	}
}





// FUNZIONE AJAX CHE RICOSTRUISCE LA PAGINA
function AjaxRedirect(id,page,stato,musica)
{
	if(musica!='')
	{
		document.film_costini.SetVariable("film_musica", musica);
		/*document.film_costini.TCallLabel("_root", "inizio");*/
	}
	document.getElementById(id).innerHTML = '<p style=\"text-align: center; margin: 50px 0px 50px 0px;\"><img src=\"/imgg/ajax-loader.gif\"\ /></p>';
	$.ajax({
	url: page,
	cache: true,
	success: function(data) {
		$('#' + id).html(data);
	}
	}); 

}

function cambioMusica(musica)
{
	if(musica!='')
	{
		document.film_costini.SetVariable("film_musica", musica);
		/*document.film_costini.TCallLabel("_root", "inizio");*/
	}
}

//CONTROLLO SU FILMATO FLASH da LINK HTML
function callExternalInterface() {
	thisMovie("externalInterfaceExample").goHome();
	
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}
	else {
		return document[movieName];
	}
} 





    function creategallery() {
        var url = "creategallery.asp";
      
		
		if (document.getElementById) {
			var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
			}
			if (x)
			{
				x.onreadystatechange = function()
					{
				if (x.readyState == 4 && x.status == 200)
				{
						
				}
			}
		x.open("GET", url, true);
		x.send(null);
		}
	}
  
