// JavaScript Document

//effetti rollover
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//aperture finestre
function finestra (img,title) { 
   var w = 600;
   var h = 400;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   
   Fin=open('','fines','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,screenX=300,screenY=200,width='+w+',height='+h+',left='+l+',top='+t+''); 
   
   Fin.document.open(); 
   Fin.document.write("<HTML><HEAD><title>"); 
   Fin.document.write(title); 
   Fin.document.write("</title></HEAD><BODY TOPMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0' BOTTOMMARGIN='0' BGCOLOR='#e3f4fe'>"); 
   Fin.document.write("<img src=img/photos/"+img+" onclick=window.close() style=cursor:hand title='Chiudi/Close'>"); 
   Fin.document.write("</BODY></HTML>");
   Fin.document.close(); 
   Fin.focus();
   }
   
//controllo campi   
function checkFields() {
missinginfo = "";
if (document.form.Nome.value == "") {
missinginfo += "\n     -  Nome";
document.form.Nome.focus();
}
else if (document.form.Cognome.value == "") {
missinginfo += "\n     -  Cognome";
document.form.Cognome.focus();
}
else if (document.form.Telefono.value == "" || isNaN(document.form.Telefono.value)) {
alert('Attenzione. Il campo telefono è vuoto o non è un numero');
document.form.Telefono.value = "";
document.form.Telefono.focus();
return false;
}
else if ((document.form.Email.value == "") || 
(document.form.Email.value.indexOf('@') == -1) || 
(document.form.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email";
document.form.Email.focus();
}
else if(document.form.Privacy.checked == 0) {
missinginfo += "\n     -  Acconsento al trattamento dei dati personali...";
}

if (missinginfo != "") {
missinginfo ="______________________________________\n" +
"Attenzione. Non hai compilato il campo: \n" +
missinginfo + "\n__________________________________" +
"\nInserisci le informazioni richieste e spedisci!";
alert(missinginfo);
return false;
}
else return true;
}

function checkFields2() {
missinginfo = "";
if (document.form.Nome.value == "") {
missinginfo += "\n     -  Name";
}
else if ((document.form.Email.value == "") || 
(document.form.Email.value.indexOf('@') == -1) || 
(document.form.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email";
}
else if(document.form.Privacy.checked == 0) {
missinginfo += "\n     -  I authorize the treatment of the personal data...";
}

if (missinginfo != "") {
missinginfo ="______________________________________\n" +
"Alt! You didn't fill out the field: \n" +
missinginfo + "\n__________________________________" +
"\nInsert the required information and submit this form!";
alert(missinginfo);
return false;
}
else return true;
}


//controllo campi IN INGLESE  
function checkFields_eng() {
missinginfo = "";
if (document.form.Nome.value == "") {
missinginfo += "\n     -  Name";
document.form.Nome.focus();
}
else if (document.form.Cognome.value == "") {
missinginfo += "\n     -  Surname";
document.form.Cognome.focus();
}
else if (document.form.Telefono.value == "" || isNaN(document.form.Telefono.value)) {
alert('Notice. the phone field is empty or It is not a number');
document.form.Telefono.value = "";
document.form.Telefono.focus();
return false;
}
else if ((document.form.Email.value == "") || 
(document.form.Email.value.indexOf('@') == -1) || 
(document.form.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email";
document.form.Email.focus();
}
else if(document.form.Privacy.checked == 0) {
missinginfo += "\n     -  I consent to the treatment of the personal data...";
}

if (missinginfo != "") {
missinginfo ="______________________________________\n" +
"Notice. You didn't fill the field one: \n" +
missinginfo + "\n__________________________________" +
"\nPlease, insert the correct information and send the form contact!";
alert(missinginfo);
return false;
}
else return true;
}

