/**
 * Popup
 */
function Popup(name, url, width, height)
{
    this.height = height;
    this.name   = name;
    this.url    = url;
    this.w      = null;
    this.width  = width;
}

Popup.prototype.open = function()
{
    this.close();
    this.w = window.open("", name, "width=100,height=100,resizable=1,directories=0,menubar=0,status=0,toolbar=0");
    if (this.w)
    {
        this.w.location.href = url;
        this.w.focus();
        if (this.w.opener == null) { this.w.opener = self; }
    }
};

Popup.prototype.close = function()
{
    if (this.w && ! this.w.closed)
    {
        if (this.w.opener && ! this.w.opener.closed)
        {
            this.w.opener.focus();
        }
        this.w.close();
    }
};

/**
 *
 */
function popUp(url, name, features)
{
    features += ",resizable=1,directories=0,menubar=0,status=0,toolbar=0";
    if (w && ! w.closed) { w.close(); }
    var w = window.open("", name, features);
    if (w)
    {
        w.location.href = url;
        w.focus();
        if (w.opener == null) { w.opener = self; }
    }
}

function newsPopUp(id)
{
    features += "width=480,height=500,scrollbars=1,resizable=1,directories=0,menubar=0,status=0,toolbar=0";
    if (w && ! w.closed) { w.close(); }
    var w = window.open("", "news", features);
    if (w)
    {
        w.location.href = "/news/articles/?id=" + id;
        w.focus();
        if (w.opener == null) { w.opener = self; }
    }
}

/**
 *
 */
function popUpPrint(url, name, features)
{
    features += ",resizable=1,directories=0,menubar=1,status=0,toolbar=0";
    if (w && ! w.closed) { w.close(); }
    var w = window.open("", name, features);
    if (w)
    {
        w.location.href = url;
        w.focus();
        if (w.opener == null) { w.opener = self; }
    }
}

/**
 *
 */
function closePopUp(w)
{
    if (w)
    {
        if (w.opener && ! w.opener.closed) { w.opener.focus(); }
        w.close();
    }
}

