function popup(parm_url, parm_name, parm_width, parm_height, parm_resizable, parm_scrollbars)
{
    window.open(parm_url, parm_name, 'width='+parm_width+',height='+parm_height+',resizable='+parm_resizable+',scrollbars='+parm_scrollbars+',status=no');
}

function vai(indirizzo)
{
    if(navigator.appName.indexOf("Microsoft")!=-1)
    {
        document.URL=indirizzo;
    }
    else if(navigator.appName.indexOf("Netscape")!=-1)
    {
         document.location.href=indirizzo;
    }
}

function inviaForm(theForm,actionForm)
{
    document.forms[theForm].action=actionForm;
    document.forms[theForm].submit();
}

function actionConfirm(theForm,theElement,value,azione)
{
    if (confirm("Sei sicuro di voler "+azione))
    {
        document.forms[theForm].elements[theElement].value=value;
        document.forms[theForm].submit() ;
    }
}

// Funzione per aprire una finestra modale
function modalpopup(parm_url, parm_width, parm_height, parm_resizable, parm_scrollbars)
{
    var ret = "";
    if (window.showModalDialog)
    {
        var argsDialog=[window];
        ret = window.showModalDialog(parm_url, argsDialog,"dialogHeight:"+parm_height+"px;dialogWidth:"+parm_width+"px;resizable:"+parm_resizable+";scrollbars="+parm_scrollbars+'"');
    }
    else
    {
        ret = window.open(parm_url,"modal","width="+parm_width+",height="+parm_height+",resizable="+parm_resizable+",scrollbars="+parm_scrollbars+",modal=yes");
    }
    return ret;
}

function formdownload(nomeLocale, nomeRemoto, preview, module)
{
    //alert(nomeRemoto);
    if (preview == 'true')
    {
        document.forms["form_download"].target="blank";
    }
    else
    {
        document.forms["form_download"].target="_self";
    }
    document.forms["form_download"].action="/extras/download/"+nomeRemoto;
    document.forms["form_download"].elements["localFileName"].value=nomeLocale;
    document.forms["form_download"].elements["remoteFileName"].value=nomeRemoto;
    document.forms["form_download"].elements["preview"].value=preview;
    document.forms["form_download"].elements["module"].value=module;
    document.forms["form_download"].submit();
}

// funzione che richiama una pagina web e passa la response alla callback_function
// url_path          = pagina web da richiamare
// callback_function = riferimento all'oggetto della funzione callback
// parse             = undefined/"xml"/"json", se specificato parsa la response restituendo un txt, un oggetto xml o una variabile parsata da json
function tee_xmlhttp(url_path, callback_function, parse)
{
    var ajax_preview_agt       = navigator.userAgent.toLowerCase();
    var ajax_preview_is_navMoz = (ajax_preview_agt.indexOf('mozilla')!=-1);
    var ajax_preview_is_navIE  = (ajax_preview_agt.indexOf('msie')!=-1);

    var xmlhttp;
    var return_value = "";

    if(ajax_preview_is_navIE == true)
    {
        xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
    }
    else
    {
        xmlhttp = new XMLHttpRequest();
    }

    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState==4)
        {
            switch (parse)
            {
                case "xml":
                {
                    return_value = xmlhttp.responseXml;
                    break;
                }
                case "json":
                {
                    return_value = eval("(" + xmlhttp.responseText + ")");
                    break;
                }
                case "txt":
                {
                    return_value = xmlhttp.responseText;
                    break;
                }
            }
            xmlhttp.abort();
            
            if (callback_function)
                callback_function(return_value);
        }

    }

    xmlhttp.open("GET", url_path, true);
    xmlhttp.send(null);
}
