function loadimage(nameimage){  
     document.images["boxfoto"].src = nameimage;  
}  

function verifica_login(form, element1, element2){
var login = eval('form.' + element1);
var password = eval('form.' + element2);
if ((login.value=="") || (password.value=="")){
 alert("ATTENZIONE: Occorre che il campo non sia vuoto!!!");}
else{
 form.submit();
 }
}

function verifica_semplice_textbox(form, element){
var elemento = eval('form.' + element);
if (elemento.value==""){
 alert("ATTENZIONE: Occorre che il campo non sia vuoto!!!");}
else{
 form.submit();
 }
}

function verifica_richiesta_info(form){
if (checkemail(form.txtemail.value)) {
 if (((form.txtnomecognome.value=="") || (form.txttelefono.value=="") || (form.txtemailvalue=="") || (form.txtrichiesta.value==""))){
  alert("ATTENZIONE: Occorre riempire tutti i campi !!!");}
 else{
  form.submit();
 }
 }
}

function verifica_popup_email(form){
if (checkemail(form.txt_email.value)) {
 if ((form.txt_nome_mittente.value=="") || (form.txt_nome_destinatario.value=="") || (form.txt_email.value=="")){
  alert("ATTENZIONE: Occorre riempire tutti i campi per inviare l'email");}
 else{
  form.submit();
 }
 }
}

function checkemail(emailAddress) {
 emailAddress=emailAddress
 if (emailAddress.indexOf ('@',0) == -1 || emailAddress.indexOf ('.',0) == -1) {
  alert("\nL' E-mail deve contenere \"@\" e uno o pił \".\"")
  return false;
 }
 else
 {
 return true;
 }
}

function apri_finestra(percorso,modalita){
switch (modalita){
 case 1 : //popup opzioni email
	window.open(percorso,"email","width=420,height=410,scrollbars=0,status=0");
	break;
 case 2 : //popup stampa
	window.open(percorso,"stampa","width=450,height=410,scrollbars=1,status=0");
	break;
case 3 : //popup mappa
	window.open(percorso,"","width=829,height=676,scrollbars=0,status=0");
	break;
 }
}

function populate(aValue) {
 //------- Select di destino
 var destino  = document.getElementById('vetture');
 if (aValue == "-") {
  //-------- Se ho tolto la selezione sul marchio
  document.getElementById('vetture').value     = '-';
  document.getElementById('vetture').className = "hidden";
	elimina(destino);
  return;
 } // if (aValue == "-") 
  //------- Select di partenza 
 var marchio = "vetture" + aValue;
 var partenza = document.getElementById(marchio);

 elimina(destino);
 copy(partenza,destino);
 document.getElementById('vetture').value     = '-';
 //
 document.getElementById('vetture').className = "shown";
} // function populate(aValue)

function copy(sel1,sel2) {
 //------ Copio il contenuto di sel1 (partenza) in sel2 (destino) 
 var i = 0;
 for (i=0;i<sel1.options.length;i++) {
  //-------- Ricavo la riga selezionata
  var oCurOption    = sel1.options.item(i);
  //-------- Creo una nuova opzione
  var oOption       = document.createElement("OPTION");
  //-------- La aggiungo alla seconda select
  sel2.options.add(oOption);
  //-------- Assegno i valori della prima select alla seconda
  oOption.value     = oCurOption.value; 
  oOption.text      = oCurOption.text ;
 } // for (i=0;i<sel1.options.length;i++)
} // function copy(sel1,sel2)

function elimina(sel2) {
 //------ Elimino il contenuto di sel2 (destino)
 var i = 0;
 for (i=sel2.options.length;i>=0;i--) {
  sel2.options.remove(i);
 } // for (i=sel2.options.length;i>=0;i--)
} // function elimina(sel2)

//-->


activateMenu = function(nav) {

/* currentStyle restricts the Javascript to IE only */
	if (document.all &&
 document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */

        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {   
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
window.onload= function(){
    /* pass the function the id of the top level UL */

    /* remove one, when only using one menu */
    activateMenu('nav_orizzontal');
}
