/**
 * 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;
}

/* 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 28 gennaio 2010 */ 

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

		 document.convegno280110.action = "../script/mail_adesione_100210.php";
		 document.convegno280110.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+'');
  }
 
