/* ----------------------------- */
/* funzioni prototipo */
String.prototype.trim = function() {
	// skip leading and trailing whitespace
	// and return everything in between
	var x=this;
	x=x.replace(/^\s*(.*)/, "$1");
	x=x.replace(/(.*?)\s*$/, "$1");
	return x;
}// fine funzione

/* ----------------------------- */
function apriFinestra(name, larghezza, altezza){
	var x = (screen.width - larghezza)/2;
	var y = (screen.height - altezza)/2;
	var finestra = window.open(name, 'ingrandimento', 'width=' + larghezza +',height=' + altezza + ',toolbar=no,directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=no,resizable=no');
	finestra.moveTo(x,y);
	finestra.focus();
}// fine funzione


/* ----------------------------- */
function controlloUploadDocumento() {
	var filename = $("#frm_documento").val();
  	if( (filename=='') ){
  			alert("Caricare un proprio documento di riconoscimento!");
			$("#frm_documento").focus();
			return false;
	}else{
	  	var pathParts = filename.split('/');   // Split the path on '/': ['path', 'to', 'file.ext']
	  	var filenamePop  = pathParts.pop();       // Take the last element. This is a file name: 'file.ext'
	  	var filenameParts = filenamePop.split('.'); // Split the file name on the '.': ['file', 'ext']
	  	var ext = filenameParts[1];      // Take the extension: 'ext'
		
        if (ext != "JPEG" && ext != "jpeg" && ext != "jpg" && ext != "JPG" && ext != "PDF" && ext != "pdf" && ext != "doc" && ext != "docx") {
	            alert("Formato consentito: jpg, pdf, doc");
	            return false;
        }
        return true;
	}
}


/* ----------------------------- */
/* DIMENSIONE LARGHEZZA FINESTRA */
	function WindowSizeW() {
	  	var myWidth = 0;
	  	if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
	  	} else if( document.documentElement && ( document.documentElement.clientWidth) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myWidth = document.documentElement.clientWidth;
	  	} else if( document.body && ( document.body.clientWidth) ) {
	    	//IE 4 compatible
	    	myWidth = document.body.clientWidth;
	  	}
	  	return myWidth;
	}//end function

/* ----------------------------- */
/* DIMENSIONE ALTEZZA FINESTRA */
	function WindowSizeH() {
	  	var myHeight = 0;
	  	if( typeof( window.innerHeight ) == 'number' ) {
		    //Non-IE
	    	myHeight = window.innerHeight;
	  	} else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myHeight = document.documentElement.clientHeight;
	  	} else if( document.body && ( document.body.clientHeight ) ) {
	    	//IE 4 compatible
	    	myHeight = document.body.clientHeight;
	  	}
	  	return myHeight;
	}//end function

	
	// IS INTEGER POSITIVE (NON ZERO)
	function isNormalInteger(str) {
	    var n = Math.floor(Number(str));
	    return n !== Infinity && String(n) === str && n >= 0;
	}
	
	

	// VERIFICA Data di nascita
	function isDate(what,fname)
	{
	   var i=new RegExp("^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$");
	   if(i.test(what))
	   {
		datePart=what.split("/");
		giorno=(datePart[0]>=1) && (datePart[0]<=31);
		mese=(datePart[1]>=1) && (datePart[1]<=12);
		anno=(datePart[2]>=1900) && (datePart[2]<=9999);

		if(!giorno || !mese || !anno) { 
			alert("Il campo data non e' valido."); return false }
	   }else{
		   alert("Il campo data non e' valido!"); return false
	   }
	   return true;
	}

	
	// VERIFICA isEmail
	function isEmail(what)
	{
	   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	   if(!i.test(what)) { alert("Il campo EMAIL non e' valido."); return false}   
	   return true;
	}	
	
	// VERIFICA CAP
	function isCAP(what)
	{
	   var i=new RegExp("^[0-9]{5}$");
	   if(!i.test(what)) { alert("Il campo CAP non e' corretto."); return false }   
	   return true;
	}

	// VERIFICA Partita IVA
	function isPIVA(what)
	{
		var i=new RegExp("[0-9]{11}");
		if(!i.test(what)) { 
			alert("Il campo PARTITA IVA non e' valido (11 cifre numeriche).");
			return false;
		}   
	   return true;
	}
	
	// VERIFICA CF
	function isCF(what)
	{
	   	var i=new RegExp("([a-zA-Z0-9]{16})");
	   	if(!i.test(what)) { 
		   alert("Il campo CODICE FISCALE non e' valido (16 cifre alfanumeriche)."); 
		   return false; 
		}   
	   	return true;
	}	
	
	
	function isCFAzienda(what)
	{
		var i=new RegExp("[0-9]{11}");
		if(!i.test(what)) { 
			alert("Il campo Codice Fiscale/Partita Iva della ditta non e' valido. (11 cifre numeriche)");
			return false;
		}   
	   return true;
	}

	
	// VERIFICA CF OR P IVA
	function isCF_or_isPIVA(what){
	   var i_cf=new RegExp("([a-zA-Z0-9]{16})");
	   var i_pi=new RegExp("[0-9]{11}");
	   if(!i_cf.test(what) && !i_pi.test(what)) { 
		   		alert("Inserire un CODICE FISCALE o una Partita IVA valida !"); 
		   		return false 
		   }   
	   return true;
	}
	
	
/* ----------------------------- */
function VerificaData(Valore) {
	var ValoriData;
	var Giorni = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var iData = new RegExp("^((3[0-1])|([1-2][0-9])|(0[1-9]))\/((1[0-2])|(0[1-9]))\/((19|20)[0-9][0-9])$");
	// verifica la validita' della data

	if(iData.test(Valore) == true){
		//	if (Valore.search(/^(3[01]|[0-2]\d)\/(1[0-2]|0\d)\/(19|20)\d\d$/) != -1 && Valore.lenght == 10) {
		// imposta il vettore dei valori
		ValoriData = Valore.split("/");
		// verifica se l'anno e' bisestile aggiungo 1 a febbraio
		if (ValoriData[2] % 4 == 0){
			Giorni[1]++;
		}// fine if
		//		alert(ValoriData[0] + '---|' + (ValoriData[1] - 1) + '|---' + Giorni[ValoriData[1] - 1] + '///' + (ValoriData[0] <= Giorni[ValoriData[1] - 1]) );
		return (ValoriData[0] <= Giorni[ValoriData[1] - 1]);
	}// fine if
	// in caso di errore ritorna false
	return false;
}//end function




// ############################################ //
//############################################ //
//############################################ //
$(function () {
	
	/* 7 FORMS - OPEN SELECT GRUPPI NEWSLETTER */
	$("#frm_newletter_forms").change(function(event){
	  	if($('#frm_newletter_forms').is(':checked')){
	  		$('#frm_newletter_forms_scelte').slideDown("slow");
	  	}else{
	  		$('#frm_newletter_forms_scelte').slideUp("slow");
	  	}//end if
	});

	/* 7 FORMS - CLOSE MODAL PREVIEW */
	$('.btn.btn-secondary, #empModal .close').on('click', function(event) {
		  event.preventDefault(); // To prevent following the link (optional)
		  $('#empModal').modal('hide'); 
	});
	
	/* 7 FORMS - CLOSE MODAL PREVIEW & SUBMIT FORM SU UNICA PAGINATA (il pulsante ha id diverso da quelle su + step :((( ) */
	$('.btn.btn-primary.onepage').on('click', function(event) {
		event.preventDefault(); // To prevent following the link (optional)
		$('#empModal').modal('hide');
		$('#btn-submit').trigger('click');
	});
	
	/* 7 FORMS - CLOSE MODAL PREVIEW & SUBMIT FORM SU PIU PAGINATE (il pulsante ha id diverso da quelle su + step :((( ) */
	$('.btn.btn-primary.morepage').on('click', function(event) {
		event.preventDefault(); // To prevent following the link (optional)
		$('#empModal').modal('hide');
		$('#btn_avanti_privacy').trigger('click');
	});
	
	
	
})
// ############################################ //
// ############################################ //
// ############################################ //


/* ----------------------------- */
/* ----------------------------- */
function login_accedi(lingua){
	switch(lingua){
		case 2:
			msg_user='Username not valid!';
			msg_psw='Password not valid!';
		break;
		default:
			msg_user='Username non valido!';
			msg_psw='Password non valida!';
		break;
	}//end switch

	with(document.forms['login']){
		//alert(UNAME.value.length);
		if(UNAME.value.length<=2){
			alert(msg_user);
			UNAME.focus();
			return;
		}//fine if
		if(PASSWD.value.length<=2){
			alert(msg_psw);
			PASSWD.focus();
			return;
		}//fine if
		submit();
	}// fine with
}// fine funzione

/* ----------------------------- */
/* ----------------------------- */
function contattaci(lingua){
	switch(lingua){
		case 3:
			msg_nome='Sie m\u00FCssen den Namen einsetzen!';
			msg_cognome='Sie m\u00FCssen den letzten Namen einsetzen!';
			msg_testo='Sie m\u00FCssen eine Anzeige einsetzen!';
			msg_email="Sie m\u00FCssen Adressen-email in der korrekten Form einsetzen: nome@dominio.xx!";			msg_citta='Sie m\u00FCssen eine Ort einsetzen!';
			msg_legge="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
			msg_destinatario="Wahlen Sie ein Zielgebiet!";

		msgLegge1='Devi acconsentire che i dati personali vengano utilizzati per le finalita di cui al punto a)';
		msgLegge2='Devi dire se acconsenti che i dati personali vengano utilizzati per le finalita di cui al punto b)';

		break;

		case 2:
			msg_nome='Insert the name!';
			msg_cognome='Insert the surname!';
			msg_testo='Insert a text message!';
			msg_email='E-mail format not correct\nFormat: name@dom.xx';
			msg_citta='Insert the city!';
			msg_legge='Non avete dato il consenso alla Legge 196/2003!';
			msg_destinatario="Select the destinator!";

		msgLegge1='Devi acconsentire che i dati personali vengano utilizzati per le finalita di cui al punto a)';
		msgLegge2='Devi dire se acconsenti che i dati personali vengano utilizzati per le finalita di cui al punto b)';

		break;

		default:
			msg_nome='Devi inserire il nome!';
			msg_cognome='Devi inserire il cognome!';
			msg_testo='Devi inserire un testo!';
			msg_email='Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx';
			msg_citta='Devi inserire la citta\'!';
			msg_legge='Non avete dato il consenso alla Legge 196/2003!';
			msg_destinatario="Selezionare un area di destinazione!";
		msgLegge1='Non avete dato il consenso alla Legge 196/2003!';
		//msgLegge1='Devi acconsentire che i dati personali vengano utilizzati per le finalita di cui al punto a)';
		msgLegge2='Devi dire se acconsenti che i dati personali vengano utilizzati per le finalita di cui al punto b)';

		break;
	}//end switch
	with(document.forms['contattaci']){
		// Nome
		frm_nome.value = frm_nome.value.trim();
		if(frm_nome.value==''){
			alert(msg_nome);
			frm_nome.focus();
			frm_nome.select();
			return;
		}//fine if

		// Cognome
		frm_cognome.value = frm_cognome.value.trim();
		if(frm_cognome.value==''){
			alert(msg_cognome);
			frm_cognome.focus();
			frm_cognome.select();
			return;
		}//fine if

		// Citta
//		frm_citta.value = frm_citta.value.trim();
//		if(frm_citta.value==''){
//			alert(msg_citta);
//			frm_citta.focus();
//			frm_citta.select();
//			return;
//		}//fine if

		// Mail
		frm_email.value = frm_email.value.trim();
		if (frm_email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(msg_email);
			frm_email.focus();
			frm_email.select();
			return;
		}//fine if

		//CONTROLLO SE E CHECCATA UNA DESTINAZIONE
		//faccio un controllo se esiste un campo area
		//se esiste deve essere checcato almeno uno
		//se non esiste dovrebbe esserci il campo h_Area e quindi partira ad mail_amm
		if(eval('document.forms[\'contattaci\'].Area') == undefined){

		}else{
			check_richiesta=0;
			for(i=0;i< elements.length;i++){
				if(eval(elements[i].name) != undefined){
				if(elements[i].name.substring(0,4)=='Area' && elements[i].checked){
					check_richiesta=1;
				}//end if
				}//end if
			}//end for
			if(check_richiesta==0){
				alert(msg_destinatario);
				return;
			}//end fi

		}//end for

		// MESSAGGIO
		frm_mess.value = frm_mess.value.trim();
		if(frm_mess.value==''){
			alert(msg_testo);
			frm_mess.focus();
			frm_mess.select();
			return;
		}//fine if


		// Legge
		if(!frm_legge[0].checked){
			alert(msgLegge1);
			frm_legge.focus();
			return;
		}// fine if

//		if(lingua == 1){
//			if(!frm_newsletter[0].checked && !frm_newsletter[1].checked){
//				alert(msgLegge2);
//				frm_newsletter.focus();
//				return;
//			}// fine if
//		}//end if



		frm_op.value = 'ok';
		submit();
	}// fine with
}// fine funzione

/* ----------------------------- */
function consulenza(linguaSito){
	switch(linguaSito){
		case 3:
		msgNome='Sie m\u00FCssen den Namen einsetzen!';
		msgCognome='Sie m\u00FCssen den letzten Namen einsetzen!';
		msgEmail="Sie m\u00FCssen Adressen-email in der korrekten Form einsetzen: nome@dominio.xx!";
		msgTesto='Sie m\u00FCssen eine Anzeige einsetzen!';
		msgLegge1="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
		msgProfessione="Insert a profession!";
		break;

		case 2:
		msgNome='Insert the name!';
		msgCognome='Insert the surname!';
		msgEmail="E-mail format not correct\nFormat: name@dom.xx!";
		msgTesto='Insert a text message!';
		msgLegge="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
		msgProfessione="Insert a profession!";

		break;
		default:
		msgNome='Devi inserire il nome!';
		msgCognome='Devi inserire il cognome!';
		msgEmail="Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx!";
		msgTesto='Devi inserire un testo!';
		msgLegge="Non avete dato il consenso alla Legge 196/2003";
		msgProfessione="Specificare una professione!";
		break;
	}//end switch

	with(document.forms[0]){

		// Nome
		consNome.value = consNome.value.trim();
		if(consNome.value==''){
			alert(msgNome);
			consNome.focus();
			consNome.select();
			return;
		}//fine if

		// Cognome
		consCognome.value = consCognome.value.trim();
		if(consCognome.value==''){
			alert(msgCognome);
			consCognome.focus();
			consCognome.select();
			return;
		}//fine if

		// PROFESSIONE ALTRO
		//		consProfAltro.value = consProfAltro.value.trim();
		//		if(consProf[2].checked && consProfAltro.value == ''){
		//			consProfAltro.focus();
		//			consProfAltro.select();
		//			alert(msgProfessione);
		//			return;
		//		}//fine if


		// Mail
		consEmail.value = consEmail.value.trim();
		if (consEmail.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(msgEmail);
			consEmail.focus();
			consEmail.select();
			return;
		}//fine if

		//CONTROLLO SE E CHECCATA UNA DESTINAZIONE
		//faccio un controllo se esiste un campo area
		//se esiste deve essere checcato almeno uno
		//se non esiste dovrebbe esserci il campo h_Area e quindi partira ad mail_amm
		if(eval('document.forms[0].Area') == undefined){

		}else{
			check_richiesta=0;
			for(i=0;i< elements.length;i++){
				//alert(i + " - " + elements[i].name + " - " + elements[i].value + " - " + elements[i].checked);
				if(elements[i].name.substring(0,4)=='Area' && elements[i].checked){
					check_richiesta=1;
				}//end if
			}//end for
			if(check_richiesta==0){
				alert("Selezionare un area di destinazione!");
				return;
			}//end fi

		}//end for

		// MESSAGGIO
		consTesto.value = consTesto.value.trim();
		if(consTesto.value==''){
			alert(msgTesto);
			consTesto.focus();
			consTesto.select();
			return;
		}//fine if

		// Legge
		//		if(lingua == 1 ){
		if(!consLegge.checked){
			alert(msgLegge);
			consLegge.focus();
			return;
		}// fine if
		//		}// fine if

		frm_op.value = 'ok';
		submit();
	}// fine with
}// fine funzione

/**
*/
function lavoro(lingua){
	// Italiano
	var msgNome;
	var msgCognome;
	var msgEmail;
	var msgLegge;
	var msgData;
	switch(lingua){
		default:
			msgNome='Devi inserire il nome';
			msgCognome='Devi inserire il cognome';
			msgEmail='Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx';
			msgLegge='Non avete dato il consenso alla Legge 196/2003';
			msgData='Devi inserire una data corretta\nFormato: gg/mm/aaaa';
		break;
	}//end switch

	with(document.forms[0]){

		// Nome
		if(frm_nome.value==''){
			alert(msgNome);
			frm_nome.focus();
			return;
		}//fine if

		// Cognome
		if(frm_cognome.value==''){
			alert(msgCognome);
			frm_cognome.focus();
			return;
		}//fine if

		// Data nascita
		if(!VerificaData(frm_nasc_data.value)){
			alert(msgData);
			frm_nasc_data.focus();
			return;
		}//fine if

		// Mail
		if (frm_email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(msgEmail);
			frm_email.focus();
			return;
		}//fine if

		// Legge
		if(!frm_legge.checked && lingua == 1 ){
			alert(msgLegge);
			frm_legge.focus();
			return;
		}// fine if

		frm_op.value = 'ok';
		submit();

	}// fine with
}// fine if


/* ----------------------------- */
/* DETTAGLIO PER PHOTOGALLERY */
function apriDettaglio(id){
	var pagina = 'gallery.php?pgSeriale=' + id;
	var larghezza = 580;
	var altezza = 450;
	var x = (screen.width -larghezza)/2;
	var y = (screen.height - altezza)/2;
	var finestra = window.open(pagina, 'ingrandimento', 'width=' + larghezza +',height=' + altezza + ',toolbar=no,directories=no,location=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,resizable=yes');
	finestra.moveTo(x,y);
	finestra.focus();
}// fine funzione

/* ----------------------------- */
function newsletter(lingua){
	switch(lingua){
		case 3:
			msgNome='Sie m\u00FCssen den Namen einsetzen!';
			msgCognome='Sie m\u00FCssen den letzten Namen einsetzen!';
			msgEmail="Sie m\u00FCssen Adressen-email in der korrekten Form einsetzen: nome@dominio.xx!";
			msgTema='Sie m\u00FCssen eine thema einsetzen!';
			msgLegge="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
		break;
		case 2:
			msgNome='Insert the name!';
			msgCognome='Insert the surname!';
			msgEmail="E-mail format not correct\nFormat: name@dom.xx!";
			msgTema='Choose at least one theme!';
			msgLegge="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
		break;
		case 1:
		default:
			msgNome='Devi inserire il nome!';
			msgCognome='Devi inserire il cognome!';
			msgEmail="Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx!";
			msgTema='Devi scegliere almeno un tema!';
			msgLegge="Non avete dato il consenso alla Legge 196/2003";
		break;
	}//end switch


	with(document.forms[0]){
		// Nome
		frm_nome.value = frm_nome.value.trim();
		if(frm_nome.value==''){
			alert(msgNome);
			frm_nome.focus();
			frm_nome.select();
			return;
		}//fine if

		// Cognome
		frm_cognome.value = frm_cognome.value.trim();
		if(frm_cognome.value==''){
			alert(msgCognome);
			frm_cognome.focus();
			frm_cognome.select();
			return;
		}//fine if

		// Mail
		frm_email.value = frm_email.value.trim();
		if (frm_email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(msgEmail);
			frm_email.focus();
			frm_email.select();
			return;
		}//fine if




		//CONTROLLO SE E CHECCATA UN TEMA
		//faccio un controllo se esiste un campo area
		//se esiste deve essere checcato almeno uno
		//se non esiste dovrebbe esserci il campo h_Area e quindi si iscrive a quell'unica newsletter
		if(eval('document.forms[0].frm_tema') == undefined){

		}else{
			// TEMA
			var flag = false;
			var espressione = new RegExp("^frm_tema.+$");

			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox' && espressione.test(elements[i].name) && elements[i].checked){
					flag = true;
				}//fine if
			}// fine for
			if(flag == false){
				alert(msgTema);
				return;
			}//fine if
		}//end if

		// Legge
		//if(lingua == 1 ){
			if(!frm_legge.checked){
				alert(msgLegge);
				frm_legge.focus();
				return;
			}// fine if
		//}// fine if

		frm_op.value = 'ok';
		submit();
	}// fine with
}// fine funzione

/* ----------------------------- */
function NewMsgGuestbook(linguaSito) {
	switch(linguaSito){
		case 3:
		case 2:
			msgNome='Insert the name!';
			msgCognome='Insert the surname!';
			msgEmail="E-mail format not correct\nFormat: name@dom.xx!";
			msgTesto='Insert a text message!';
			msgLegge="You have to allow the treatment of personal data on the basis of the legal Act 196/2003.";
		break;
		default:
			msgNome='Devi inserire il nome!';
			msgCognome='Devi inserire il cognome!';
			msgEmail="Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx!";
			msgTesto='Devi inserire un testo!';
			msgLegge="Non avete dato il consenso alla Legge 196/2003";
		break;
	}//end switch

	with(document.forms['Contattaci']){
		// Nome
		Nome.value = Nome.value.trim();
		if(Nome.value==''){
			alert(msgNome);
			Nome.focus();
			Nome.select();
			return;
		}//fine if

		// Cognome
		Cognome.value = Cognome.value.trim();
		if(Cognome.value==''){
			alert(msgCognome);
			Cognome.focus();
			Cognome.select();
			return;
		}//fine if

		// Mail
		Email.value = Email.value.trim();
		if (Email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(msgEmail);
			Email.focus();
			Email.select();
			return;
		}//fine if

		// MESSAGGIO
		Messaggio.value = Messaggio.value.trim();
		if(Messaggio.value==''){
			alert(msgTesto);
			Messaggio.focus();
			Messaggio.select();
			return;
		}//fine if

		// Legge
		//		if(lingua == 1 ){
		if(!check.checked){
			alert(msgLegge);
			check.focus();
			return;
		}// fine if
		//}// fine if


//        if (!VerificaCampi(document.forms[0], "Nome:Cognome:Email:Titolo:Messaggio:check")){
//            return;
//        }
		COMANDO.value="salva";
     	submit();
    }//end with
}// end function

/* ----------------------------- */
function amicoML(lingua){
	switch(linguaSito){
		case 3:
		case 2:
			msgNome='Insert your name!';
			msgEmail="E-mail format not correct\nFormat: name@dom.xx!";
		break;
		default:
			msgNome='Devi inserire il tuo nome!';
			msgEmail="Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx!";
		break;
	}//end switch

	with(document.forms[0]){
		// Nome
		frm_nome.value = frm_nome.value.trim();
		if(frm_nome.value==''){
			alert(msgNome);
			frm_nome.focus();
			frm_nome.select();
			return;
		}//fine if

		var emailReg = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$");

		// Mail TUA
		frm_email.value = frm_email.value.trim();
		if (!emailReg.test(frm_email.value)) {
			alert(msgEmail);
			frm_email.focus();
			frm_email.select();
			return;
		}//fine if

		// Mail PRIMO AMICO
		frm_amico_0.value = frm_amico_0.value.trim();
		if (!emailReg.test(frm_amico_0.value)) {
			alert(msgEmail);
			frm_amico_0.focus();
			frm_amico_0.select();
			return;
		}//fine if


		// Email ALTRI amici
		var espressione = new RegExp("^frm_amico_[1-9]+$");

		var boolMail = false;

		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == 'text' && espressione.test(elements[i].name)){

				elements[i].value = elements[i].value.trim();

				if(elements[i].value!=''){

					boolMail = emailReg.test(elements[i].value)

					if (!boolMail) {
						alert(msgEmail);
						elements[i].focus();
						elements[i].select();
						return;
					}//fine if
				}// fine if

			}//fine if
		}// fine for

		frm_op.value = 'ok';
		submit();
	}// fine with
}// fine funzione

/* ----------------------------- */
function bacheca(comando, seriale, lingua){
	with(document.forms[0]){
		//for(i=0;i< elements.length;i++){alert(i + " - " + elements[i].name + " - " + elements[i].value + " - " + elements[i].checked);}
		COMANDO.value = comando;
		switch(comando){
			case 'scheda':
			SERIALE.value = seriale;
			break;
		}//end switch
		submit();
	}// fine with
}// fine funzione

/* ----------------------------- */
/* -- NON UTILIZZATA 20070525 -- */
function apriFinestraParam(name, larghezza, altezza, parametri){
	var x = (screen.width - larghezza)/2;
	var y = (screen.height - altezza)/2;
	var finestra = window.open(name, 'ingrandimento', 'width=' + larghezza +',height=' + altezza + ', ' + parametri);
	finestra.moveTo(x,y);
	finestra.focus();
}// fine funzione

/* ----------------------------- */

/* -- MENU QUICKLINK -- */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
/* ----------------------------- */

function mod_display(id){
//	alert(id);

	with(document.forms[0]){
		/*
		var elemento;
		if(document.getElementById)
			elemento = document.getElementById("submenudocs");
		else
			elemento = document.all["submenudocs"];
	    elemento.innerHTML = "ciao";
		*/
	  	// alert(id);
		//    loader=document.createElement("img");
		//    loader.setAttribute("src","./imm_struttura/gira.gif");
		//    elemento.appendChild(loader);
/*
$(document).ready(function(){
	$(".submenuguide").click(function(){
		$("#submenu").slideToggle("slow");
	});


});
*/
	}//end with
}



/* ----------------------------- */
/* ----------------------------- */
function cerca(lingua, nome_form){
	switch(lingua){
		case 3:
		case 2:
			msg_field='Insert a string!';
		break;
		default:
			msg_field='Inserire una stringa!';
		break;
	}//end switch

	with(document.forms[nome_form]){
		if(cercaText.value.length<=2){
			alert(msg_field);
			cercaText.focus();
			return;
		}//fine if
		submit();
	}// fine with
}// fine funzione


/* ----------------------------- */
/* ----------------------------- */
function intval($int) {
	return parseInt($int);
}


