//CVS:       $Id: external.js,v 1.2 2010/02/25 22:35:11 cvsdevel Exp $
//Title:     external.js
//Version:   1.02
//Copyright: Copyright (c) 2010
//Author:    REVIE
//Company:   Rhino Internet

/**
 * Utility library which parses the DOM tree and points all anchor tags
 * within the tree and marked with a rel="external" tag to open in a
 * new window.  Created to provide XHTML-strict compatability.
 * <p>
 * Original version of functionality provided by
 * <a href="http://www.sitepoint.com/article/standards-compliant-world/"
 *    rel="external">SitePoint</a>.
 *
 * <p>
 * <b>Changelog:</b><pre>
 *  1.00  REVIE 2006/10/31  created.
 *  1.01  REVIE 2008/06/24  added addLoadEvent() to improve onload handling.
 *  1.02  REVIE 2010/02/25  now uses jQuery for onload() initialization.
 * </pre>
 *
 * @author  REVIE
 * @version 1.02
 */

// -----------------------------------------------
//
//  main methods
//

/**
 * Adds the selected function to the list of functions designated to
 * run once the page loads.
 *
 * @param func the function to be executed on page load.
 */
function addLoadEvent(func) {
   $(document).ready(func);
} // addLoadEvent

$(document).ready(function() {
   if (document.getElementsByTagName) {
      var anchors = document.getElementsByTagName('a');
      for (var i = 0; i < anchors.length; i++) {
         var anchor = anchors[i];
         if (anchor.getAttribute('href') &&
             anchor.getAttribute('rel') == 'external') {
            anchor.target = '_blank';
         }
      }
   }
});

