/*
 * Some JavaScript to open links marked with a rel attribute with a value of
 * "external" in a new window. In XHTML 1.0 Strict there isn't a target
 * attribute for links so this is required.
 * 
 * I commented out the code that appends " (opens in a new window)" to the link text
 * 
 * For more details see:
 * http://www.brucelawson.co.uk/index.php/2005/opening-links-in-new-windows-in-xhtml-strict-2/
 */

 window.onload = externalLinks;

 function externalLinks()
 {
     var objCurrent, objReplacement;

     if (document.getElementsByTagName)
     {
         var objAnchors = document.getElementsByTagName('a');
         for (var iCounter=0; iCounter<objAnchors.length; iCounter++)
         {
             if (objAnchors[iCounter].getAttribute('href') &&objAnchors[iCounter].getAttribute('rel') == 'external')
             {
                 objAnchors[iCounter].onclick = function(event){return launchWindow(this, event);}
                 objAnchors[iCounter].onkeypress = function(event){return launchWindow(this, event);}

                 /*if (document.replaceChild)
                 {
                     objCurrent = objAnchors[iCounter].firstChild;
                     if (objCurrent.nodeType == 3) // Text node
                     {
                         objReplacement = document.createTextNode(objCurrent.data + ' (opens in a new window)');
                         objAnchors[iCounter].replaceChild(objReplacement, objCurrent);
                     }
                     else if (objCurrent.alt) // Current element is an image
                     {
                         objReplacement = objCurrent;
                         objReplacement.alt = objCurrent.alt + ' (opens in a new window)';
                         try
                         {
                             objAnchors[iCounter].replaceChild(objReplacement, objCurrent);
                         }
                         catch(e){}
                     }
                 }*/
             }
         }
     }
 }

 function launchWindow(objAnchor, objEvent)
 {
     var iKeyCode;

     if (objEvent && objEvent.type == 'keypress')
     {
         if (objEvent.keyCode)
         iKeyCode = objEvent.keyCode;
         else if (objEvent.which)
         iKeyCode = objEvent.which;

         if (iKeyCode != 13 && iKeyCode != 32)
         return true;
     }

     return !window.open(objAnchor);
 }