//aprire una finestra centrata nello schermo
function apriFinestra(url, myname, w, h, prop, res) {
 	var winl = (screen.width - w) / 2;
 	var wint = (screen.height - h) / 2;
 	winprops = "scrollbars="+prop+",height="+h+",width="+w+",top="+wint+",left="+winl+",resizable="+res+",status=yes,menubar=no,toolbar=no";
	var win;
 	win = window.open(url, myname, winprops);
 if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//apre finestra centrata con la foto grande
function apriZoom(theURL,winName,width,height,features) { //v3.1
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
    newWindow.focus();
}


function controllaForm(nomeform){
	var F=eval("document."+nomeform);
	var ok=true;
	var jmail=F.email;
	var jnome=F.nominativo;
	var jmex=F.mex;
	var jaccetto=F.accetto;
	var MYregexp =/^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+[.][A-Za-z]{2,6}$/;

	if(ok && jnome.value==""){alert("Inserire il nome ed il cognome");jnome.focus();ok=false;}
	if(ok && (MYregexp.test(jmail.value)==false)){alert("Inserire un indirizzo di posta valido");jmail.focus();ok=false;}
	if(ok && jmex.value==""){alert("Inserire il testo del messaggio");jmex.focus();ok=false;}
	
	if(ok && jaccetto.checked==false){alert("Per inviare il modulo e' necessario accettare la clausola di trattamento dei dati privati");jaccetto.focus();ok=false;}
	if(ok){ 
		return true;
	}else{
		return false;
	}
		
}

function stampapagina(theURL,winName){
	newWindow=window.open(''+ theURL + '',''+ winName + '','width=500,height=420,top=0,left=0,resizable=yes,status=yes,menubar=no,toolbar=no,scrollbars=yes');
  newWindow.print();
}
