/**
 * function open/close elements 
 */
function _openClose(obj) {
	if (document.getElementById(obj).style.visibility != 'hidden') {
		document.getElementById(obj).style.visibility = 'hidden';
		document.getElementById(obj).style.display = 'none';
	} else {
		document.getElementById(obj).style.visibility = 'visible';
		document.getElementById(obj).style.display = 'block';
	}
}

/* function OPEN POPUP */
function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);
  return false;
}


/** function validateform **/
function formCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
			return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   return false
}
if (len<2) {
   return false
}
return true;
}

function inserisci() {

/*	if (document.workshop.accettazione[0].checked) {
		
		 if((document.workshop.societa.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire Azienda/Ente. Grazie.");
		 return false;} 
		 
    if((document.workshop.settore.value == "settore_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Scegliere il settore. Grazie.");
		 return false;
    } 

    if (document.workshop.email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
		 if((document.workshop.email.value != "") && (!formCheck(document.workshop.email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }

		 if((document.workshop.indirizzo.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire indirizzo. Grazie.");
		 return false;} 

		 if((document.workshop.citta.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la cittą. Grazie.");
		 return false;} 

		 if((document.workshop.prov.value == "prov_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la provincia. Grazie.");
		 return false;} 
	
		 if((document.workshop.tel.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il telefono. Grazie.");
		 return false;} 


		 if((document.workshop.cognome1.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il cognome. Grazie.");
		 return false;
		 } 
		 
		 if((document.workshop.nome1.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il nome. Grazie.");
		 return false;
     
     if (document.workshop.email_partecipante1.value == "" ) {
		 alert("Inserire indirizzo e-mail del partecipante.");
		 return false;
		 }
		 if((document.workshop.email_partecipante1.value != "") && (!formCheck(document.workshop.email_partecipante1.value))){
		 alert("Inserire un indirizzo e-mail del partecipante valido.");
		 return false;
		 }
     
  } 
	*/	 
     document.inserisci.action = "/script/inserisci_database.php";
		 document.inserisci.submit;
/*		} else {
    alert("Per procedere, confermare l'accettazione al trattamento dei dati personali. Grazie.");
    return false;
    }
*/
	}



/* FORM per segnalazione EVENTI INTERNAZIONALI */ 

function controlform() {
/*
if (document.formdati.accettazione[0].checked) {
		if((document.formdati.cognomenome.value == "")&&(document.formdati.accettazione[0].checked)) {
		alert("Inserire un nominativo. Grazie.");
		return false;} 

		if((document.formdati.societa.value == "")&&(document.formdati.accettazione[0].checked)) {
		alert("Inserire Denominazione Societ&agrave;. Grazie.");
		return false;} 
		
		if((document.formdati.indirizzo.value == "")&&(document.formdati.accettazione[0].checked)) {
		alert("Inserire l'indirizzo. Grazie.");
		return false;} 
		
		if((document.formdati.citta.value == "")&&(document.formdati.accettazione[0].checked)) {
		alert("Inserire la citta'. Grazie.");
		return false;} 

		if((document.formdati.provincia.value == "provincia_non_selezionata")&&(document.formdati.accettazione[0].checked)) {
		alert("Scegliere una provincia. Grazie.");
		return false;} 

		if (document.formdati.email.value == "" ) 			{
				alert("Inserire l'indirizzo e-mail.");
				return false;
			}
    if((document.formdati.email.value != "") && (!formCheck(document.formdati.email.value)))		{
				alert("Inserire un indirizzo e-mail valido.");
				return false;
			}


		if((document.formdati.settore.value == "settore_non_selezionato")&&(document.formdati.accettazione[0].checked)) {
		alert("Scegliere un settore di attivitą. Grazie.");
		return false;
    } 
		
		document.formdati.action = "../script/invio_form_eventi_int.php";
		document.formdati.submit;
		} else {
    alert("Per procedere, confermare l'accettazione della Privacy . Grazie.");
    return false;
    }
*/
	}


/* FORM per segnalazione LBW PROPOSTE COMMERCIALI */ 

function controlformlbw() {
	if (document.LBW_form.accettazione[0].checked) {
		
		 if((document.LBW_form.societa.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire Denominazione Societ&agrave;. Grazie.");
		 return false;} 
		
		 if((document.LBW_form.indirizzo.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire indirizzo. Grazie.");
		 return false;} 
		
		 if((document.LBW_form.citta.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire la citta'. Grazie.");
		 return false;} 
		 
		 if((document.LBW_form.paese.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire il paese'. Grazie.");
		 return false;} 

	     if (document.LBW_form.email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
    	 if((document.LBW_form.email.value != "") && (!formCheck(document.LBW_form.email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }
			
		 if((document.LBW_form.settore.value == "settore_non_selezionato")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Scegliere un settore di attivitą. Grazie.");
		 return false;
         } 
	
	     if((document.LBW_form.prodottiservizi.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire descrizione prodotti e servizi. Grazie.");
		 return false;
		 } 

	     if((document.LBW_form.cognomenome.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Inserire un nominativo. Grazie.");
		 return false;
		 } 

	     if((document.LBW_form.tipo_cooperazione.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Scegliere il tipo di cooperazione. Grazie.");
		 return false;
		 } 

	     if((document.LBW_form.desc_cooperazione.value == "")&&(document.LBW_form.accettazione[0].checked)) {
		 alert("Descrivere la cooperazione ricercata. Grazie.");
		 return false;
		 } 

		 document.LBW_form.action = "../script/mail_lbw.php";
		 document.LBW_form.submit;
		} else {
    alert("Per procedere, confermare l'accettazione della Privacy. Grazie.");
    return false;
    }

	}

/* FORM per adesione caffe internazionalizzazione 2010 */ 

function controlform_caffe2010() {

	if (document.caffe2010.accettazione[0].checked) {
		
		 if((document.caffe2010.cognome.value == "")&&(document.caffe2010.accettazione[0].checked)) {
		 alert("Inserire il cognome. Grazie.");
		 return false;
		 } 
		 if((document.caffe2010.nome.value == "")&&(document.caffe2010.accettazione[0].checked)) {
		 alert("Inserire il nome. Grazie.");
		 return false;
		 } 
		 
		 if((document.caffe2010.societa.value == "")&&(document.caffe2010.accettazione[0].checked)) {
		 alert("Inserire Azienda/Ente. Grazie.");
		 return false;} 
    
     if((document.caffe2010.settore.value == "settore_non_selezionato")&&(document.caffe2010.accettazione[0].checked)) {
		 alert("Scegliere il settore. Grazie.");
		 return false;
     } 
     
     if (document.caffe2010.email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
     if((document.caffe2010.email.value != "") && (!formCheck(document.caffe2010.email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }

//  if (document.caffe2010.accettazione[1].checked) {


    //  if( (!document.caffe2010.catalogo[0].checked) && (!document.caffe2010.catalogo[1].checked) && (document.caffe2010.accettazione[0].checked))  {
    //   if( (!document.caffe2010.catalogo[].checked) && (!document.caffe2010.catalogo[0].checked) && (!document.caffe2010.catalogo[1].checked) && (document.caffe2010.accettazione[0].checked))  {
    
    
      if (( document.caffe2010.catalogo[0].checked == false ) &&	( document.caffe2010.catalogo[1].checked == false ) ) { 
	      alert("Scegliere se pubblicare i dati inseriti nel catalogo. Grazie.");
        return false;
      } 
      
    document.caffe2010.action = "/script/mail_adesione_caffe2010.php";
    document.caffe2010.submit; 

    } else {
      alert("Per procedere, confermare l'accettazione al trattamento dei dati personali. Grazie.");
     return false;
  }
}


/* FORM per ISCRIZIONE WORKSHOP INTFORMATEVI 2010 */ 

function controlform_workshop() {
/*
	if (document.workshop.accettazione[0].checked) {
		
		 if((document.workshop.societa.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire Azienda/Ente. Grazie.");
		 return false;} 
		 
    if((document.workshop.settore.value == "settore_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Scegliere il settore. Grazie.");
		 return false;
    } 

    if (document.workshop.email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
		 if((document.workshop.email.value != "") && (!formCheck(document.workshop.email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }

		 if((document.workshop.indirizzo.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire indirizzo. Grazie.");
		 return false;} 

		 if((document.workshop.citta.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la cittą. Grazie.");
		 return false;} 

		 if((document.workshop.prov.value == "prov_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la provincia. Grazie.");
		 return false;} 
	
		 if((document.workshop.tel.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il telefono. Grazie.");
		 return false;} 


		 if((document.workshop.cognome1.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il cognome. Grazie.");
		 return false;
		 } 
		 
		 if((document.workshop.nome1.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il nome. Grazie.");
		 return false;
     
     if (document.workshop.email_partecipante1.value == "" ) {
		 alert("Inserire indirizzo e-mail del partecipante.");
		 return false;
		 }
		 if((document.workshop.email_partecipante1.value != "") && (!formCheck(document.workshop.email_partecipante1.value))){
		 alert("Inserire un indirizzo e-mail del partecipante valido.");
		 return false;
		 }
     
  } 
		 
     document.workshop.action = "/script/iscrizione_workshop2010.php";
		 document.workshop.submit;
		} else {
    alert("Per procedere, confermare l'accettazione al trattamento dei dati personali. Grazie.");
    return false;
    }
*/
	}

/* FORM per ISCRIZIONE CORSO TUSCIA 2010 */ 

function controlform_workshop_tuscia() {

	if (document.workshop.accettazione[0].checked) {
		
		 if((document.workshop.societa.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire Azienda/Ente. Grazie.");
		 return false;
     } 
		 
    if((document.workshop.settore.value == "settore_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Scegliere il settore. Grazie.");
		 return false;
    } 

    if (document.workshop.email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
		 if((document.workshop.email.value != "") && (!formCheck(document.workshop.email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }

		 if((document.workshop.indirizzo.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire indirizzo. Grazie.");
		 return false;} 

		 if((document.workshop.citta.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la cittą. Grazie.");
		 return false;} 

		 if((document.workshop.prov.value == "prov_non_selezionato")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire la provincia. Grazie.");
		 return false;} 
	
		 if((document.workshop.tel.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il telefono. Grazie.");
		 return false;} 


		 if((document.workshop.cognome.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il cognome del partecipante. Grazie.");
		 return false;
     } 
		 
		 if((document.workshop.nome.value == "")&&(document.workshop.accettazione[0].checked)) {
		 alert("Inserire il nome del partecipante. Grazie.");
		 return false;
     } 
     
     if (document.workshop.email_partecipante.value == "" ) {
		 alert("Inserire indirizzo e-mail del partecipante.");
		 return false;
		 }
		 if((document.workshop.email_partecipante.value != "") && (!formCheck(document.workshop.email_partecipante.value))){
		 alert("Inserire un indirizzo e-mail del partecipante valido.");
		 return false;
		 }

     if (( document.workshop.orario[0].checked == false ) &&	( document.workshop.orario[1].checked == false ) ) { 
	   alert("Esprimere una preferenza per orario del corso. Grazie.");
     return false;
     } 
		 
     document.workshop.action = "/script/iscrizione_workshop_tuscia2010.php";
		 document.workshop.submit;
		} else {
    alert("Per procedere, confermare l'accettazione al trattamento dei dati personali. Grazie.");
    return false;
    }

	}



/* FORM SERVIZI CCIS 2010-2011 */ 

function controlform_ccis() {

	if (document.ccis.accettazione[0].checked) {
		
		 if((document.ccis.Cognome.value == "")&&(document.ccis.accettazione[0].checked)) {
		 alert("Inserire il cognome. Grazie.");
		 return false;
		 } 
		 if((document.ccis.Nome.value == "")&&(document.ccis.accettazione[0].checked)) {
		 alert("Inserire il nome. Grazie.");
		 return false;
		 } 
		 
		 if((document.ccis.Societa.value == "")&&(document.ccis.accettazione[0].checked)) {
		 alert("Inserire Denominazione Impresa. Grazie.");
		 return false;
     } 
		    
     if((document.ccis.Settore.value == "settore_non_selezionato")&&(document.ccis.accettazione[0].checked)) {
		 alert("Scegliere il settore. Grazie.");
		 return false;
     } 

		 if((document.ccis.Provincia.value == "prov_non_selezionato")&&(document.ccis.accettazione[0].checked)) {
		 alert("Inserire la provincia. Grazie.");
		 return false;
     } 

		 if((document.ccis.Telefono.value == "")&&(document.ccis.accettazione[0].checked)) {
		 alert("Inserire il telefono. Grazie.");
		 return false;
     } 
     
	   if (document.ccis.Email.value == "" ) {
		 alert("Inserire indirizzo e-mail.");
		 return false;
		 }
     
     if((document.ccis.Email.value != "") && (!formCheck(document.ccis.Email.value))){
		 alert("Inserire un indirizzo e-mail valido.");
		 return false;
		 }
    if((document.ccis.RichiestaServizi.value == "")&&(document.ccis.accettazione[0].checked)) {
		 alert("Indicare brevemente i servizi richiesti. Grazie.");
		 return false;
     } 

		 //document.ccis.action = "../script/mail_adesione_150410.php";
     document.ccis.action = "/script/mail_servizi_CCIS.php";
		 document.ccis.submit;
		} else {
    alert("Per procedere, confermare l'accettazione della Privacy. Grazie.");
    return false;
    }

	}


/* FORM per segnalazione PHARMA FINANCE 2009 */ 
/*
function controlpf09() {
if (document.formdatipf09.dati[0].checked) {
		if((document.formdatipf09.cognomenome.value == "")&&(document.formdatipf09.dati[0].checked)) {
		alert("Inserire un nominativo. Grazie.");
		return false;} 

		if((document.formdatipf09.societa.value == "")&&(document.formdatipf09.dati[0].checked)) {
		alert("Inserire Denominazione Societą. Grazie.");
		return false;} 

		if (document.formdatipf09.email.value == "" ) {
				alert("Inserire l'indirizzo e-mail.");
				return false;
			}
    if((document.formdatipf09.email.value != "") && (!formCheck(document.formdatipf09.email.value)))	{
		alert("Inserire un indirizzo e-mail valido.");
		return false;
		}
		document.formdatipf09.action = "/script/invio_form_pf09.php";
		document.formdatipf09.submit;
		} else {
    alert("Per procedere, confermare l'accettazione al trattamento dei dati personali. Grazie.");
    return false;
    }

	}
*/


/** function newsletter **/
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
			return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   return false
}
if (len<2) {
   return false
}
return true;
}
	function controllonl() {
		if((document.lettermanMod.attribute1.value == "")&&(document.lettermanMod.task[0].checked)) {
		alert("Inserisci un nome di sottoscrizione. Grazie.");
		return false;} 
		
		if (document.lettermanMod.email.value == "" ) 
			{
				alert("Inserire l'indirizzo e-mail.");
				return false;
			}
       if((document.lettermanMod.email.value != "") && (!emailCheck(document.lettermanMod.email.value)))
			{
				alert("Inserire un indirizzo e-mail valido.");
				document.lettermanMod.email.value="";
				return false;
			}
		
		if (document.lettermanMod.task[0].checked) {
		document.lettermanMod.emailconfirm.value=document.lettermanMod.email.value;
		document.lettermanMod.action = "/lists/?p=subscribe&id=1";
		aprifinestra(640,480);
		document.lettermanMod.target='form_target';
		document.lettermanMod.submit;
		} else {
		document.lettermanMod.unsubscribeemail.value = document.lettermanMod.email.value;
		document.lettermanMod.action = "/lists/?p=unsubscribe&id=1";
		aprifinestra(640,480);
		document.lettermanMod.target='form_target';
		document.lettermanMod.submit;
		}
			
	}
  
  function aprifinestra(w,h){
	  width= screen.width;
	  height= screen.height;
	  left=(width-w)/2;
	  top=(height-h)/2;
	  window.open('','form_target','width='+w+',height='+h+',left='+left+',top='+top+'');
  }
 
