﻿// JScript File

//JPM - Script Alterado por causa do tamanho das janelas diferir entre ie6 e ie7.
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion); //JPM: Novo
var is_mozilla = (agt.indexOf('firefox') != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); //JPM: alterado: adicionei opera.
var is_ie7 = (is_ie && (is_major == 4) && (agt.indexOf("msie 7.") != -1)); //JPM: Novo

// Var e Func da Window HTML
var index = 0;
var page;

function wmcmWindowOpen(url, name, features) {
    wnd = window.open(url, name, features);
    wnd.focus();

}

function wmcmModalOpen(url, name, wmcmModalWidth, wmcmModalHeight) {
    openModalDialog(name, wmcmModalWidth, wmcmModalHeight, url, this);
    return false;
}

function openModalDialog(title, width, height, url, openerPage) {
    if (!is_ie) {
        var win = new Window('modal' + index,
            { title: title,
                top: 100,
                left: 100,
                width: width,
                height: height,
                zIndex: 150,
                opacity: 1,
                url: url,
                resizable: false,
                //draggable: false,
                //showEffect: Effect.Appear,
                //hideEffect: Effect.DropOut})
                showEffect: Element.show,
                hideEffect: Element.hide
            })
        win.showCenter(true);
        index++;
        page = openerPage;
    }
    else {
        //JPM: Novo
        if (!is_ie7) {
            width = width + 4;
            height = height + 29 + 25 + 4;
        }

        window.showModalDialog(url, window, "dialogHeight:" + height + "px; dialogWidth: " + width + "px; help:yes; scroll:yes;resizable:no");
    }
}

function wmcmScrollPosition(oObject) {
    var posTop = 0, posLeft = 0;

    var oParent = oObject;

    while (oParent != null) {
        posTop += oParent.offsetTop;
        oParent = oParent.offsetParent;
    }
    return (posTop);
}

function wmcmValidaNumericoIntervalo(txt, minVal, maxVal) {
    var key = window.event.keyCode - 48;

    var actVal = txt.value + "" + key;

    if ((window.event.keyCode < 48 || window.event.keyCode > 57 || actVal > maxVal || actVal < minVal) && window.event.keyCode != 8) {
        window.event.keyCode = 0;
        return;
    }
}