var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,resizable=1,scrollbars=1,width=600,height=600';
var _popWindow;

function raw_popup(url, target, features) {
	// pops up a window containing url optionally named target, optionally having features
	if (isUndefined(features)) features = _POPUP_FEATURES;
	if (isUndefined(target  )) target   = '_popWindow';
	_popWindow = window.open(url, target, features, true);
	_popWindow.focus();
	return _popWindow;
}

function link_popup(src, bExisting, features) {
	// to be used in an html event handler as in: <a href=""..."" onclick=""link_popup(this,...)"" ...
	// pops up a window grabbing the url from the event source's href
	var target = bExisting ? '_popWindow' : src.getAttribute('target') || '_blank';
	return raw_popup(src.getAttribute('href'), target, features);
}

function event_popup(e) {
	// to be passed as an event listener
	// pops up a window grabbing the url from the event source's href
	link_popup(e.currentTarget);
	e.preventDefault();
}

function isUndefined(a) { return typeof a == 'undefined' }
