﻿function isUndefined(a) {
    return ((typeof a == 'undefined') || (a == null));
}

var _POPUP_FEATURES = 'width=600, height=600, resizable=yes, menubar=no, toolbar=yes, status=yes, scrollbars=yes, location=yes, titlebar=yes';

var objWindow = null;

function raw_popup(url, target, features) {
    try {
        if (objWindow != null)
            objWindow.close();
    } catch (e) { }

    if (isUndefined(features)) {
        features = _POPUP_FEATURES;
    }
    if (isUndefined(target)) {
        target = '_blank';
    }
    objWindow = window.open(url, target, features);
    objWindow.focus();
    return objWindow;
}

function link_popup(src, features) {
    return raw_popup(src.getAttribute('href'),
        src.getAttribute('target') || '_blank',
        features);
}

function link_popup2(src, intWidth, intHeight) {
    return ShowPopup(src.getAttribute('href'), intWidth, intHeight);
}

function link_popup3(src) {
    var href = src.getAttribute('href');
    var width = src.getAttribute('popupwidth');
    var height = src.getAttribute('popupheight');

    return ShowPopup(href, width, height);
}

function ShowPopup(strURL, intWidth, intHeight) {
    intWidth = (isUndefined(intWidth) ? 600 : intWidth);
    intHeight = (isUndefined(intHeight) ? 600 : intHeight);

    return raw_popup(strURL, '_blank', 'width=' + intWidth + ', height=' + intHeight + ', resizable=yes, menubar=no, toolbar=yes, status=yes, scrollbars=yes, location=yes, titlebar=yes')
}

