//
// Physics 2000/Ruder, 09/22/99
//
// Version for DYANMIC created TOC!! Not for static .html-TOC!!
//
function ChangeContents(URL)
{
  //
  // Change main document
  //
//  navName = navigator.appName;
//  navVersion = navigator.appVersion;
//  alert(navName + ", V " + navVersion + " on " + navigator.platform);

  top.Contents.location.href=URL;
}

function ChangeSubdir(Title, Subtitle, Prefix)
{
  //
  // Change frame with Subdirectory
  //
//  navName = navigator.appName;
//  navVersion = navigator.appVersion;
//  alert(navName + ", V " + navVersion + " on " + navigator.platform);

  if (top.frames.length > 0)
  {
    //
    // Obviously, we're having frames
    //
    oldFile = top.SubDirTOC.location.pathname;
    fileStart = oldFile.lastIndexOf("/");
    oldFile = oldFile.substring(fileStart + 1, oldFile.length);

    if (Subtitle != "")
    {
      newFile = "index.pl?Type=SubDir&Sub=" + Title + "#" + Subtitle;
    }
    else
    {
      newFile = "index.pl?Type=SubDir&Sub=" + Title;
    }

    if (oldFile != newFile)
    {
      top.SubDirTOC.location.href=Prefix + newFile;
    }
  }
}

function NoFrames()
{
  doNoFrames = confirm("The current page will be reloaded without the frame navigation.\nFor more information please click on 'INFO'.\nDo you want to continue?");

  if (doNoFrames == true)
  {
    //
    // Current Page
    //
    currentPage = top.Contents.location.href;

    //
    // Rename Contents Frame
    //
    top.Contents.name = "oldContents";
    top.name = "Contents";

    //
    // Open TOC
    //
    NoFramesTOC();

    //
    // Destroy frame structure and name this windows Contents
    //
    top.location.href=currentPage;
  }
}

function NoFramesTOC()
{
  //
  // Generate name of TOC
  //
  TOCURL = BaseURL() + "index.pl?Type=TOC";

  //
  // Open Table of Contents
  //
  TOC = window.open(TOCURL, "TOC", "dependant=yes,height=" + screen.height / 2 + ",locationbar=0,menubar=0,resizable=1,screenX=0,screenY=0,scrollbars=1,status=1,width=" + screen.width / 2);
  TOC.focus();
}

function Frames()
{
  doFrames = confirm("The current page will be reloaded with the frame navigation.\nFor more information please click on 'INFO'.\nDo you want to continue?");

  if (doFrames == true)
  {
    //
    // back to frame navigation, simulate bookmarking
    //
    Contents = window.open("", "Contents");
    Contents.name = "P2000";
    currentPage = Contents.location.href;
    frameURL = BookmarkURL(currentPage);
    Contents.location.href = frameURL;
    self.close();
  }
}

function MakeBookmarkAble()
{
  doBookmark = confirm("The current page will be reloaded, using a URL that is bookmarkable. Please use the bookmark function of your browser after the page has been reloaded.\nFor more information please click on 'INFO'.\nDo you want to continue?");

  if (doBookmark == true)
  {
    currentPage = top.Contents.location.href;

    bookmarkURL = BookmarkURL(currentPage);

    top.location.href = bookmarkURL;
  }
}

function BaseURL()
{
  var baseURL, endURL;

  //
  // Find Base URL (this works only, if called in base directory)
  //
  baseURL = top.location.href;
  endURL = baseURL.indexOf("?");
  if (endURL != -1)
  {
    baseURL = baseURL.substring(0, endURL);
  }

  endURL = baseURL.lastIndexOf("/") + 1;
  if (endURL != 0)
  {
    baseURL = baseURL.substring(0, endURL);
  }

  return baseURL;
}

function BookmarkURL(contentsPage)
{
  var bookmarkURL, startFile;

  //
  // Find bookmarking URL
  //
  bookmarkURL = BaseURL();

  startFile = contentsPage.lastIndexOf(bookmarkURL.substring(bookmarkURL.length - 4, bookmarkURL.length));
  contentsPage = contentsPage.substring(startFile + 4, contentsPage.length);

  bookmarkURL = bookmarkURL + "index.pl?Page=" + contentsPage;

  return bookmarkURL;
}
