//Sets all links' onclick handlers, if necessary
function fixDocumentLinks() {
  //Loop through all links in the document
  for ( var index = 0; index < document.links.length; index++) {
    //Get the rel of the current link
    var link = document.links[index];
	var rel = ( link.rel + ' ' );

	//If Popup is one of the values, add an onclick event handler
	if ( rel.indexOf( 'External ' ) > -1 ) {
	  link.onclick = new Function( 'return openWin(this);' );
	}
  }
}

//Opens a new window for links, and returns false to surpress link from opening in existing window
function openWin(link/*, width, height*/) {
  /*
  if ( width == null) width = 400;
  if ( height == null) height = 300;

  var config = 'width=' + width + ',height=' + height;
  */

  //Try to open the window
  if ( window.open( link.href, '_blank'/*, config*/ ) ) {
    return false;
  }

  //If all else fails, let document load in existing window
  return true;
}


//Run the script
fixDocumentLinks();
