﻿function BranchIdByIndex( i )
  {
  return 'branch' + i.toString();
  }

function ToggleVisibility( id )
  {
  var i = 0;
  var element = document.getElementById( BranchIdByIndex( i ) );
  while ( element != null )
    {
    if ( element.id == id )
      {
      element.style.display = 'block';
      }
    else
      {
      element.style.display = 'none';
      }
    
    i++;
    element = document.getElementById( BranchIdByIndex( i ) );
    }
  }

function externalLinks() {
  if ( !document.getElementsByTagName ) {
    return;
  }
  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";
    } else if ( anchor.getAttribute( "href") == "#thumb" ) {
      anchor.setAttribute( "href", anchor.getElementsByTagName( "img" )[ 0 ].getAttribute( "src" ) );
      anchor.target = "_blank";
    }
  }
}

window.onload = externalLinks;

