if ((typeof Jesper=='undefined')){
    var Jesper = {};
}
if ((typeof Jesper.link=='undefined')){
    Jesper.link = {};
}
Jesper.link.External = new Class({
  Implements: [Options],
  options : {
    'search':'a.external-link',
    'alert': " <img src=\"http://omega.jesper.nu/images/icons/Icon_External_Link.png\" style=\"border:0\"/>"
  },
  element : null,
  initialize: function(el, options){
    this.setOptions(options);
    this.element = document.id(el) || document;
    this._init();  
  },
  _init : function()
  {
    // Change this to the text you want to use to alert the user that a new window will be opened
    // Find all links
    var links = this.element.getElements(this.options.search);
    var self = this;
    var strNewWindowAlert = this.options.alert;
    // Create an em element containing the new window warning text and insert it after the link text
    
    links.each(function(link){
      var objWarningText;
      objWarningText = document.createElement("span");
      if (link.id.substr(0, 4) !='lnk-')
          objWarningText.innerHTML = strNewWindowAlert;
      if(link.getElement('img') == null && link.getStyle('display')!='block')
        link.appendChild(objWarningText);
      link.addEvent('click', self.onClick);
      objWarningText = null;
    })
  },
  onClick : function(event)
  {
    // Abort if a modifier key is pressed
    if (event.shift || event.alt || event.ctrl || event.meta)
    {
      return true;
    }
    else
    {
      // Change "_blank" to something like "newWindow" to load all links in the same new window
      var newWindow = window.open(this.get('href'), '_blank');
      if (newWindow)
      {
        if (newWindow.focus) {
                newWindow.focus();
        }
        return false;
      }
      return false;
    }
  }
});
