        function apri_popup(url,lar,alt,scroll,nome) {
            if(scroll=="") scroll='auto';
            if(nome=="") nome='';
            var w = screen.width;
            var h = screen.height;
            var x = Math.round(w / 2) - Math.round(lar / 2);
            var y = Math.round(h / 2) - Math.round(alt / 2);
            window.open(url, nome, 'menubar=no, height=' + alt + ', width=' + lar + ', resizable=yes, toolbar=no, location=no, status=no, left=' + x + ', top=' + y +', scrollbars=' + scroll);
            return true;
        }

        function apri_popup_da_mod(url,lar,alt) {
            var w = screen.width;
            var h = screen.height;
            var x = Math.round(w / 2) - Math.round(lar / 2);
            var y = Math.round(h / 2) - Math.round(alt / 2);
            window.open(url, "", 'menubar=no, height=' + alt + ', width=' + lar + ', resizable=yes, toolbar=no, location=no, status=no, left=' + x + ', top=' + y +', scrollbars=yes');
            return true;
        }

        // APRO IL MENU ...

        function apri(m)

        {

            document.getElementById(m).style.visibility = "visible";

        }

        // CHIUDO IL MENU ...

        function chiudi(m)

        {

            document.getElementById(m).style.visibility = "hidden";

        }



        function aprichiudi(m) {
            if(document.getElementById(m).style.visibility == "visible") {
                document.getElementById(m).style.visibility = "hidden";
                document.getElementById(m).style.display = "none";            
                return true;
            }

            if(document.getElementById(m).style.visibility == "hidden") {
                document.getElementById(m).style.visibility = "visible";
                document.getElementById(m).style.display = "block";            
                return true;
            }
        }



        function aprichiudi_modulo(m) {

            if(document.getElementById(m).style.visibility == "visible") {

                document.getElementById(m).style.visibility = "hidden";

                document.getElementById(m).style.display = "none";            

                document.getElementById(m + '_img').src='_immagini/espandi.png';
                return true;

            }

            

            if(document.getElementById(m).style.visibility == "hidden") {

                document.getElementById(m).style.visibility = "visible";

                document.getElementById(m).style.display = "block";            

                document.getElementById(m + '_img').src='_immagini/contrai.png';
                return true;

            }

        

        }


        function aprichiudi_menu(m) {

            if(document.getElementById('sott_' + m).style.visibility == "visible") {

                document.getElementById('sott_' + m).style.visibility = "hidden";

                document.getElementById('sott_' + m).style.display = "none";            

                return true;

            }

            

            if(document.getElementById('sott_' + m).style.visibility == "hidden") {

                document.getElementById('sott_' + m).style.visibility = "visible";

                document.getElementById('sott_' + m).style.display = "block";            

                return true;

            }

        

        }


        function aprichiudi_pag(m) {

            if(document.getElementById(m).style.visibility == "visible") {

                document.getElementById(m).style.visibility = "hidden";

                document.getElementById(m).style.display = "none";            

                document.getElementById('piu' + m).src='_immagini/espandi.png';
                return true;

            }

            

            if(document.getElementById(m).style.visibility == "hidden") {

                document.getElementById(m).style.visibility = "visible";

                document.getElementById(m).style.display = "block";            

                document.getElementById('piu' + m).src='_immagini/contrai.png';
                return true;

            }

        

        }


    var campo;
    var tipo;
    var loading;
    var risultato;

        
    function makeRequest(id_div_output,url) {

    		if(!(id_div_output)) id_div_output=campo;

        var http_request = false;
        risultato = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up  Cannot create an XMLHTTP instance');
            return false;
        }

				if(loading!=0) document.getElementById(id_div_output).innerHTML='<div style="margin: 0px auto; text-align: center; padding: 30px;">Attendere..<br /><br /><img src="_immagini/loading.gif" /></div>';
        http_request.onreadystatechange = function() { alertContents(http_request,id_div_output); };

        if(tipo==null) {
            http_request.open('GET', url, true);
            http_request.send(null);
        } else if(tipo=='POST') {
        		tipo=null;
      			var parti = url.split("?");
            var parameters=parti[1];
            url=parti[0];
            http_request.open('POST', url, true);
            http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http_request.setRequestHeader("Content-length", parameters.length);
            http_request.setRequestHeader("Connection", "close");
            http_request.send(parameters);
        }              
    }

    function alertContents(http_request,output) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
			risposta=http_request.responseText;
			//alert(output);
			document.getElementById(output).innerHTML=risposta;
      risposta=execJS(risposta);
      risultato=true;
            } else {
                alert('There was a problem with the request.');
            }
        }

    }
    
    //-----------------------------------------------------
//valuta il codice javascript e restituisce la stringa
//senza codice
//-----------------------------------------------------
function execJS(t)
{
    var p1 = 0, p2 = 0, p3 = 0, p4 = 0;
    p1 = t.indexOf("<" + "script", 0);
    if(p1 == -1) return t;
    
    p2 = t.indexOf(">", p1 + 7) + 1;
    p3 = t.indexOf("<" + "/script>", p2);
    p4 = p3 + 9;
    
    var c = t.substring(p2, p3);
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.text = c;
    document.getElementsByTagName("head")[0].appendChild(s);
    
    t = t.substring(0, p1) + t.substr(p4);
    return execJS(t);

}
    
    // Funzione per ottenere il valore del radio button
    function readvalue(check) {
        var indice = 0;
        for (var i = 0; i < check.length; i++) {
            if (check[i].checked) indice = i;
        }
        return check[indice].value;
    }
    
    // Funzione per l'attesa dell'Ajax
    function controlla(){
      if (risp!='')
          return;
    else setTimeout('controlla();',300);
		}