﻿
function popupWindow(sPage, sName, sWidth, sHeight, showToolbar, showDirectories, showStatus, showMenubar, showScrollbars, showResizable, showLocation, showAsModalWindow) 
{
    //Properties
    this.Page = sPage;
    this.Name = (sName) ? name : '';
    this.Width = (sWidth) ? sWidth : getBrowserScreenWidth();
    this.Height = (sHeight) ? sHeight : getBrowserScreenHeight();
    this.Toolbar = (showToolbar) ? '1' : '0';
    this.Directories = (showDirectories) ? '1' : '0';
    this.Status = (showStatus) ? '1' : '0';
    this.Menubar = (showMenubar) ? '1' : '0'
    this.Scrollbars = (showScrollbars) ? '1' : '0';
    this.Resizable = (showResizable) ? '1' : '0';
    //this.Location = (showLocation) ? '1' : '0';
    this.IsModal = showAsModalWindow;
    
    //Methods
    this.open = open;
    this.getWindowFeatures = getWindowFeatures;
    
    function open()
    {
        if (this.IsModal) 
        {
            var string = new String();
            string.concat('dialogWidth:', this.Width, 'px;', 'dialogHeight:', this.Height, 'px');
            window.showModalDialog(this.Page, this.Name,  string.toString());
        }
        else 
        {
            window.open(this.Page, this.Name, this.getWindowFeatures());    
        }
    }

    function getWindowFeatures() 
    {
        var string = new String();
        var features = string.concat('height=', this.Height,
                                     ',width=', this.Width,
                                     ',toolbar=', this.Toolbar,
                                     ',directories=', this.Directories,
                                     ',status=', this.Status,
                                     ',menubar=', this.Menubar,
                                     ',scrollbars=', this.Scrollbars,
                                     ',resizable=', this.Resizable);

        return (features);
    }

    function getBrowserScreenWidth() 
    {
        return (100);
    }
    
    function getBrowserScreenHeight()
    {
        return(200);
    }
}

function openPopupWindow(sPage, sName, sWidth, sHeight, showToolbar, showDirectories, showStatus, showMenubar, showScrollbars, showResizable, showLocation, showAsModalWindow) 
{
    var settings;
    settings = "width=" + sWidth + ",height=" + sHeight + ",scrollbars=" + showScrollbars + ",toolbar=no";
    popwin = window.open(sPage, "FAFSPORT", settings);
    popwin.focus();
}


