var currentPopWindow = null;

function openPopup(url, pWidth, pHeight, name, features, centerWindow)
{
    closePopup();
    if (centerWindow)
    {
        var centerX = screen.width / 2;
        var centerY = screen.height / 2;
        centerX = centerX - (pWidth / 2);
        centerY = centerY - (pHeight / 2);
        features += ",screenX=" + centerX + ",left=" + centerX + ",screenY=" + centerY + ",top=" + centerY;
    }

    features += ",height=" + pHeight + ",width=" + pWidth ;
    
    currentPopWindow = window.open(url, name + new Date().getTime(), features);
    if (currentPopWindow) {
        currentPopWindow.focus();
    }
}

function closePopup() {
    if (currentPopWindow == null) {
        return;
    }

    if (!currentPopWindow.closed) {
        currentPopWindow.close();
        currentPopWindow = null;
    }
    window.focus();
}

function openSlides(url, name) {
    openPopup(url, 780, 500, name, "resizable=yes,scrollbars=yes", true);
}
