﻿function isUndefined(a) 
{
    return typeof a == 'undefined';
} 

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();
    
    try {
        //this is to try to work around a bug in IE7, where it ignores the return value in the onclick,
        //and will still process the href as normal, generally resulting in 2 open windows.
        event.returnValue = false;
    } catch (e2) { }
    
    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 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')
}


