﻿function OpenPopUp() {
    //Default valores    
    this.url = null;
    this.identificador = null;
    this.top = null;
    this.left = null;
    this.scrollbars = null;
    this.resizable = null;
    this.location = null;
    this.status = null;
    this.width = null;
    this.height = null;

    this.novoPopUp = function(_url, _identificador, _top, _left, _scrollbar, _resizable, _location, _status, _width, _height) {

        try {
            if ((_url != "") && (_identificador != "")) {
                this.url = _url;
                this.identificador = _identificador;
                this.top = _top;
                this.left = _left;
                this.scrollbars = _scrollbar;
                this.resizable = _resizable;
                this.location = _location;
                this.status = _status;
                this.width = _width;
                this.height = _height;

                this.abrirPopUp();
            }
        }
        catch (e) {
            this.url = null;
            this.identificador = null;
            this.top = null;
            this.left = null;
            this.scrollbars = null;
            this.resizable = null;
            this.location = null;
            this.status = null;
            this.width = null;
            this.height = null;

            alert("OpenPopUp.novoPopUp(); = " + e.message);

            return false;
        }
    }

    this.abrirPopUp = function() {
        try {
            var strParametros = "";
            var concatParametros = "";

            strParametros += (this.top != "") ? concatParametros + "top=" + this.top : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.left != "") ? concatParametros + "left=" + this.left : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.scrollbars != "") ? concatParametros + "scrollbars=" + this.scrollbars : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.resizable != "") ? concatParametros + "resizable=" + this.resizable : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.location != "") ? concatParametros + "location=" + this.location : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.status != "") ? concatParametros + "status=" + this.status : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.width != "") ? concatParametros + "width=" + this.width : "";
            concatParametros = (strParametros != "") ? "," : "";
            strParametros += (this.height != "") ? concatParametros + "height=" + this.height : "";


            if ((strParametros != "") && (this.url != null) && (this.identificador != null)) {
                window.open(this.url, this.identificador, strParametros);
            }

            this.url = null;
            this.identificador = null;
            this.top = null;
            this.left = null;
            this.scrollbars = null;
            this.resizable = null;
            this.location = null;
            this.status = null;
            this.width = null;
            this.height = null;
        }
        catch (e) {
            alert("OpenPopUp.abrirPopUp(); = " + e.message);
            return false;
        }
    }
}