/* Code copyleft James Craig 2003? */

/* One browser sniff to circumvent a known bug. */
var sUserAgent = navigator.userAgent.toLowerCase();
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;

/****************************************************************
Make a new pop-up window...
Parameters:
  oAnchor: required object reference to the anchor (link)
  sWindow: optional string for the window name if wanting to reuse window or null to use the default.
  sProps: optional string of window properties ('width=300,height=200') or null to use the defaults defined here.
Notes:
  Notice in the example that the 'href' value maintains URL (not "#" or "javascript:") and the 'title' attribute
  should indicate that this will be a pop-up window.
Example use:
  <a href="foo.htm" onclick="return pop(this);" title="Foo opens a new window.">Foo</a>
  <a href="survey.htm" onclick="return pop(this,'survey');" title="Survey opens a new window.">Take our survey!</a>
  <a href="http://cookiecrook.com/" onclick="return pop(this,'cc','width=500,height=350');" title="Cookiecrook opens a new window.">Cookiecrook</a>
****************************************************************/
function pop(oAnchor,sWindow,sProps){
	var sUrl = '';
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	else if(sUrl=='') sUrl = oAnchor.href;
	if(sUrl=='') return true;
	var oPopup = false;
	if(sUrl&&sWindow&&sProps) oPopup = window.open(sUrl,sWindow,sProps);
	else if(sUrl&&sWindow) oPopup = window.open(sUrl,sWindow);
	else if(sUrl) oPopup = window.open(sUrl);
	/* An Opera bug returns too early if you focus the window, so we don't focus it in that browser. */
	/* Only a noticable defect if a window is already open and hidden (out of keyboard focus) in Opera. */
	if(oPopup && !isOp) oPopup.focus();
	/* If pop-up was created successfully, cancel link in calling window. */
	/* Acts as regular link in browser that has blocks requested pop-ups or has JavaScript disabled. */
	return (oPopup)?false:true;
}

