// esempio di chiamata della funzione per la visualizzazione di un 
// pop up contenente la pagina pagina.asp
//<a href="javascript:MM_openBrWindow('pagina.asp','nomepag','scrollbars=no,resizable=no,width=500,height=500')">

function MM_openBrWindow(theURL,winName,features) 
{ 
  newwindow=window.open(theURL,winName,features);
  newwindow.creator=self;
}

function controllo(nomeform){
 if (document[nomeform].mail.value==""){
    alert("Il campo 'Indirizzo e-mail' è obbligatorio.");
    return;
     }
     
 if ((document[nomeform].mail.value.indexOf(" ", 0)!=-1) ||
           (document[nomeform].mail.value.indexOf("@", 0)==-1) ||
           (document[nomeform].mail.value.indexOf(".", 0)==-1))
 {alert("Indirizzo mail errato!");
  return; 
  }
  
  document[nomeform].submit(); 
}

// Data una stringa la restituisce senza spazi a destra e a sinistra.
// Se la stringa è vuota o contiene solo spazi restituisce una stringa vuota.
function newTrim(stringa){
	if (stringa==""){
		return stringa;
	}
	tipostr = /\S{1,}[\S{0,}\s{0,}]*\S{1,}|\S{1}/
	arr = stringa.match(tipostr);
	if (arr==null){
		return ""
	}
	return arr[0];
}

function controllomail(mail){
	var tipoemail = /([a-zA-Z0-9_&èéòùìüâàåçÇêëïîÄÅÉæÆôöûÿÖÜøØ-]|\'|\+|\.)+@([a-zA-Z0-9_&èéòùìüâàåçÇêëïîÄÅÉæÆôöûÿÖÜøØ-]|\'|\+|\.)+(\.([a-zA-Z0-9_&àèéòùìüâàåçÇêëïîÄÅÉæÆôöûÿÖÜøØ-]|\+|\')+)+/;
	var arr = mail.match(tipoemail);
	if ((arr==null)||(arr[0]!=mail)){
			return false;
		}
		return true;	
}
