function MM_reloadPage(init) 
{  //reloads the window if Nav4 resized
      if (init==true) with (navigator) 
      {
       if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
       {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
       }
      }
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
      location.reload();
}
    MM_reloadPage(true);

function cambia(ImageName,ImageFile)
{
 ImageName.src = ImageFile;
}


function cambiaVideo (video,nomeVideo)
{
 var stringa = "";
 stringa+="<center><object width='427' height='348'><param name='movie' value='http://www.youtube.com/v/"+video+"&autoplay=1'></param>";
 stringa+="<embed src='http://www.youtube.com/v/"+video+"&autoplay=1' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></center>";
 document.getElementById('titoloVideo').innerHTML = nomeVideo;
 document.getElementById('mostraVideo').innerHTML = stringa;
}


function schedaOperatore (id)
{
  var larghezza = 600;
  var altezza = 300;
  var w = screen.width;
  var h = screen.height;
  var x = Math.round(w / 2) - Math.round(larghezza / 2);
  var y = Math.round(h / 2) - Math.round(altezza / 2);

  var windowprops = "width=600, height=300, left = "+x+", screenX = "+x+", top = "+y+", screenY = "+y+", scrollbars=no, menubar = no, status=no,resizable=no,location=no";
  popup = window.open("visualizzaScheda.php?id="+id,'remote',windowprops);

}



function expandingWindow(website) 
{
  var windowprops='width=1,height=1,scrollbars=no,status=no,resizable=no,location=no'
  var heightspeed = 8; 
  var widthspeed = 8; 
  var leftdist = 0;   
  var topdist = 0; 
  var lunghezza = window.screen.width;
  var altezza = window.screen.height;
  
  if(lunghezza == 0){
  lunghezza = window.screen.availWidth;
      }
  if(altezza == 0){
  altezza = window.screen.availHeight;
  }
  
  if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
  var winwidth = lunghezza;
  var winheight = altezza;
  var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);
  for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
  sizer.resizeTo("1", sizeheight);
  for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
  sizer.resizeTo(sizewidth, sizeheight);
  sizer.location = website;
  }
  else
  window.open(website,'Gallery');
}

function emailFalsa (email)
{
 contPunti = 0;
 contChiocciole = 0;
 for (i=0; i<email.length; i++)
 {
  if (email.charAt(i) == '@') contChiocciole++;
  if (email.charAt(i) == '.') contPunti++;
 }
 if (contChiocciole == 0 || contChiocciole > 1 || contPunti == 0) // email falsa
 return true;
 else return false;
}

function etaFalsa (eta)
{
 if (!isNaN(eta))
  {
   if (eta < 1 || eta > 99)
    return true;
   else
    return false;  
  }
 else
  return true;
}


function controlloProva()
{
 with(document.arruolarsi)
 {
   if(cognome.value == "" || cognome.value == "undefined" || cognome.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo COGNOME");
     cognome.focus();
     return false;
   }
   if(nome.value == "" || nome.value == "undefined" || nome.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo NOME");
     nome.focus();
     return false;
   }

   if(eta.value == "" || eta.value == "undefined" || eta.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo ETA'");
     eta.focus();
     return false;
   }

   if(citta.value == "" || citta.value == "undefined" || citta.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo CITTA'");
     citta.focus();
     return false;
   }
   if(email.value == "" || email.value == "undefined" || email.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo E-MAIL");
     email.focus();
     return false;
   }
   if(numero.value == "" || numero.value == "undefined" || numero.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo NUMERO DI TELEFONO");
     numero.focus();
     return false;
   }
   
   if(emailFalsa(email.value))
   {
     alert("Errore: Hai inserito un'email non valida");
     email.focus();
     return false;
   }

   
   if(etaFalsa(eta.value))
   {
     alert("Errore: inserire una ETA' corretta");
     eta.focus();
     return false;
   }
 }
 return true;
} 

function controlloContattaci()
{
 with(document.form_contattaci)
 {
   if(cognome.value == "" || cognome.value == "undefined" || cognome.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo COGNOME");
     cognome.focus();
     return false;
   }
   if(nome.value == "" || nome.value == "undefined" || nome.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo NOME");
     nome.focus();
     return false;
   }

   if(email.value == "" || email.value == "undefined" || email.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo E-MAIL");
     email.focus();
     return false;
   }

   if(messaggio.value == "" || messaggio.value == "undefined" || messaggio.value.charAt(0) == " ")
   {
     alert("Errore: compilare il campo MESSAGGIO");
     messaggio.focus();
     return false;
   }
   
   if(emailFalsa(email.value))
   {
     alert("Errore: Hai inserito un'email non valida");
     email.focus();
     return false;
   }

 }
 return true;
} 


