
/*_____________________________POP UP_____________________________*/

	function popUp(pg, w, h, scr, res) 
	{ 
		
		if (w == "" || h == "")
		{
			w = (screen.width - 250);
			h = (screen.height - 250);
		}

		larg = screen.width;
		alt = screen.height;

		larg = (larg - w)/2;
		alt = (alt - h)/2;

		window.open(pg, 'p', 'scrollbars='+scr+', resizable='+res+', width='+w+', height='+h+', top='+alt+', left='+larg+', status=no, location=no, toolbar=no');
	}

// La funzione che controllo il modulo di invio richiesta informazioni
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('Per continuare devi Accettare l\'informativa sul trattamento dei Dati personali.');
					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;
			}		
		}

// ############################################################
	var consenso1 = document.forms['form2'].elements['consenso1'].checked;
	alert(consenso1);
	if (consenso1 == true) {
		alert('OK');
		return false;
	} else {
		
		alert('Per inviare la Richiesta devi prima leggfere ed accettare il Trattamento della Privacy.');	
	}
		
		// Campo radio
		//else {
		//	var valorecampo = document.modulo.sesso.value;
		//	if (!valorecampo) {
		//		alert('Campo ' + nomecampo + ' non selezionato');
		//	}
		
		//}

// ############################################################		


		part_num+=1;
	}
}