/** libs.js Versione 1.0.0 2 Gennaio 2012
*  funzioni javascript per la gestione del sito www.cei.it e delle aree riservate
* 
*  Copyright 2011 Savioli Massimiliano, tutti i diritti sono riservati.
*/
/*********** 
*
* variabili globali
* 
***********/
var idVisible = ""; // globale, tiene traccia del div visible
var idContentVisible = "index"; // globale, tiene traccia del contenuto-pagina visibile
var changeImage = null; // globale, funzione changeImage
var vert = null; // globale, il newsticker
var path = "Home";
var textOkLavora = " Registrazione avvenuta con successo.<br \/>E' stata inviata una E-mail di notifica all'indirizzo E-mail specificato.";
var textOkLavora2 = " Dati modificati con successo.";
var textOkLavoraUploadify = ""; // testo da mostrare nel caso in cui l'upload abbia successo: può valere textOkLavora o textOkLavora2 in base al contesto (utente loggato/non loggato)
var uploadifyResetForm = true; // globale, se è true viene resettato il form al termine dell'upload
var counterGalleryImages = 0; // globale conteggio documento in upload per l'area lavora con noi
var fileNameLavora = ""; // globale, nome del file curriculum nella modifica dei dati per l'area lavora con noi
var mdialog = null; // globale, confirm box
var cdialog = null; // globale, alert box
var idOfferta = 0; // globale, idofferta per la candidatura

var initCat = true; //globale, flag di attivazione path catalogo

var catSelected = 0; // globale, idcatalogo (primo selezionato)
var codiceCatImg = ""; // globale, codice pubblicazione catalogo(primo selezionato)
var pathCatImg = ""; // globale, path immagine catalogo (primo selezionato)
var descCatImg = ""; // globale, descrizione catalogo (primo selezionato)
var tipoCat = 0; // globale, tipo catalogo (primo selezionato)

var lineSelected = 0; // globale, linea catalogo (primo selezionato)
var codiceLineImg = ""; // globale, codice linea catalogo(primo selezionato)
var pathLineImg = ""; // globale, path immagine linea catalogo (primo selezionato)
var descLineImg = ""; // globale, descrizione linea catalogo (primo selezionato)

var groupSelected = 0; // globale, gruppo catalogo (primo selezionato)
var codiceGroupImg = ""; // globale, codice gruppo catalogo(primo selezionato)
var pathGroupImg = ""; // globale, path immagine gruppo catalogo (primo selezionato)
var descGroupImg = ""; // globale, descrizione gruppo catalogo (primo selezionato)

var initNews = true; //globale, flag di attivazione path news

var newsSelected = 0; // globale, news (prima selezionata)
var codiceNewsImg = ""; // globale, codice pubblicazione news(prima selezionata)
var pathNewsImg = ""; // globale, path immagine news (prima selezionata)
var descNewsImg = ""; // globale, descrizione news (prima selezionata)
var tipoNews = 0; // globale, tipo news (prima selezionata)

var groupNewsSelected = 0; // globale, gruppo news (prima selezionata)
var codiceGroupNewsImg = ""; // globale, codice gruppo news(prima selezionata)
var pathGroupNewsImg = ""; // globale, path immagine gruppo news (prima selezionata)
var descGroupNewsImg = ""; // globale, descrizione gruppo news (prima selezionata)

// calsse newsticker (news con scroll verticale in home page)
var Ticker = new Class({
    setOptions: function(options) {
        this.options = Object.extend({
            speed: 900,
            delay: 7000,
            direction: 'vertical',
            onComplete: Class.empty,
            onStart: Class.empty
        }, options || {});
    },
    initialize: function(el,options){
        this.setOptions(options);
        this.el = $(el);
        this.items = this.el.getElements('li');
        var w = 0;
        var h = 0;
        if(this.options.direction.toLowerCase()=='horizontal') {
            h = this.el.getSize().y;
            this.items.each(function(li,index) {
                w += li.getSize().x;
            });
        } else {
            w = this.el.getSize().x;
            this.items.each(function(li,index) {
                h += li.getSize().y;
            });
        }
        this.el.setStyles({
            position: 'absolute',
            top: 0,
            left: 0,
            width: w,
            height: h
        });
        this.fx = new Fx.Morph(this.el,{duration:this.options.speed,onComplete:function() {
            var i = (this.current==0)?this.items.length:this.current;
            this.items[i-1].injectInside(this.el);
            this.el.setStyles({
                left:0,
                top:0
            });
        }.bind(this)});
        this.current = 0;
        this.next();
    },
    pause: function() {
     this.fx.pause()
    },
    resume: function() {
        this.fx.resume();
    },
    next: function() {
        this.current++;
        if (this.current >= this.items.length) this.current = 0;
        var pos = this.items[this.current];
        this.fx.start({
            top: -pos.offsetTop,
            left: -pos.offsetLeft
        });
        this.next.bind(this).delay(this.options.delay+this.options.speed);
    }
});

// gestione link con targer esterni alla pagina
document.onclick = function(e)
{
var target = e ? e.target : window.event.srcElement;    

    while (target && !/^(a|body)$/i.test(target.nodeName))
    {
        target = target.parentNode;
    }

    if (target && target.getAttribute('rel') && target.rel == 'external')
    {
        var external = window.open(target.href);

        return external.closed;
    }
}

// visualizza il bloco div  dei contenuti di una pagina
function loadPage (page,pageId)
 {
    if (page != "")
    {
        id = "bodyContainer_" + page;
        idCVisible = "bodyContainer_" + idContentVisible; 
        if (id!=idCVisible)
        {
            // listener OnComplete per idVisible
            $("bodyContainer_" + idContentVisible).set('tween', {duration: 200,
            onComplete: function(e) {
                    // spengo il div "idVisible"
                    $("bodyContainer_" + idContentVisible).setStyle('display', 'none');
                    
                    // fadein div "id" 
                    $("bodyContainer_" + page).setStyle('display', 'block');
                    $("bodyContainer_" + page).set('opacity',0);
                    $("bodyContainer_" + page).fade('in');     
                },
                onStart: function(e) {
                    
                    // gestione casi particolari
                    if (idContentVisible == "mappe")
                    {
                        // rimozione google map via innerHtml
                         var el = document.getElementById("g_map");
                         el.innerHTML = ""; 
                    }
                    else if (idContentVisible == "rete")
                    {
                        // rimozione swf rete vendita via swfObject
                        swfobject.removeSWF("rv_map");
                    } 
                }
            });
            
            // listener onComplete per id
            $("bodyContainer_" + page).set('tween', {duration: 200,
            onComplete: function(e) {
                
                    // idContentVisible ora diventa page
                    idContentVisible = page;
                    
                    getPath(pageId);
                    
                    // gestione casi particolari
                    if (idContentVisible == "mappe")
                    {
                        var el = document.getElementById("g_map");
                        el.innerHTML = "<iframe width=\"580\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.it/maps?f=q&amp;source=embed&amp;hl=it&amp;geocode=&amp;q=Via+Emilia+239+Anzola+Emilia&amp;sll=44.443968,11.478696&amp;sspn=0.008318,0.014377&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Emilia,+239,+40011+Anzola+dell'Emilia+Bologna,+Emilia+Romagna&amp;t=m&amp;vpsrc=6&amp;ll=44.562038,11.170349&amp;spn=0.021404,0.049782&amp;z=14&amp;output=embed\"><\/iframe><br \/><a href=\"http://maps.google.it/maps?f=q&amp;source=embed&amp;hl=it&amp;geocode=&amp;q=Via+Emilia+239+Anzola+Emilia&amp;sll=44.443968,11.478696&amp;sspn=0.008318,0.014377&amp;ie=UTF8&amp;hq=&amp;hnear=Via+Emilia,+239,+40011+Anzola+dell'Emilia+Bologna,+Emilia+Romagna&amp;t=m&amp;vpsrc=6&amp;ll=44.562038,11.170349&amp;spn=0.021404,0.049782&amp;z=14\">Zoom<\/a>";
                            
                    }
                    else if (idContentVisible == "rete")
                    {
                        // caricamento swf rete vendita via swfObject
                        container = document.getElementById("rv_mapContainer");
                        el = document.createElement("div");
                        el.setAttribute("id", "rv_map");
                        container.appendChild(el); 
                        
                        var flashvars = {};
                        var params = {};
                        params.scale = "noscale";
                        params.menu = "false";
                        params.salign = "tl";
                        params.wmode = "transparent";
                        var attributes = {};
                        swfobject.embedSWF("scripts/reteVendita/Depositi_v2.swf","rv_map", "590", "378", "9.0.0", false, flashvars, params, attributes);
                    }
                    else if (idContentVisible == "cataloghi" && initCat)
                    {
                        initCat = false;
                        document.getElementById('pathCataloghi').innerHTML= descCatImg + ' >';
                    }
                    else if (idContentVisible == "novita" && initNews)
                    {
                        initNews = false;
                        if (document.getElementById('pathNews')!= null)
                        {
                            document.getElementById('pathNews').innerHTML= descNewsImg + ' >';
                        }
                    }
                    
                    var flashvars = {};
                    flashvars.settingsXML= "scripts/coverFlow/settings_" + page + ".xml";
                    var params = {};
                    params.scale = "noscale";
                    params.menu = "false";
                    params.salign = "tl";
                    params.wmode = "transparent";
                    params.quality = "best";
                    var attributes = {};
                    swfobject.embedSWF("scripts/coverFlow/CoverFlowFX.swf", "DivCoverFlowFX", "650", "420", "9.0.0", false, flashvars, params, attributes);
                    
                },
                onStart: function(e) {
                    
                    // mi assicuro che il div da spegnere sia spento
                    $("bodyContainer_" + idContentVisible).setStyle('display', 'none');
                }
            });

            // spengo idVisible
            $("bodyContainer_" + idContentVisible).fade('out');  
        }
        
                 
    }
 }
 
 // ricava il percorso di navigazione (ajax)
 function getPath(pageId)
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     if (pageId!=0)
     {
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                var elTex=document.getElementById("path");

                if (xmlHttp.responseText != undefined)
                {
                    var tex=""+xmlHttp.responseText;
                    elTex.innerHTML = tex;
                }
                else
                {
                    // errore nel ricavare il path
                    elRes.innerHTML="";  
                }
            }
        }
        
        qs="scripts/ajax/controller.php";
        
        params="getPath="+pageId+"&langId="+langId;

        xmlHttp.open("POST",qs,true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.send(params);
     }
 }
 
 // gestisce il form di registrazione all'area clienti (ajax)
 function processClientAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Form error. Service Temporarily Unavailable.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Errore nell'invio dei dati. Registrazione annullata.";  
                        break;
                        case "2": // inglese
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                        case "3": // francese
                            textError = "Form error. Service Temporarily Unavailable."; 
                        break;
                        case "4": // spagnolo
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                    }
                    
                    document.getElementById("submitText").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.regDo.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        
                        // gestione testi
                        textError = "Mandatory fields error.";
                        textOk = " Registration successfully completed.<br \/>A notification E-mail has been sent to the address you supplied.";
                        textError2 = "Error";
                        switch (langId)
                        {
                            case "1": // italiano
                                textError = "Campi non compilati correttamente.";
                                textOk = " Registrazione avvenuta con successo.<br \/>E' stata inviata una E-mail di notifica all'indirizzo E-mail specificato.";
                                textError2 = "Errore";
                            break;
                            case "2": // inglese
                                textError = "Mandatory fields error.";
                                textOk = " Registration successfully completed.<br \/>A notification E-mail has been sent to the address you supplied.";
                                textError2 = "Error";    
                            break;
                            case "3": // francese
                                textError = "Champs pas corrects.";
                                textOk = " Enregistrement complété avec succès.<br \/>On a envoyé un courrier électronique pour confirmtion à l'adresse indiqué.";
                                textError2 = "Error";
                            break;
                            case "4": // spagnolo
                                textError = "Campo rellenado incorrectamente.";
                                textOk = " Su gabraciòn tuvo éxito.<br \/>Se ha enviado un correo electrónico por confirmación a la dirreción indicada.";
                                textError2 = "Error";
                            break;
                        }
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            
                            elTex = document.getElementById(campo);
                            if (valore=="0")
                            {
                                elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                reg = false;  
                            }
                            else
                            {
                                elTex.innerHTML = "";
                                document.getElementById("submitText").innerHTML="";    
                            }   
                        }
                        if (reg)
                        {
                            document.getElementById("submitText").innerHTML="<span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOk+"<\/span>";
                            document.regDo.reset();
                            document.getElementById("codiceCliente_Field").style.visibility = "hidden";
                            document.getElementById("conosci_Field").style.visibility = "hidden";
                            document.getElementById("altri_Field").style.visibility = "hidden";
                        }
                        else
                        {
                            document.getElementById("submitText").innerHTML="<span class=\"error\">"+textError+"<\/span>";    
                        }
                    }
                }
                document.getElementById('captcha').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.regDo.reset();
                document.getElementById("codiceCliente_Field").style.visibility = "hidden";
                document.getElementById("conosci_Field").style.visibility = "hidden";
                document.getElementById("altri_Field").style.visibility = "hidden";
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    
    titolo = document.regDo.titolo.value;
    cognome = document.regDo.cognome.value;
    nome = document.regDo.nome.value;
    azienda = document.regDo.azienda.value;
    tipologia = document.regDo.tipologia.value;
    indirizzo = document.regDo.indirizzo.value;
    cap = document.regDo.cap.value;
    citta = document.regDo.citta.value;
    nazione = document.regDo.nazione.value;
    telefono = document.regDo.telefono.value;
    fax = document.regDo.fax.value;
    email = document.regDo.email.value;
    sito = document.regDo.sito.value;
    
    clienteCheck = "";
    rad_val = "";
    for (var i=0; i < document.regDo.clienteCheck.length; i++)
    {
        if (document.regDo.clienteCheck[i].checked)
        {
            var rad_val = document.regDo.clienteCheck[i].value;
        }
    }
    clienteCheck = rad_val;
    codiceCliente = document.regDo.codiceCliente.value;
    
    conosciCheck = "";
    rad_val = "";
    for (var i=0; i < document.regDo.conosciCheck.length; i++)
    {
        if (document.regDo.conosciCheck[i].checked)
        {
            var rad_val = document.regDo.conosciCheck[i].value;
        }
    }
    conosciCheck = rad_val;
    conosci = document.regDo.conosci.value;
    
    altriCheck = "";
    rad_val = "";
    
    if (document.regDo.costruttori[7].checked)
    {
        var rad_val = document.regDo.costruttori[7].value;
    }
    altriCheck = rad_val;
    altri = document.regDo.altri.value;
    
    rad_val = "";
    costruttori = "";
    counterC = 0;
    for (var i=0; i < document.regDo.costruttori.length; i++)
    {
        if (i!=7 && document.regDo.costruttori[i].checked)
        {
            if (counterC == 0)
            {
                counterC++;
                rad_val = document.regDo.costruttori[i].value;    
            }
            else
            {
                rad_val = rad_val +"; " + document.regDo.costruttori[i].value;
            }
        }
    }
    costruttori = rad_val;
    
    piva = document.regDo.piva.value;
    amministratoreDelegato = document.regDo.amministratoreDelegato.value;
    annoFondazione = document.regDo.annoFondazione.value;
    dipendenti = document.regDo.dipendenti.value;
    locazioni = document.regDo.locazioni.value;
    fatturato = document.regDo.fatturato.value;
    note = document.regDo.note.value;
    
    code = document.regDo.code.value;
    
    params="processClientAreaForm=1&langId="+langId+"&code="+code+"&titolo="+titolo+"&cognome="+cognome+"&nome="+nome+"&azienda="+azienda+"&tipologia="+tipologia+"&indirizzo="+indirizzo+"&cap="+cap+"&citta="+citta+"&nazione="+nazione+"&telefono="+telefono+"&fax="+fax+"&email="+email+"&sito="+sito+"&clienteCheck="+clienteCheck+"&codiceCliente="+codiceCliente+"&conosciCheck="+conosciCheck+"&conosci="+conosci+"&costruttori="+costruttori+"&altriCheck="+altriCheck+"&altri="+altri+"&piva="+piva+"&amministratoreDelegato="+amministratoreDelegato+"&annoFondazione="+annoFondazione+"&dipendenti="+dipendenti+"&locazioni="+locazioni+"&fatturato="+fatturato+"&note="+note;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di registrazione all'area lavora con noi (ajax)
 function processLavoraAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Errore nell'invio dei dati. Registrazione annullata.";
                    
                    document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.lavDo.reset();
                    jQuery('#uploadify').uploadifyClearQueue(); 
                }
                else
                {
                    // gestione testi (solo lingua italiana)
                    textError = "Campi non compilati correttamente.";
                    textError2 = "Errore";
                    
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        ute = 0; // id utente internet candidato (lavora con noi)
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            if (campo=="ute")
                            {
                                ute = valore;    
                            }
                            else
                            {
                                elTex = document.getElementById(campo);
                                if (valore=="0")
                                {
                                    elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                    reg = false;  
                                }
                                else
                                {
                                    elTex.innerHTML = "";
                                    document.getElementById("submitTextLavora").innerHTML="";    
                                }
                            }   
                        }
                        if (reg)
                        {
                            if (counterGalleryImages>0)
                            {
                                textOkLavoraUploadify = textOkLavora;
                                uploadifyResetForm = false;
                                jQuery('#uploadify').uploadifySettings('scriptData',{'galleryContest': 'new','ute': ''+ute+''});
                                jQuery('#uploadify').uploadifyUpload();    
                            }
                            else
                            {
                                document.getElementById("submitTextLavora").innerHTML="<span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOkLavora+"<\/span>";
                                document.lavDo.reset();
                                jQuery('#uploadify').uploadifyClearQueue();
                            }
                        }
                        else
                        {
                            document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";    
                        }
                    }
                    else
                    {
                        document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                        document.lavDo.reset();
                        jQuery('#uploadify').uploadifyClearQueue();     
                    }
                }
                document.getElementById('captcha_lavora').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha_lavora').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.lavDo.reset();
                jQuery('#uploadify').uploadifyClearQueue();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    cognome = document.lavDo.cognome.value;
    nome = document.lavDo.nome.value;
    provincia = document.lavDo.provincia.value;
    domicilio = document.lavDo.domicilio.value;
    telefono = document.lavDo.telefono.value;
    email = document.lavDo.email.value;
    
    
    rad_val = "";
    aree = "";
    counterC = 0;
    for (var i=0; i < document.lavDo.aree.length; i++)
    {
        if (document.lavDo.aree[i].checked)
        {
            if (counterC == 0)
            {
                counterC++;
                rad_val = document.lavDo.aree[i].value;    
            }
            else
            {
                rad_val = rad_val +"; " + document.lavDo.aree[i].value;
            }
        }
    }
    aree = rad_val;
    
    eta = document.lavDo.eta.value;
    note = document.lavDo.note.value;
    consenso = "";
    if (document.lavDo.consenso.checked)
    {
        consenso = document.lavDo.consenso.value;    
    }
    else
    {
        consenso = "";     
    }
    consenso2 = "";
    if (document.lavDo.consenso2.checked)
    {
        consenso2 = document.lavDo.consenso2.value;    
    }
    else
    {
        consenso2 = "";     
    }
    
    code2 = document.lavDo.code2.value;
    
    params="processLavoraAreaForm=1&langId="+langId+"&code2="+code2+"&cognome="+cognome+"&nome="+nome+"&provincia="+provincia+"&domicilio="+domicilio+"&telefono="+telefono+"&email="+email+"&aree="+aree+"&eta="+eta+"&note="+note+"&consenso="+consenso+"&consenso2="+consenso2+"&curriculum="+counterGalleryImages;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di modifica dei dati per l'area lavora con noi (ajax)
 function processLavoraAreaFormMod()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Errore nell'invio dei dati. Registrazione annullata.";
                    
                    document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.lavDo.reset();
                    jQuery('#uploadify').uploadifyClearQueue(); 
                }
                else
                {
                    // gestione testi (solo lingua italiana)
                    textError = "Campi non compilati correttamente.";
                    textError2 = "Errore";
                    
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        ute = 0; // id utente internet candidato (lavora con noi)
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            if (campo=="ute")
                            {
                                ute = valore;    
                            }
                            else
                            {
                                elTex = document.getElementById(campo);
                                if (valore=="0")
                                {
                                    elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                    reg = false;  
                                }
                                else
                                {
                                    elTex.innerHTML = "";
                                    document.getElementById("submitTextLavora").innerHTML="";    
                                }
                            }   
                        }
                        if (reg)
                        {
                            if (counterGalleryImages>0)
                            {
                                textOkLavoraUploadify = textOkLavora2;
                                uploadifyResetForm = false;
                                jQuery('#uploadify').uploadifySettings('scriptData',{'galleryContest': 'update','ute': ''+ute+''});
                                jQuery('#uploadify').uploadifyUpload();    
                            }
                            else
                            {
                                document.getElementById("submitTextLavora").innerHTML="<a name=\"lavoraForm\"></a><span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOkLavora2+"<\/span>";
                                document.getElementById('captcha_lavora').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                                location.href = "#lavoraForm";
                            }
                        }
                        else
                        {
                            document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";    
                        }
                    }
                    else
                    {
                        document.getElementById("submitTextLavora").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                        document.lavDo.reset();
                        jQuery('#uploadify').uploadifyClearQueue();     
                    }
                }
                document.getElementById('captcha_lavora').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha_lavora').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.lavDo.reset();
                jQuery('#uploadify').uploadifyClearQueue();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    cognome = document.lavDo.cognome.value;
    nome = document.lavDo.nome.value;
    provincia = document.lavDo.provincia.value;
    domicilio = document.lavDo.domicilio.value;
    telefono = document.lavDo.telefono.value;
    email = document.lavDo.email.value;
    
    
    rad_val = "";
    aree = "";
    counterC = 0;
    for (var i=0; i < document.lavDo.aree.length; i++)
    {
        if (document.lavDo.aree[i].checked)
        {
            if (counterC == 0)
            {
                counterC++;
                rad_val = document.lavDo.aree[i].value;    
            }
            else
            {
                rad_val = rad_val +"; " + document.lavDo.aree[i].value;
            }
        }
    }
    aree = rad_val;
    
    eta = document.lavDo.eta.value;
    note = document.lavDo.note.value;
    consenso = "";
    if (document.lavDo.consenso.checked)
    {
        consenso = document.lavDo.consenso.value;    
    }
    else
    {
        consenso = "";     
    }
    consenso2 = "";
    if (document.lavDo.consenso2.checked)
    {
        consenso2 = document.lavDo.consenso2.value;    
    }
    else
    {
        consenso2 = "";     
    }
    
    code2 = document.lavDo.code2.value;
    
    params="processLavoraAreaForm=1&langId="+langId+"&code2="+code2+"&cognome="+cognome+"&nome="+nome+"&provincia="+provincia+"&domicilio="+domicilio+"&telefono="+telefono+"&email="+email+"&aree="+aree+"&eta="+eta+"&note="+note+"&consenso="+consenso+"&consenso2="+consenso2+"&curriculum="+counterGalleryImages;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di recupero password dell'area clienti (ajax)
 function processRecPasswdClientAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Form error.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Errore. Procedura annullata.";  
                        break;
                        case "2": // inglese
                            textError = "Form error.";   
                        break;
                        case "3": // francese
                            textError = "Form error."; 
                        break;
                        case "4": // spagnolo
                            textError = "Form error.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientRet").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.regRet.reset(); 
                }
                else if (tex.indexOf("*") == 0)
                {
                    // errore di database/invio mail
                    textError = "User disabled. Use Reopening request.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Utenza non attiva. Utilizzare Richiesta riattivazione.";  
                        break;
                        case "2": // inglese
                            textError = "User disabled. Use Reopening request.";   
                        break;
                        case "3": // francese
                            textError = "User disabled. Use Reopening request."; 
                        break;
                        case "4": // spagnolo
                            textError = "User disabled. Use Reopening request.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientRet").innerHTML="<span class=\"error\"><img alt=\"Error\" title=\"Error\" src=\"templates/1/immagini/error.gif\" \/> "+textError+"<\/span>";
                    document.regRet.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        
                        // gestione testi
                        textError = "Mandatory fields error.";
                        textOk = " A notification E-mail has been sent to the address you supplied.";
                        textError2 = "Error";
                        switch (langId)
                        {
                            case "1": // italiano
                                textError = "Campi non compilati correttamente.";
                                textOk = " E' stata inviata una E-mail di notifica all'indirizzo E-mail specificato.";
                                textError2 = "Errore";
                            break;
                            case "2": // inglese
                                textError = "Mandatory fields error.";
                                textOk = " A notification E-mail has been sent to the address you supplied.";
                                textError2 = "Error";    
                            break;
                            case "3": // francese
                                textError = "Mandatory fields error.";
                                textOk = " A notification E-mail has been sent to the address you supplied.";
                                textError2 = "Error";
                            break;
                            case "4": // spagnolo
                                textError = "Mandatory fields error.";
                                textOk = " A notification E-mail has been sent to the address you supplied.";
                                textError2 = "Error";
                            break;
                        }
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            
                            elTex = document.getElementById(campo);
                            if (valore=="0")
                            {
                                elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                reg = false;  
                            }
                            else
                            {
                                elTex.innerHTML = "";
                                document.getElementById("submitText_clientRet").innerHTML="";    
                            }   
                        }
                        if (reg)
                        {
                            document.getElementById("submitText_clientRet").innerHTML="<span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOk+"<\/span>";
                            document.regRet.reset();
                        }
                        else
                        {
                            document.getElementById("submitText_clientRet").innerHTML="<span class=\"error\">"+textError+"<\/span>";    
                        }
                    }
                }
                document.getElementById('captcha_clientRet').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha_clientRet').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.regRet.reset();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    username = document.regRet.username.value;
    
    code3 = document.regRet.code3.value;
    
    params="processRecPasswdClientAreaForm=1&langId="+langId+"&code3="+code3+"&username="+username;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di riattivazione utenza dell'area clienti (ajax)
 function processReopeningClientAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Form error. Service Temporarily Unavailable.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Username non valido. Procedura annullata.";  
                        break;
                        case "2": // inglese
                            textError = "Invalid Username.";   
                        break;
                        case "3": // francese
                            textError = "Invalid Username."; 
                        break;
                        case "4": // spagnolo
                            textError = "Invalid Username.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientReop").innerHTML="<span class=\"error\"><img alt=\"Error\" title=\"Error\" src=\"templates/1/immagini/error.gif\" \/> "+textError+"<\/span>";
                    document.regReop.reset(); 
                }
                else if (tex.indexOf("*") == 0)
                {
                    // errore di database/invio mail
                    textError = "A reopening request is already pending.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "La richiesta di riattivazione &#232; gi&#224; stata inoltrata.";  
                        break;
                        case "2": // inglese
                            textError = "A reopening request is already pending.";   
                        break;
                        case "3": // francese
                            textError = "A reopening request is already pending."; 
                        break;
                        case "4": // spagnolo
                            textError = "A reopening request is already pending.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientReop").innerHTML="<span class=\"error\"><img alt=\"Error\" title=\"Error\" src=\"templates/1/immagini/error.gif\" \/> "+textError+"<\/span>";
                    document.regReop.reset(); 
                }
                else if (tex.indexOf("!") == 0)
                {
                    // errore di database/invio mail
                    textError = "The account is already active. No request sent.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "L'utenza risulta essere gi&#224 attiva. Richiesta di riattivazione non inoltrata.";  
                        break;
                        case "2": // inglese
                            textError = "The account is already active. No request sent.";   
                        break;
                        case "3": // francese
                            textError = "The account is already active. No request sent."; 
                        break;
                        case "4": // spagnolo
                            textError = "The account is already active. No request sent.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientReop").innerHTML="<span class=\"error\"><img alt=\"Error\" title=\"Error\" src=\"templates/1/immagini/error.gif\" \/> "+textError+"<\/span>";
                    document.regReop.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        
                        // gestione testi
                        textError = "Mandatory fields error.";
                        textOk = " Richiesta di riattivazione inoltrata.";
                        textError2 = "Error";
                        switch (langId)
                        {
                            case "1": // italiano
                                textError = "Campi non compilati correttamente.";
                                textOk = " Richiesta di riattivazione inoltrata.";
                                textError2 = "Errore";
                            break;
                            case "2": // inglese
                                textError = "Mandatory fields error.";
                                textOk = " Request sent.";
                                textError2 = "Error";    
                            break;
                            case "3": // francese
                                textError = "Mandatory fields error.";
                                textOk = " Request sent.";
                                textError2 = "Error";
                            break;
                            case "4": // spagnolo
                                textError = "Mandatory fields error.";
                                textOk = " Request sent.";
                                textError2 = "Error";
                            break;
                        }
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            
                            elTex = document.getElementById(campo);
                            if (valore=="0")
                            {
                                elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                reg = false;  
                            }
                            else
                            {
                                elTex.innerHTML = "";
                                document.getElementById("submitText_clientReop").innerHTML="";    
                            }   
                        }
                        if (reg)
                        {
                            document.getElementById("submitText_clientReop").innerHTML="<span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOk+"<\/span>";
                            document.regReop.reset();
                        }
                        else
                        {
                            document.getElementById("submitText_clientReop").innerHTML="<span class=\"error\"><img alt=\"Error\" title=\"Error\" src=\"templates/1/immagini/error.gif\" \/> "+textError+"<\/span>";    
                        }
                    }
                }
                document.getElementById('captcha_clientReop').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha_clientReop').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.regReop.reset();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    username = document.regReop.username.value;
    
    code5 = document.regReop.code5.value;
    
    params="processReopeningClientAreaForm=1&langId="+langId+"&code5="+code5+"&username="+username;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di ricerca dei prodotti (ajax)
 function processSearchProdClientAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Form error. Service Temporarily Unavailable.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Errore nell'invio dei dati. Procedura annullata.";  
                        break;
                        case "2": // inglese
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                        case "3": // francese
                            textError = "Form error. Service Temporarily Unavailable."; 
                        break;
                        case "4": // spagnolo
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientFind").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.regRet.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        
                        // gestione testi
                        textError2 = "Error";
                        
                        reg2 = true;
                        
                        switch (langId)
                        {
                            case "1": // italiano
                                textError2 = "Error";
                            break;
                            case "2": // inglese
                                textError2 = "Error";
                            break;
                            case "3": // francese
                                textError2 = "Error";
                            break;
                            case "4": // spagnolo
                                textError2 = "Error";
                            break;
                        }
                        
                        innerHtml = ""; // risultato
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            
                            elTex = document.getElementById(campo);
                            if (campo=="res")
                            {
                                innerHtml = valore;
                            }
                            else if (campo == "resError")
                            {
                                innerHtml = valore;
                                document.getElementById("submitText_clientFind").innerHTML="<span class=\"error\">" + innerHtml + "<\/span>";    
                            }
                            else
                            {
                                if (valore=="0")
                                {
                                    elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                    reg = false;  
                                }
                                else if (valore=="1")
                                {
                                    elTex.innerHTML = "";
                                }
                                else if (valore=="2")
                                {
                                    elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                    reg2 = true;
                                    reg = false;    
                                }
                                else if (valore=="3")
                                {
                                    elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                    reg2 = true;
                                    reg = false;    
                                }
                            }      
                        }
                        if (reg)
                        {
                            // Ricerca Ok
                            document.getElementById("submitText_clientFind").innerHTML = innerHtml;
                            document.regRet.reset();
                        }
                        else 
                        {
                            if (!reg2)
                            {
                                document.getElementById("submitText_clientFind").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                            }    
                        }
                        
                        // pulizia div di verifica disponibilià
                        if (document.getElementById("submitText_clientDispo") != null)
                        {
                            document.getElementById("submitText_clientDispo").innerHTML = "";
                        }
                    }
                }
                
            }
            else
            {
                
                document.regRet.reset();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    ceiCode = document.searchProd.ceiCode.value;
    oemCode = document.searchProd.oemCode.value;
    
    params="processSearchProdClientAreaForm=1&langId="+langId+"&ceiCode="+ceiCode+"&oemCode="+oemCode;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce il form di verifica disponibilità dei prodotti (ajax)
 function processSearchDispoClientAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail
                    textError = "Form error. Service Temporarily Unavailable.";
                    switch (langId)
                    {
                        case "1": // italiano
                            textError = "Errore nell'invio dei dati. Procedura annullata.";  
                        break;
                        case "2": // inglese
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                        case "3": // francese
                            textError = "Form error. Service Temporarily Unavailable."; 
                        break;
                        case "4": // spagnolo
                            textError = "Form error. Service Temporarily Unavailable.";   
                        break;
                    }
                    
                    document.getElementById("submitText_clientFind").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.regRet.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");

                        innerHtml = ""; // risultato
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            elTex = document.getElementById(campo);
                            if (campo=="res")
                            {
                                innerHtml = valore;
                            }
                        }
                        if (innerHtml != "")
                        {
                            // Ricerca Ok
                            document.getElementById("submitText_clientDispo").innerHTML = innerHtml;  
                        }
                    }
                } 
            }
            else
            {
                document.regRet.reset();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    ceiCode = document.searchDispo.ceiCode.value;
    oemCode = document.searchDispo.oemCode.value;
    dispo = document.searchDispo.dispo.value;
    
    if (dispo == "0" || dispo == "")
    {
        document.searchDispo.dispo.value = 1;
        document.getElementById("submitText_clientDispo").innerHTML = "";    
    }
    else
    {
        params="processSearchDispoClientAreaForm=1&langId="+langId+"&ceiCode="+ceiCode+"&oemCode="+oemCode+"&dispo="+dispo;

        xmlHttp.open("POST",qs,true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.send(params);
    }
     
 }
 
 // gestisce la visualizzazione dei campi nel form di registrazione all'area clienti
 function manageFormField (id,val,type)
 {
    if (id != "")
    {
        idField = (id.substring(0,id.indexOf("_")));
        switch (type)
        {
            case "toggle":
                visibility = "visible";
                if (val == 0)
                {
                    visibility = "hidden";
                    eval("document.regDo."+idField+".value= ''");    
                }
                document.getElementById(id).style.visibility = visibility;  
            break;
            case "toggle1":
                visibility = "visible";
                if (eval("document.regDo."+idField+"Check.checked") == false)
                {
                     visibility = "hidden";
                     eval("document.regDo."+idField+".value= ''");    
                }
                document.getElementById(id).style.visibility = visibility;
            break;
        }
    }    
 }
 
 // gestisce il submit del form di registrazione all'area clienti
 function clieForm ()
 {
     if (document.reg.delta.value != "" && document.reg.gamma.value != "")
     {
        document.reg.submit();
     }
 }
 
 // gestisce il submit del form di registrazione all'area lavora con noi
 function clieLavoraForm ()
 {
     if (document.regLavora.epsilon.value != "" && document.regLavora.digamma.value != "")
     {
        document.regLavora.submit();
     }
 }
 
 // gestisce il form di recupero password dell'area lavora con noi (ajax)
 function processRecPasswdLavoraAreaForm()
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore di database/invio mail (solo italiano)
                    textError = "Errore nell'invio dei dati. Procedura annullata.";  
                    
                    document.getElementById("submitText_lavoraRet").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    document.regRetLavora.reset(); 
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        
                        // gestione testi (solo italiano)
                        textError = "Campi non compilati correttamente.";
                        textOk = " E' stata inviata una E-mail di notifica all'indirizzo E-mail specificato.";
                        textError2 = "Errore";
                        
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);
                            
                            elTex = document.getElementById(campo);
                            if (valore=="0")
                            {
                                elTex.innerHTML = "<img title=\""+textError2+"\" alt=\""+textError2+"\" style=\"height:14px;margin:1px 0 0 0;\" alt=\""+textError2+"\" title=\""+textError2+"\" src=\"templates/1/immagini/error.gif\" \/>";
                                reg = false;  
                            }
                            else
                            {
                                elTex.innerHTML = "";
                                document.getElementById("submitText_lavoraRet").innerHTML="";    
                            }   
                        }
                        if (reg)
                        {
                            document.getElementById("submitText_lavoraRet").innerHTML="<span class=\"ok\"><img alt=\"Ok\" title=\"Ok\" src=\"templates/1/immagini/check.png\" \/>"+textOk+"<\/span>";
                            document.regRetLavora.reset();
                        }
                        else
                        {
                            document.getElementById("submitText_lavoraRet").innerHTML="<span class=\"error\">"+textError+"<\/span>";    
                        }
                    }
                }
                document.getElementById('captcha_lavoraRet').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
            }
            else
            {
                document.getElementById('captcha_lavoraRet').src = 'scripts/securimage/securimage_show.php?sid=' + Math.random();
                document.regRetLavora.reset();
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    username = document.regRetLavora.username.value;
    
    code4 = document.regRetLavora.code4.value;
    
    params="processRecPasswdLavoraAreaForm=1&langId="+langId+"&code4="+code4+"&username="+username;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce le funzioni del confirm box relativo alla candidatura ad una ricerca nell'area lavora con noi
 function confirmCandidate(p)
 {
     if (p)
     {
        if (idOfferta != 0)
        {
            param = idOfferta;
            // resetto idOfferta globale
            idOfferta = 0;
            processCandidate (param);  
        }
     }
     else
     {
         // resetto idOfferta globale
         idOfferta = 0;
     }
 }
 
 // crea il confirm box relativo alla candidatura ad una ricerca nell'area lavora con noi
 function create_confirmDialog(p) 
 {
        idOfferta = p;
        mdialog = new MavDialog.Confirm({
            'title': 'Candidatura',
            'message': 'Si desidera candidarsi alla seguente ricerca?',
            'callback': confirmCandidate
        });
 }
 
 // crea l'alert box di avviso login per l'area di ricerca dei prodotti
 function create_alertDialog() 
 {
        switch (langId)
        {
            case "1": // italiano
                text = "Eseguire il Login per accedere alla ricerca prodotti.";  
            break;
            case "2": // inglese
                text = "Login to enter the Product Search page.";   
            break;
            case "3": // francese
                text = "Login to enter the Product Search page"; 
            break;
            case "4": // spagnolo
                text = "Login to enter the Product Search page";   
            break;
        }
        mdialog = new MavDialog.Alert({
            'title': 'Login',
            'message': text
        });
 }
 
 // crea l'alert box di avviso di login per le candidature relative all'area lavora con noi
 function create_alertDialog2() 
 {
     text = "Per candidarsi &#224; necessario eseguire il Login all'area Lavora con noi.";     
     mdialog = new MavDialog.Alert({
            'title': 'Login area Lavora con noi',
            'message': text
        });
 }
 
 // gestisce la candidatura di un utente ad una ricerca nell'area lavora con noi (ajax)
 function processCandidate(p)
 {
     var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                // errore di database/invio mail
                textError = "Errore nell'invio dei dati. Registrazione candidatura annullata.";
                    
                if (tex.indexOf("_") == 0)
                {
                    document.getElementById("submitTextCandidate").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                    location.href = "#submitTextCandidate";
                    
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        texArray = tex.split(";");
                        for (i = 0; i < texArray.length; i++) 
                        { 
                            campo = texArray[i].substring(0,texArray[i].indexOf("="));
                            valore = texArray[i].substring(texArray[i].indexOf("=")+1,texArray[i].length);

                            elTex = document.getElementById(campo);
                            if (valore=="0")
                            { 
                                reg = false;  
                            }
                            else
                            {
                                elTex3 = document.getElementById(campo+"_data");
                                elTex3.className = "dataOk";
                                
                                elTex2 = document.getElementById(campo+"_testoIcona");
                                elTex2.className = "testoIconaOk";
                                elTex2.innerHTML = "Candidatura Ok";
                                
                                elTex.innerHTML = "<img alt=\"Candidatura Ok\" title=\"Candidatura Ok\" src=\"templates/1/immagini/tick.png\">";
                                document.getElementById("submitTextCandidate").innerHTML="";
                                reg = true;    
                            }      
                        }
                        
                        if (reg)
                        {
                            document.getElementById("submitTextCandidate").innerHTML="";    
                        }
                        else
                        {
                            document.getElementById("submitTextCandidate").innerHTML="<span class=\"error\">"+textError+"<\/span>";
                            location.href = "#submitTextCandidate";    
                        }
                    }
                } 
            }
            else
            {
                
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    offerta = p;
    
    params="processCandidate=1&langId="+langId+"&offerta="+offerta;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);
     
 }
 
 // gestisce la navigazione dell'elenco dei cataloghi nella gestione dei cataloghi (primo livello)
 function manageCatSelected (p,p2,p3,p4,p5)
 {
     if (p != 0 && p3!="")
     {
         document.getElementById("cata_" + catSelected).className = "voce";
         document.getElementById("cata_" + catSelected).onmouseover = "this.className='voceSelected'";
         document.getElementById("cata_" + catSelected).onmouseout = "this.className='voce'";
         
         document.getElementById("cata_" + p).className = "voceSelected";
         document.getElementById("cata_" + p).onmouseover = "";
         document.getElementById("cata_" + p).onmouseout = "";
         
         document.getElementById("cataDesc_" + catSelected).style.display = "none";
         
         catSelected = p;
         
         codiceCatImg = p2;
         pathCatImg = p3;
         descCatImg = p4;
         tipoCat = p5;
         
         levels = 2; // default
         if (tipoCat == 3)
         {
            levels = 2;
         }
         else if (tipoCat == 1 || tipoCat == 2 || tipoCat == 4 || tipoCat == 5)
         {
            levels = 3;
         }
         
         overText = "";
         if (descCatImg !="")
         {
            overText = codiceCatImg + ": " + descCatImg;
         }
         else
         {
            overText = codiceCatImg;  
         }
         
         document.getElementById("catalogoPreview").innerHTML = "<a title='" + overText + "' href='javascript:displayCat(" + catSelected + "," + tipoCat + ","+levels+");'><img alt='" + overText + "' title='" + overText + "' src='" + pathCatImg + "'\/><\/a>";
         document.getElementById('pathCataloghi').innerHTML= descCatImg + ' >';
         
         document.getElementById("cataDesc_" + catSelected).style.display = "block";
     }
 }
 
 // gestisce la navigazione dell'elenco dei gruppi nella gestione dei cataloghi (terzo livello)
 function manageGroupSelected (p,p2,p3,p4,p5)
 {
     if (p != 0 && p3!="")
     {
         id = "group_" + groupSelected;

         document.getElementById(id).className = "voce";
         document.getElementById(id).onmouseover = "this.className='voceSelected'";
         document.getElementById(id).onmouseout = "this.className='voce'";
         
         if (document.getElementById("pdf_"+groupSelected))
         {
            document.getElementById("pdf_"+groupSelected).style.display = "none";
         }
         
         document.getElementById("group_" + p).className = "voceSelected";
         document.getElementById("group_" + p).onmouseover = "";
         document.getElementById("group_" + p).onmouseout = "";
         
         groupSelected = p;
         
         codiceGroupImg = p2;
         pathGroupImg = p3;
         descGroupImg = p4;
         
         overText = "";
         if (descGroupImg !="")
         {
            overText = descGroupImg;
         }
         
         document.getElementById("catalogoPreview2").innerHTML = "<a title='" + overText + "'><img alt='" + overText + "' title='" + overText + "' src='" + pathGroupImg + "'\/><\/a>";
         
         stringPath = "";
         if (p5 == 2) // chiamata da php displayCat (2 livelli)
         {
            stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleCat();'>" + descCatImg + "<\/a> <span>><\/span> " + descGroupImg + ' <span>>><\/span>';
         }
         else if (p5 == 3) // chiamata da php displayLine (3 livelli)
         {
            stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleCat();'>" + descCatImg + "<\/a> <span>><\/span> " +
                        
                        "<a title='"+ descLineImg +"' href='javascript:toggleLine();'>" + descLineImg + "<\/a> <span>>><\/span> "
                        
                        + descGroupImg + ' <span>>>><\/span>';    
         }
         document.getElementById('pathCataloghi').innerHTML= stringPath;
         if (document.getElementById("pdf_"+p))
         {
            document.getElementById("pdf_"+p).style.display = "block";
         }
     }
 }
 
 // gestisce la navigazione dell'elenco delle fasce vendita per i cataloghi (secondo livello)
 function manageLineSelected (p,p2,p3)
 {
     if (p != 0 && p3!="")
     {
         id = "line_" + lineSelected;

         document.getElementById(id).className = "voce";
         document.getElementById(id).onmouseover = "this.className='voceSelected'";
         document.getElementById(id).onmouseout = "this.className='voce'";
         
         
         document.getElementById("line_" + p).className = "voceSelected";
         document.getElementById("line_" + p).onmouseover = "";
         document.getElementById("line_" + p).onmouseout = "";
         
         lineSelected = p;
         
         pathLineaImg = p2;
         descLineImg = p3;
         
         overText = "";
         if (descLineImg !="")
         {
            overText = descLineImg;
         }
         
         document.getElementById("catalogoPreview3").innerHTML = "<a title='" + overText + "' href='javascript:displayLine(" + catSelected + "," + tipoCat + "," + levels + "," + lineSelected + ");'><img alt='" + overText + "' title='" + overText + "' src='" + pathLineaImg + "'\/><\/a>";
         
         stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleGroup();'>" + descCatImg + "<\/a> <span>><\/span> " + descLineImg + ' <span>>><\/span>';
         document.getElementById('pathCataloghi').innerHTML= stringPath;
     }
 }
 
 // visualizza i cataloghi (ajax)
 function displayCat (p,p2,p3)
 {
    var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        
                        texArray = tex.split("####_####");
                        
                        if (p3 == 2) // livello di visualizzazione (valori possibili: 2,3)
                        {
                            if (document.getElementById("pdf_"+groupSelected))
                            {
                                document.getElementById("pdf_"+groupSelected).style.display = "none";
                            }
                            
                            groupSelected = texArray[0];
                            descGroupImg = texArray[1];
                            codiceGroupImg = texArray[2];
                            pathGroupImg = texArray[3];

                            codeHtml = texArray[4]; 
                            
                            document.getElementById("cataloghiContainer").style.display = "none";
                            document.getElementById("cataloghiContainer2").style.display = "block";
                            
                            if (codeHtml!= undefined)
                            {
                                document.getElementById("cataloghiContainer2").innerHTML = codeHtml;
                            }
                            
                            codeHtml2 = texArray[5];
                            
                            document.getElementById("cataloghiContainerRes").style.display = "block";
                            
                            if (codeHtml2!= undefined)
                            {
                                document.getElementById("cataloghiContainerRes").innerHTML = codeHtml2;
                            }

                            stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleCat();'>" + descCatImg + "<\/a> <span>><\/span> " + descGroupImg + ' <span>>><\/span>';
         
                            document.getElementById('pathCataloghi').innerHTML= stringPath;
                            
                        }
                        else if (p3 == 3)
                        {
                            if (document.getElementById("pdf_"+groupSelected))
                            {
                                document.getElementById("pdf_"+groupSelected).style.display = "none";
                            }
                            
                            lineSelected = texArray[0];
                            pathLineImg = texArray[2];
                            descLineImg = texArray[1];
                            
                            codeHtml = texArray[3];
                            
                            document.getElementById("cataloghiContainer").style.display = "none";
                            document.getElementById("cataloghiContainer3").style.display = "block";
                            document.getElementById("cataloghiContainer3").innerHTML = codeHtml;

                            stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleGroup();'>" + descCatImg + "<\/a> <span>><\/span> " + descLineImg + ' <span>>><\/span>';
         
                            document.getElementById('pathCataloghi').innerHTML= stringPath;
                        }
                    }
                } 
            }
            else
            {
                // errore    
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    catId = p;
    catType = p2;
    level = p3;
    
    params="displayCat=1&langId="+langId+"&catId="+catId+"&catType="+catType;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);      
 }
 
 // visualizza i cataloghi al secondo step: parte dalle fasce vendita (ajax)
 function displayLine (p,p2,p3,p4)
 {
    var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        
                        texArray = tex.split("####_####");
                        
                        groupSelected = texArray[0];
                        descGroupImg = texArray[1];
                        codiceGroupImg = texArray[2];
                        pathGroupImg = texArray[3];

                        codeHtml = texArray[4]; 
                        
                        
                        document.getElementById("cataloghiContainer3").style.display = "none";
                        document.getElementById("cataloghiContainer2").style.display = "block";
                        
                        if (codeHtml!= undefined)
                        {
                            document.getElementById("cataloghiContainer2").innerHTML = codeHtml;
                        }
                        
                        codeHtml2 = texArray[5];
                        
                        document.getElementById("cataloghiContainerRes").style.display = "block";
                        
                        if (codeHtml2!= undefined)
                        {
                            document.getElementById("cataloghiContainerRes").innerHTML = codeHtml2;
                        }

                        stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleCat();'>" + descCatImg + "<\/a> <span>><\/span> " +
                        
                        "<a title='"+ descLineImg +"' href='javascript:toggleLine();'>" + descLineImg + "<\/a> <span>>><\/span> "
                        
                        + descGroupImg + ' <span>>>><\/span>';
     
                        document.getElementById('pathCataloghi').innerHTML= stringPath;
                            
                       
                    }
                } 
            }
            else
            {
                // errore    
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    catId = p;
    catType = p2;
    level = p3;
    lineId = p4;
    
    params="displayLine=1&langId="+langId+"&catId="+catId+"&lineId="+lineId+"&catType="+catType;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);      
 }
 
 // gestisce la visualizzazione dei blocchi div relativi ai cataloghi nella gestione dei cataloghi (primo livello)
 // (spegne i blocchi relativi al secondo e terzo livello e attiva il blocco relativo al primo)
 // * nota bene: id cataloghiContainer2 = terzo livello, cataloghiContainer3 = secondo livello
 function toggleCat()
 {
    document.getElementById("cataloghiContainer3").style.display = "none";
    document.getElementById("cataloghiContainer2").style.display = "none";
    document.getElementById("cataloghiContainerRes").style.display = "none";
    document.getElementById("cataloghiContainer").style.display = "block";
    stringPath = descCatImg + " <span>><\/span>";
    document.getElementById('pathCataloghi').innerHTML= stringPath;
 }
 
 // gestisce la visualizzazione dei blocchi div relativi ai gruppi nella gestione dei cataloghi (terzo livello)
 // (spegne i blocchi relativi al secondo livello e attiva il blocco relativo al primo)
 // * nota bene: id cataloghiContainer2 = terzo livello, cataloghiContainer3 = secondo livello
 function toggleGroup()
 {
    document.getElementById("cataloghiContainer3").style.display = "none";
    document.getElementById("cataloghiContainer").style.display = "block";
    stringPath = descCatImg + " <span>><\/span>";
    document.getElementById('pathCataloghi').innerHTML= stringPath;
 }
 
 // gestisce la visualizzazione dei blocchi div relativi alle fasce vendita nella gestione dei cataloghi (secondo livello)
 // (spegne i blocchi relativi al terzo livello e attiva il blocco relativo al secondo)
 // * nota bene: id cataloghiContainer2 = terzo livello, cataloghiContainer3 = secondo livello
 function toggleLine()
 {
    document.getElementById("cataloghiContainer2").style.display = "none";
    document.getElementById("cataloghiContainerRes").style.display = "none";
    document.getElementById("cataloghiContainer3").style.display = "block";
    stringPath = descCatImg + " <span>><\/span>";
    
    stringPath = "<a title='"+ descCatImg +"' href='javascript:toggleCat();'>" + descCatImg + "<\/a> <span>><\/span> " + descLineImg + ' <span>>><\/span>';
    document.getElementById('pathCataloghi').innerHTML= stringPath;
 }
 
 // visualizza le cei news (ajax)
 function displayNews (p,p2)
 {
    var xmlHttp;
     try
     {  // Firefox, Opera 8.0+, Safari    
        xmlHttp=new XMLHttpRequest();    
     }
     catch (e)
     {  // Internet Explorer   
        try
        {      
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {      try
                {        
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX!");        return false;        
                }      
        }    
     }
     
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var tex = "";
            if (xmlHttp.responseText != undefined)
            {
                var reg = true;
                tex = ""+xmlHttp.responseText;
                
                if (tex.indexOf("_") == 0)
                {
                    // errore
                }
                else
                {
                    if (tex.indexOf(";") == 0)
                    {
                        tex = tex.substring(1,tex.length);
                        
                        texArray = tex.split("####_####");
                        
                        
                        if (document.getElementById("pdf_"+groupNewsSelected))
                        {
                            document.getElementById("pdf_"+groupNewsSelected).style.display = "none";
                        }
                        
                        groupNewsSelected = texArray[0];
                        descGroupNewsImg = texArray[1];
                        codiceGroupNewsImg = texArray[2];
                        pathGroupNewsImg = texArray[3];

                        codeHtml = texArray[4]; 
                        
                        document.getElementById("newsContainer").style.display = "none";
                        document.getElementById("newsContainer2").style.display = "block";
                        
                        if (codeHtml!= undefined)
                        {
                            document.getElementById("newsContainer2").innerHTML = codeHtml;
                        }
                        
                        codeHtml2 = texArray[5];
                        
                        document.getElementById("newsContainerRes").style.display = "block";
                        
                        if (codeHtml2!= undefined)
                        {
                            document.getElementById("newsContainerRes").innerHTML = codeHtml2;
                        }

                        stringPath = "<a title='"+ descNewsImg +"' href='javascript:toggleNews();'>" + descNewsImg + "<\/a> <span>><\/span> " + descGroupNewsImg + ' <span>>><\/span>';
     
                        document.getElementById('pathNews').innerHTML= stringPath;  
                    }
                } 
            }
            else
            {
                // errore    
            }
        }
    }
    
    qs="scripts/ajax/controller.php";
    
    catId = p;
    
    params="displayNews=1&langId="+langId+"&catId="+catId;

    xmlHttp.open("POST",qs,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(params);      
 }
 
 // gestisce la visualizzazione dei blocchi div relativi alle fasce vendita delle cei news
 // (spegne i blocchi relativi al secondo livello e attiva il blocco relativo al primo)
 function toggleNews()
 {
    document.getElementById("newsContainer2").style.display = "none";
    document.getElementById("newsContainerRes").style.display = "none";
    document.getElementById("newsContainer").style.display = "block";
    stringPath = descCatImg + " <span>><\/span>";
    document.getElementById('pathNews').innerHTML= stringPath;
 }
 
 // gestisce la navigazione dell'elenco delle fasce vendita cei news (primo livello)
 function manageNewsSelected (p,p2,p3)
 {
     if (p != 0)
     {
         document.getElementById("newsArea_" + newsSelected).className = "voce";
         document.getElementById("newsArea_" + newsSelected).onmouseover = "this.className='voceSelected'";
         document.getElementById("newsArea_" + newsSelected).onmouseout = "this.className='voce'";
         
         document.getElementById("newsArea_" + p).className = "voceSelected";
         document.getElementById("newsArea_" + p).onmouseover = "";
         document.getElementById("newsArea_" + p).onmouseout = "";
         
         document.getElementById("newsDesc_" + newsSelected).style.display = "none";
         
         newsSelected = p;
         
         pathNewsImg = p2;
         descNewsImg = p3;
         
         
         overText = "";
         if (descNewsImg !="")
         {
            overText = descNewsImg;
         }
         
         document.getElementById("newsPreview").innerHTML = "<a title='" + overText + "' href='javascript:displayNews(" + newsSelected + "," + tipoNews +");'><img alt='" + overText + "' title='" + overText + "' src='" + pathNewsImg + "'\/><\/a>";
         document.getElementById('pathNews').innerHTML= descNewsImg + ' >';
         
         document.getElementById("newsDesc_" + newsSelected).style.display = "block";
     }
 }
 
 // gestisce la navigazione dell'elenco dei gruppi delle cei news (secondo livello)
 function manageGroupNewsSelected (p,p2,p3,p4,p5)
 {
     if (p != 0 && p3!="")
     {
         id = "groupNews_" + groupNewsSelected;

         document.getElementById(id).className = "voce";
         document.getElementById(id).onmouseover = "this.className='voceSelected'";
         document.getElementById(id).onmouseout = "this.className='voce'";
         
         if (document.getElementById("pdfNews_"+groupNewsSelected))
         {
            document.getElementById("pdfNews_"+groupNewsSelected).style.display = "none";
         }
         
         document.getElementById("groupNews_" + p).className = "voceSelected";
         document.getElementById("groupNews_" + p).onmouseover = "";
         document.getElementById("groupNews_" + p).onmouseout = "";
         
         groupNewsSelected = p;
         
         codiceGroupNewsImg = p2;
         pathGroupNewsImg = p3;
         descGroupNewsImg = p4;
         
         overText = "";
         if (descGroupNewsImg !="")
         {
            overText = descGroupNewsImg;
         }
         
         document.getElementById("newsPreview2").innerHTML = "<a title='" + overText + "'><img alt='" + overText + "' title='" + overText + "' src='" + pathGroupNewsImg + "'\/><\/a>";
         
         stringPath = "";
         if (p5 == 2) // chiamata da php displayCat (2 livelli)
         {
            stringPath = "<a title='"+ descNewsImg +"' href='javascript:toggleNews();'>" + descNewsImg + "<\/a> <span>><\/span> " + descGroupNewsImg + ' <span>>><\/span>';
         }
         
         document.getElementById('pathNews').innerHTML= stringPath;
         if (document.getElementById("pdfNews_"+p))
         {
            document.getElementById("pdfNews_"+p).style.display = "block";
         }
     }
 }
