// $Id: contextlinks.js,v 1.1 2004/09/03 17:24:35 jhriggs Exp $

/**
 * The contextlinks.js file provides a JavaScript function for opening
 * links in a new browser window.  Links with the rel attribute set to
 * "CONTEXTLINKS_NEW_WINDOW" will be opened in a new browser.  This is
 * used instead of the target attribute to allow strict HTML4 and
 * XHTML pages to validate.
 *
 * @version $Id: contextlinks.js,v 1.1 2004/09/03 17:24:35 jhriggs Exp $
 * @copyright Copyright (c) 2004 Jim Riggs.  All rights reserved.
 * @author Jim Riggs <drupal at jim and lissa dot com>
 */


/* This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 */

/**
 * Sets all document anchors with a rel attribute of
 * "CONTEXTLINKS_NEW_WINDOW" to open in a new window.
 */
function contextlinks_new_window_links() {
  if (!document.getElementsByTagName)
    return;

  var theLinks = document.getElementsByTagName("a");

  for (var i = 0; i < theLinks.length; i++) {
    if (theLinks[i].getAttribute("href") && (theLinks[i].getAttribute("rel") == "CONTEXTLINKS_NEW_WINDOW")) {
      theLinks[i].target = "_blank";
    }
  }
} // function contextlinks_new_window_links
