function popup(url, name, width, height)
{
if (screen) {
	LeftPos = (screen.width - width) / 2
	TopPos = (screen.height - height) / 2
}

settings="top="+TopPos+",left="+LeftPos+",fullscreen=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=no,width="+width+",height="+height;

MyNewWindow=window.open(url,name,settings);
}

//FINESTRA A DIMENSIONE AUTOMATICA PER IMMAGINI

function OpenPhoto(NomeImg,Alt){
  BigImg = new Image();
  BigImg.src = (NomeImg);
  Controlla(NomeImg,Alt);
}

function Controlla(NomeImg,Alt){
  if((BigImg.width!=0)&&(BigImg.height!=0)){
    viewFoto(NomeImg,Alt);
  }
  else{
    funzione="Controlla('"+NomeImg+"','"+Alt+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function viewFoto(img,Alt){
	wImg = BigImg.width
	hImg = BigImg.height
	ImgSrc = BigImg.src
	
	if (screen) {
		leftPos = (screen.width - wImg) /2
		topPos = (screen.height - hImg) /2
	}
	newWindow=window.open("","NewWin","width="+wImg+",height="+hImg+",left="+leftPos+",top="+topPos+",status=no,menubar=no,resizable=no,scrollbars=no");
	newWindow.resizeTo(wImg+10,hImg+79)
	newWindow.document.write("<HTML>")
	newWindow.document.write("<HEAD>")
	newWindow.document.write("<TITLE>Dettaglio</TITLE>")
	newWindow.document.write("<style>.MANINA{cursor:hand;}</style>")
	newWindow.document.write("</HEAD>")
	newWindow.document.write("<BODY onLoad='top.window.focus();' topmargin='0' leftmargin='0' bgproperties='fixed'>")
	newWindow.document.write("<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' WIDTH='100%' HEIGHT='100%'>")
	newWindow.document.write("<TR>")
	newWindow.document.write("<TD ALIGN='center' VALIGN='middle'>")
	newWindow.document.write("<IMG BORDER='0' NAME='MyImg' SRC='"+ImgSrc+"' Alt='"+Alt+"' onclick='javascript:parent.close()' class='manina'>")
	newWindow.document.write("</TD>")
	newWindow.document.write("</TR>")
	newWindow.document.write("</TABLE>")
	newWindow.document.write("</BODY>")
	newWindow.document.write("</HTML>")
	newWindow.document.close()
}

function checkMl(theForm){
	if (theForm.strEmail.value == "") {
		alert("Inserire una E-Mail per iscriversi alla mailing list");
		theForm.strEmail.focus();
		return (false);
	}
	if (!validEmail(theForm.strEmail.value)){
		alert("E-Mail non valida! Si prega di controllare!");
		theForm.strEmail.focus();
		return (false);	
	}
	return (true);
}
function popupSendML(url)
{
topPos = (screen.height - 100)/2
leftPos = (screen.width - 200)/2

settings="top="+topPos+",left="+leftPos+",fullscreen=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=no,"+
"resizable=no,width=200,height=100";

MyNewWindow=window.open(url,'IscrivitiML',settings);
}

function validEmail(email){
	invalidChars = " /:,;"
	
	if (email == "") {
		return (false); 	
	}

	for (i=0; invalidChars.lenght; i++) {
		badChar = invalidChars.chartAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return (false);
		}	
	}

	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return (false);
	}

	if (email.indexOf("@",atPos+1) > -1) {
		return (false);
	}

	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return (false);
	}

	if (periodPos+3 > email.lenght){
		return (false);
	}
	
	return (true);
}

