var printWin;

            // Manage links created from HTML editor
            function manageLink(obj, objType)
            {
                var history = "yes";
                if (objType == 'immagine')
                {
                    openNewWindow(obj, '_blank', dimX, dimY, true, true, false);
                }
                else if (objType == 'file')
                {
                    window.open(obj);
                }
                else if (objType == 'documento')
                {
                    window.location.href = '/portalWeb/portlets/ssbRicarica/documento.jsp?cm_path=' + obj + '&history=' + history;
                }
                else if (objType == 'notizia')
                {
                    openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia&coopVoce=yes', 'popupDocumento', dimX, dimY, true, true, false);
                }
                else if (objType == 'URL')
                {
                    var regExp = new RegExp(".*/portalWeb/portlets/consumatori/goToConsumatori.jsp", "i")

                    if (obj == '/portalWeb/farmaci/FarmaciController.jpf')
                    {
                        openNewWindow(obj, 'farmaci', 512, 560, true, true, false);
                    }
                    if (obj.match(regExp) != null)
                    {
                        window.location.href = obj;
                    }
                    // Esternal Link
                    if (obj.substring(0,7) == 'http://')
                    {
                        window.open(obj);
                        return;
                    }
                    //18-07-2006 Stefano
                    //Farmaci pop-up
                    regExp = new RegExp(".*/portalWeb/portlets/farmaciLavora/*", "i")
                    if (obj.match(regExp) != null)
                    {
                        openNewWindow(obj,'FarmaciLavora', 520, 560, true, true, true);
                    }
                    else
                        window.location.href = obj;
                }
    
                return;
            }
        
function printWindow(link)
{
    if (!printWin || printWin.closed)
    {
       printSpecial();
    }
    printWin.focus()
    return true;
}
var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
    // Dimensions for popup
    var dimX = 540;
    var dimY = 500;
    
    if (document.getElementById != null)
    {
        var html = '<HTML>\n<HEAD>\n';

        if (document.getElementsByTagName != null)
        {
            var headTags = document.getElementsByTagName("head");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }
        
        html += '\n</HE' + 'AD>\n<BODY>\n';
        
        var printReadyElem = document.getElementById("printReady");
        
        if (printReadyElem != null)
        {
                html += '<div class="corpoPrint">' + printReadyElem.innerHTML + '</div>';
        }
        else
        {
            alert("Attenzione la stampa della pagina si avvia in automatico.");
            return;
        }
            
        html += '\n</BO' + 'DY>\n</HT' + 'ML>';
        
        printWin = openNewWindow("", 'printWindow', dimX, dimY, true, true, false)
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();
        printWin.document.getElementById("dontPrint").innerHTML = '';
        if (gAutoPrint)
            printWin.print();
    }
    else
    {
        alert("Attenzione: la funzionalitą di stampa č disponibile solo per i browser moderni.");
    }
}