// Copyright (c) Emagine bvba. All rights reserved.

var emagiCdotNet_Window = new Object();
var emagiCdotNet_PopupWidth = 600;
var emagiCdotNet_PopupHeight = 400;

function emagiCdotNet_Popup(url) {
    url = GetPopupSize(url);
    emagiCdotNet_Window['popupWindow'] = window.open(url, 'doc', 'resizable=1,toolbar=0,border=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,copyhistory=0,width=' + emagiCdotNet_PopupWidth + ',height=' + emagiCdotNet_PopupHeight);
    setTimeout('setWindowFocus(emagiCdotNet_Window["popupWindow"])', 500);
}

function setWindowFocus(win) {
    try {win.focus()}
    catch(e) {}
}

function activateObject(myObjectSource) {
    try {document.write(myObjectSource)}
    catch(e) {}
}

function GetPopupSize(url) {
    var exp = /([^\?]+)\?([^\*]*?)(\d{1,4})\*(\d{1,4})(.*)/;
    var result = url.match(exp);
    if (result == null) {
        exp = /([^\?]+)\?([^\*]*?)(\d{1,4})x(\d{1,4})(.*)/;
        result = url.match(exp);
    }
    if (result != null) {
        if (result[3] != '' && result[4] != '') {
            emagiCdotNet_PopupWidth = result[3];
            emagiCdotNet_PopupHeight = result[4];
            url = url.replace(emagiCdotNet_PopupWidth + '*' + emagiCdotNet_PopupHeight, '');
            url = url.replace(emagiCdotNet_PopupWidth + 'x' + emagiCdotNet_PopupHeight, '');
            if (url.lastIndexOf('?') == url.length - 1) url = url.substr(0, url.length - 1);
        }
    }
    return url;
}


