/*  uses code from                             */
/*  http://v2studio.com/k/code/lib/            */

var DEFAULT_POPUP_FEATURES = 'location=1, statusbar=1,  menubar=1,  width=700,  height=600';

function isUndefined(a) { 
	return typeof a == 'undefined';
}

function raw_popup(url, target, features) {
  if (isUndefined(features)) {
    features = DEFAULT_POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }else{
	target = '_blank'; //for this project we always want a new window. in other cases this is 
	                   //the name of the window, which will be reused in subsequent calls
}
  var theWindow =  window.open(url, target, features);
  theWindow.focus();
  return theWindow;   // maybe todo: if(theWindow){return false;}else{return true;} so that the original
                      // link will be opened if js window opening failed 
}

function link_popup(src, features) {
  return  raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}