// Sensible defaults for the popup window, override when calling
var defaultPops = 'scrollbars=1,location=0,statusbar=0,menubar=0,width=400,height=450';

// Raw popup popup function, accepts URL, target window and features
// Returns a reference to the window
function raw_popup(url, target, features) {
	// pops up a window containing url optionally named target, optionally having features
	var features = (features == null) ? defaultPops : features;
	var target = (target == null) ? "_blank" : target;
	var poppedWindow = window.open(url, target, features);
	poppedWindow.focus();
	return poppedWindow;
}

// Wrapper for main popup function
// Usage: <a href="http://www.google.com" onclick="javascript:link_popup(this,'scrollbars=1,location=0,statusbar=0,menubar=0,width=587,height=700'); return false;">Google</a>
//
function link_popup(src, 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
	return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}
