/**
 * Detectar browser engine.
 */
var ie  = document.all && !document.getElementById;
var dom = document.getElementById;
var ns  = document.layers;


/**
 * Janelas pop-up centradas.
 */
function abreJanela(fonte, janela, height, width)
{
    var screenW = 800, screenH = 600;

    if (document.getElementById || document.layers)
    {
        screenW = screen.availWidth;
        screenH = screen.availHeight;
    }
    var leftPos = ((screenW - width) / 2), topPos = ((screenH - height) / 2);

    window.open(fonte, janela, 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height + ',top=' + topPos + ',left=' + leftPos);
}


/**
 * Desabilitar botão direito do mouse
 */
var message = 'Desculpe, função desabilitada para proteger direitos autorais.';
function clickIe()
{
    if (document.all)
    {
        alert(message);
        return false;
    }
}
function clickNs(e)
{
    if (ns || (dom && !document.all))
    {
        if (e.which == 2 || e.which == 3)
        {
            alert(message);
            return false;
        }
    }
}
function protege()
{
    if (ns)
    {
        document.captureEvents(Event.MOUSEDOWN);
        if (document.images)
        {
            for (i = 0; i < document.images.length; i++)
            {
                document.images[i].onmousedown = clickNs;
            }
        }
    }
    else
    {
        if (document.images)
        {
            for (i = 0; i < document.images.length; i++)
            {
                document.onmouseup = clickNs;
                document.images[i].oncontextmenu = clickIe;
            }
        }
    }
}