/*	Accessible Pop-ups (Reference: http://www.alistapart.com/articles/popuplinks/) */

/*	SAMPLE IMPLEMENTATIONS:
 *	
 *	default features:
 *	<a href="http://example.com" target="_blank" onclick="linkPopup(this); return false;">something</a>
 *	
 *	specified features:
 *	<a href="http://example.com" target="_blank" onclick="linkPopup(this, features); return false;">something</a>
 *
 *  combined with external link indication:
 *  <a href="http://example.com" target="_blank" onclick="if(externalLinkConfirm()) { linkPopup(this, 'location=no,status=yes,menubar=no,resizable=yes,toolbar=no,width=739,height=415'); return false; } else { return false; }">something</a>
 *  
 *  TODO: make the combination of this with external link indication automatic?
 *  
 */

var _DEFAULT_POPUP_FEATURES = 'location=0,statusbar=1,menubar=0,width=400,height=300';

function rawPopup(url, target, features)
{
	if(isUndefined(features))
	{
		features = _DEFAULT_POPUP_FEATURES;
	}
	
	if(isUndefined(target))
	{
		target = '_blank';
	}
		
	var newWindow = window.open(url, target, features);	
	newWindow.focus();
	
	return newWindow;
}

function linkPopup(src, features)
{
	return rawPopup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function isUndefined(x) { return typeof x == 'undefined' }

