<!-- per 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];}
}


<!-- modulo contatti -->
function Modulo() {
    var nome = document.modulo.nome.value;
    var cognome = document.modulo.cognome.value;
    var indirizzo = document.modulo.indirizzo.value;
    var provincia = document.modulo.provincia.value;
    var citta = document.modulo.citta.value;
    var telefono = document.modulo.telefono.value;
    var email = document.modulo.email.value;
    var info = document.modulo.info.value;

    var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

    if ((nome == "") || (nome == "undefined")) {
        alert("Il campo Nome è obbligatorio.");
        document.modulo.nome.focus();
        return false;
    }
    else if ((cognome == "") || (cognome == "undefined")) {
       alert("Il campo Cognome è obbligatorio.");
       document.modulo.cognome.focus();
       return false;
    }
    else if ((isNaN(telefono)) || (telefono == "") || (telefono == "undefined")) {
       alert("Il campo Telefono è numerico senza spazi ed obbligatorio.");
       document.modulo.telefono.value = "";
       document.modulo.telefono.focus();
       return false;
    }
    else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
       alert("Inserire un indirizzo email corretto.");
       document.modulo.email.select();
       return false;
    }
    else if ((info == "") || (info == "undefined") || (info.indexOf("Inserisci qui il tuo slogan!") != (-1))) {
       alert("Il campo Messaggio è obbligatorio.");
       document.modulo.info.focus();
       return false;
    } else {
        return true;
    }
}

function Modulo2() {
    var partenza = document.modulo2.partenza.value;
    var arrivo = document.modulo2.arrivo.value;
    var giorno = document.modulo2.giorno.value;
    var mese = document.modulo2.mese.value;
    var anno = document.modulo2.anno.value;
    var nome = document.modulo2.nome.value;
    var cognome = document.modulo2.cognome.value;
    var email = document.modulo2.email.value;
    var telefono = document.modulo2.telefono.value;

    var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

    if ((partenza == "") || (partenza == "undefined")) {
        alert("Il campo Località di Partenza è obbligatorio.");
        document.modulo2.partenza.focus();
        return false;
    }
    else if ((arrivo == "") || (arrivo == "undefined")) {
       alert("Il campo Località di Arrivo è obbligatorio.");
       document.modulo2.arrivo.focus();
       return false;
    }
    else if ((giorno == "") || (giorno == "undefined")) {
       alert("Il campo Giorno di partenza è obbligatorio.");
       document.modulo2.giorno.focus();
       return false;
    }
    else if ((mese == "") || (mese == "undefined")) {
       alert("Il campo Mese di partenza è obbligatorio.");
       document.modulo2.mese.focus();
       return false;
    }
    else if ((anno == "") || (anno == "undefined")) {
       alert("Il campo Anno di partenza è obbligatorio.");
       document.modulo2.anno.focus();
       return false;
    }
    else if ((nome == "") || (nome == "undefined")) {
       alert("Il campo Nome è obbligatorio.");
       document.modulo2.nome.focus();
       return false;
    }
    else if ((cognome == "") || (cognome == "undefined")) {
       alert("Il campo Cognome è obbligatorio.");
       document.modulo2.cognome.focus();
       return false;
    }
    else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
       alert("Inserire un indirizzo email corretto.");
       document.modulo2.email.select();
       return false;
    }
    else if ((isNaN(telefono)) || (telefono == "") || (telefono == "undefined")) {
       alert("Il campo Telefono è numerico senza spazi ed obbligatorio.");
       document.modulo2.telefono.value = "";
       document.modulo2.telefono.focus();
       return false;
    }
    else {
        return true;
    }
}

function openPicture(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
    newWindow = window.open('',"newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
    newWindow.document.open();
    newWindow.document.write('<html><HEAD><title>C.L.P. Servizi S.p.A.</title></HEAD><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
    newWindow.document.write('<img src="'+imageName+'" width="'+imageWidth+'" height="'+imageHeight+'" alt="'+alt+'">');
    newWindow.document.write('</body></html>');
    newWindow.document.close();
    newWindow.focus();
}

function openPrint(url,w,h,pleft,ptop) {
    newWindow = window.open(url,"newWindow","width="+w+",height="+h+",left="+pleft+",top="+ptop);
    newWindow.print();
}

<!-- menucatalogo -->

function SwitchMenu(obj){
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = document.getElementById("cont").getElementsByTagName("DIV");
        if(el.style.display == "none"){
            for (var i=0; i<ar.length; i++){
                ar[i].style.display = "none";
            }
            el.style.display = "block";
        }else{
            el.style.display = "none";
        }
    }
}
function ChangeClass(menu, newClass) {
     if (document.getElementById) {
         document.getElementById(menu).className = newClass;
     }
}
document.onselectstart = new Function("return true");

<!-- funzione antispam -->

function antispam(a,b) {
    document.location.href='mailto:'+a+'@'+b;
}

function cambia_orario(tipo,val) {
    if (tipo == 'andata') {
        dati = js_andata_orario[val];
    } else {
        dati = js_ritorno_orario[val];
    }
    for (var i=0; i<dati.length; i++){
        ora = dati[i];
        span = document.getElementById(tipo+i);
        span.innerHTML = ora;
    }
}

function show_disponibilita() {
    sel = document.getElementById('tipo_periodicita');

    if (typeof sel == 'object' && sel != null) {
        val = sel.options[sel.selectedIndex].value;

        new_hide('periodicita_settimanale');
        new_hide('periodicita_mensile');
        new_hide('periodicita_personalizzata');

        if (val == 2) {
            new_show('periodicita_settimanale');
        }
        if (val == 3) {
            new_show('periodicita_mensile');
        }
        if (val == 4) {
            new_show('periodicita_personalizzata');
        }

    }
}

function new_hide(val) {
    if (typeof val != 'object') {
        val = document.getElementById(val);
        if (typeof val == 'object' && val != null) {
            val.style.display = 'none';
        }
    }
}

function new_show(val) {
    if (typeof val != 'object') {
        val = document.getElementById(val);
        if (typeof val == 'object' && val != null) {
            val.style.display = 'block';
        }
    }
}

function ricostruisci_tabella() {
    // fermate
    // distanze
    // costi

    but = document.getElementById('submit');
    but.disabled = true;

    div = document.getElementById('tabellafermate');
    if (typeof div == 'object' && div != null) {
        toadd = intestazione_tabella();

        if (typeof js_fermate != 'object' || js_fermate == null) {
            js_fermate = new Array();
        }

        if (typeof js_distanze != 'object' || js_distanze == null) {
            js_distanze = new Array();
        }

        if (typeof js_costi != 'object' || js_costi == null) {
            js_costi = new Array();
        }


        for (var i=0; i<js_fermate.length; i++){

            toadd = toadd + '<tr>' + "\n";
            fermata = js_fermate[i];
            if (typeof js_listafermate[fermata] == 'undefined') {
                toadd = toadd + '<td width="350" align="left"><b style="color: #f00;">Fermata rimossa</b></td>' + "\n";
            } else {
                toadd = toadd + '<td width="350" align="left"><b>' + js_listafermate[fermata] + '</b></td>' + "\n";
            }

            if (i==0) {
                // js_distanze[i] = 0;
                toadd = toadd + '<td width="60" align="center"><input type="text" readonly="yes" size="5" name="distanza' + i + '" id="distanza' + i + '" class="testo" value="' + js_distanze[i] + '"></td>' + "\n";
            } else {
                toadd = toadd + '<td width="60" align="center"><input type="text" size="5" onChange="set_distanza('+i+');" name="distanza' + i + '" id="distanza' + i + '" class="testo" value="' + js_distanze[i] + '"></td>' + "\n";
            }

            if (typeof js_costi[i] == 'undefined') js_costi[i] = 0;
            if (i==0) {
                // js_costi[i] = 0;
                toadd = toadd + '<td width="60" align="center"><input type="text" readonly="yes" size="5" name="costo' + i + '" id="costo' + i + '" class="testo" value="' + js_costi[i] + '"></td>' + "\n";
            } else {
                toadd = toadd + '<td width="60" align="center"><input type="text" size="5" onChange="set_costo('+i+');" name="costo' + i + '" id="costo' + i + '" class="testo" value="' + js_costi[i] + '"></td>' + "\n";
            }

            if (i==0) {
                toadd = toadd + '<td width="60" align="center">&nbsp;</td>' + "\n";
            } else {
                toadd = toadd + '<td width="60" align="center"><img class="ylink" onClick="porta_su('+i+')" src="immagini/freccia_verde_su.png" width="10" height="13" border="0"></td>' + "\n";
            }

            if (i==(js_fermate.length-1)) {
                toadd = toadd + '<td width="60" align="center">&nbsp;</td>' + "\n";
            } else {
                toadd = toadd + '<td width="60" align="center"><img class="ylink" onClick="porta_giu('+i+')" src="immagini/freccia_arancio_giu.png" width="10" height="13" border="0"></td>' + "\n";
            }

            toadd = toadd + '<td width="60" align="center"><img class="ylink" onClick="elimina('+i+')" src="immagini/canc_scuro.gif" width="37" height="37" border="0"></td>' + "\n";

            toadd = toadd + '</tr>' + "\n";

        }

        toadd = toadd + chiusura_tabella();
        div.innerHTML = toadd;

    }

    ricostruisci_campi();

    but.disabled = false;
}

function ricostruisci_campi() {
    fermate = document.getElementById('fermate');
    if (typeof fermate == 'object' && fermate != null) {
        toadd = '';
        for (var i=0; i<js_fermate.length; i++){
            toadd = toadd + js_fermate[i];
            if (i <  js_fermate.length - 1) {
                toadd = toadd + ';';
            }
        }
        fermate.value = toadd;
    }

    distanze = document.getElementById('distanze');
    if (typeof distanze == 'object' && distanze != null) {
        toadd = '';
        for (var i=0; i<js_distanze.length; i++){
            toadd = toadd + js_distanze[i];
            if (i <  js_distanze.length - 1) {
                toadd = toadd + ';';
            }
        }
        distanze.value = toadd;
    }

    costi = document.getElementById('costi');
    if (typeof costi == 'object' && costi != null) {
        toadd = '';
        for (var i=0; i<js_costi.length; i++){
            toadd = toadd + js_costi[i];
            if (i <  js_costi.length - 1) {
                toadd = toadd + ';';
            }
        }
        costi.value = toadd;
    }
}

function porta_su(val) {
    if (val == 0) return;

    temp1 = js_fermate[val];
    temp2 = js_distanze[val];
    temp3 = js_costi[val];
    temp4 = js_fermate[val-1];
    temp5 = js_distanze[val-1];
    temp6 = js_costi[val-1];

    js_fermate[val] = temp4;
    js_distanze[val] = temp5;
    js_costi[val] = temp6;

    js_fermate[val-1] = temp1;
    js_distanze[val-1] = temp2;
    js_costi[val-1] = temp3;

    ricostruisci_tabella();
}

function porta_giu(val) {
    if (val == js_fermate.length-1) return;

    temp1 = js_fermate[val];
    temp2 = js_distanze[val];
    temp3 = js_costi[val];
    temp4 = js_fermate[val+1];
    temp5 = js_distanze[val+1];
    temp6 = js_costi[val+1];

    js_fermate[val] = temp4;
    js_distanze[val] = temp5;
    js_costi[val] = temp6;

    js_fermate[val+1] = temp1;
    js_distanze[val+1] = temp2;
    js_costi[val+1] = temp3;

    ricostruisci_tabella();
}

function elimina(val) {

    tempfermate = new Array();
    for (var i=0; i<js_fermate.length; i++){
        if (i == val) continue;
        tempfermate[tempfermate.length] = js_fermate[i];
    }
    js_fermate = tempfermate;

    tempdistanze = new Array();
    for (var i=0; i<js_distanze.length; i++){
        if (i == val) continue;
        tempdistanze[tempdistanze.length] = js_distanze[i];
    }
    js_distanze = tempdistanze;

    tempcosti = new Array();
    for (var i=0; i<js_costi.length; i++){
        if (i == val) continue;
        tempcosti[tempcosti.length] = js_costi[i];
    }
    js_costi = tempcosti;

    ricostruisci_tabella();
}

function add_fermata(val) {
    sel = document.getElementById('fermata');

    if (typeof sel == 'object' && sel != null) {
        val = sel.options[sel.selectedIndex].value;
        if (val == 0) return;

        js_fermate[js_fermate.length] = val;
        js_distanze[js_distanze.length] = 0;
        js_costi[js_costi.length] = 0;

        ricostruisci_tabella();
    }

}

function set_distanza(val) {
    ob = document.getElementById('distanza'+val);

    if (typeof ob == 'object' && ob != null) {
        if (ob.value/1 != ob.value) ob.value = 0;
        js_distanze[val] = ob.value/1;
    }

    ricostruisci_campi();
}

function set_costo(val) {
    ob = document.getElementById('costo'+val);

    if (typeof ob == 'object' && ob != null) {
        if (ob.value/1 != ob.value) ob.value = 0;
        js_costi[val] = ob.value/1;
    }

    ricostruisci_campi();
}


function intestazione_tabella() {
    toret = '<table width="650" border="0" cellpadding="3" cellspacing="0" class="testo">' + "\n";
    toret = toret + '<tr>' + "\n";
    toret = toret + '<td width="350"><font color="#0066CC">Fermata</font></td>' + "\n";
    toret = toret + '<td width="60" align="center"><font color="#0066CC">Distanza<br>(in minuti)</font></td>' + "\n";
    toret = toret + '<td width="60" align="center"><font color="#0066CC">Biglietto</font></td>' + "\n";
    toret = toret + '<td width="60" align="center"><font color="#0066CC">Porta su</font></td>' + "\n";
    toret = toret + '<td width="60" align="center"><font color="#0066CC">Porta giu</font></td>' + "\n";
    toret = toret + '<td width="60" align="center"><font color="#0066CC">Elimina</font></td>' + "\n";
    toret = toret + '</tr>' + "\n";

    return toret;
}

function chiusura_tabella() {
    return '</table>' + "\n";
}