window.onload = init;

function init ( )
{
  addLinkPopups( );
}

function addLinkPopups ( )
{
  var links = document.getElementsByTagName( "a" );
  var curLink = 0;
  for( curLink = 0; curLink < links.length; curLink++ )
  {
    if( links[curLink].className.indexOf( "popup" ) >= 0 )
    {
      if( links[curLink].getElementsByTagName( "img" ).length = 1 )
      {
        links[curLink].onclick = function ( ) {
          var src = this.getElementsByTagName( "img" )[0].getAttribute( "src" ).replace( "thumbs", "fullsized" );
          alert( src );
          var stdOptions = "toolbar=no,location=no,menubar=no,scrollbars=no,statusbar=no,directories=no,resizable=yes";
          var image = new Image( ); image.src = src;  //Get original dimentions of image
          var dimentions = "width=" + ( image.width + 20 ) + "," + "height=" + ( image.height + 20 );
          delete image;
          window.open( src, "_blank", stdOptions + "," + dimentions );
          return false;
        };
      } else {
        links[curLink].onclick = function ( ) {
          alert("no");
          window.open( this.getAttribute( "href" ), "_blank" );
          return false;
        };
      }
      
    }
  }
}