/**
 * File: popup.js
 * Autore: Piero Giampani
 * Data: 14 agosto 2008
 */
function launchCenter(url, name, popupHeight, popupWidth) {
    var leftPos = 0, topPos = 0;

    if (window.outerHeight) {
        topPos = (window.top.outerHeight - popupHeight) / 2;
        leftPos = (window.top.outerWidth - popupWidth) / 2;
    } else if (document.body.offsetHeight) {
        topPos = (top.document.body.offsetHeight - popupHeight) / 2;
        leftPos = (top.document.body.offsetWidth - popupWidth) / 2;
    }
    if (window.screenY) {
        topPos += window.top.screenY;
        leftPos += window.top.screenX;
    } else if (window.screenTop) {
        topPos += window.top.screenTop / 2;
        leftPos += window.top.screenLeft;
    }
    if (topPos < 0) {
        topPos = 0;
    }
    if (topPos + popupHeight > screen.availHeight) {
        topPos = screen.availHeight - popupHeight;
    }
    if (leftPos < 0) {
        leftPos = 0;
    }
    if (leftPos + popupWidth > screen.availWidth) {
        leftPos = screen.availWidth - popupWidth;
    }

    window.open(url, name,
        'screenX=' + leftPos +
        ',screenY=' + topPos +
        ',left=' + leftPos +
        ',top=' + topPos +
        ',width=' + popupWidth +
        ',height=' + popupHeight +
        ',location=no,toolbar=no,menubar=no,status=no' +
        ',directories=no,scrollbars=yes,resizable=yes').focus();
}
