// externalLinks()
// DESCRIPTION: XHTML Strict pop-up links (the standard compliant way)
//
// This function is based on that provided by SitePoint in the article:
// http://www.sitepoint.com/article/standards-compliant-world
// It has been modified to better support the REL attribute, as the original
// function did not allow space seperated values. This one does.
// It has also been extended to show you how you might create sized, positioned
// pop-ups
//
// To use the file you must include the following inside you XHTML's <head>
//
//  <script type="text/javascript" src="/PATH/TO/FILE/dom.js">
//  </script>
//
// I have included two default values you can use for the REL attribute; as
// follows:
//
// <a href="http://someurl" rel="size1">pop-up</a>
// this will open a new window 560px by 560px.
//
// <a href="http://someurl" rel="size2">
// this will open a new window 400px by 300px.
//
// You can extend this function by defining your own values for use in the REL
// attribute and defining appropriate actions for that value.
// You can also delete all the comments so it all loads faster ;)
//
// This file provided by Matthew Wilcox, as part of the article 
// 'Popup windows with XHTML Strict' which can be read at:
// http://mattwilcox.net/devblog/5/

function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) 
    {
    // DONT EDIT THESE TWO VARS
    var anchor   = anchors[i];
    var rel      = anchor.getAttribute("rel");

    // VALUES FOR THE rel ATTRIBUTE. YOU CAN DEFINE MORE var's HERE
    var external = /external/;
    var size1    = /size1/;
	var size2    = /size2/;

    // ACTIONS FOR MATCHING rel VALUES

    // what to do if the rel is set to 'external'
    if (anchor.getAttribute("href") &&
        external.test(rel))
          {
          var link = anchor.getAttribute("href");
          anchor.href = "javascript: void window.open('"+link+"','external','location=1,toolbar=1,scrollbars=1,statusbar=1,menubar=1,resizable=1')";
          }
		  
    // what to do if the rel is set to 'size1'
    if (anchor.getAttribute("href") &&
        size1.test(rel))
          {
          var link = anchor.getAttribute("href");
          anchor.href = "javascript: void window.open('"+link+"','size1','location=0,toolbar=0,scrollbars=0,statusbar=0,menubar=0,resizable=1,width=400,height=300')";
          }
		  
    // what to do if the rel is set to 'size2'
    if (anchor.getAttribute("href") &&
        size2.test(rel))
          {
          var link = anchor.getAttribute("href");
          anchor.href = "javascript: void window.open('"+link+"','size2','location=0,toolbar=0,scrollbars=0,statusbar=1,menubar=0,resizable=1,width=450,height=525')";
          }
		  
    }
  }
window.onload = externalLinks;

// END function externalLinks()