//
// Physics 2000/Ruder, 09/22/99
//
// These scripts are for STATIC frames, not for index.pl generated
// dynamic frames!!
//
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 = "TOC_" + Title + ".html#" + Subtitle;
    }
    else
    {
      newFile = "TOC_" + Title + ".html";
    }

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

function NoFrames()
{
  doNoFrames = confirm("La página actual será cargada nuevamente sin la navegación con 'frames'.\nPara más informacion haga click sobre 'INFO'.\nDesea continuar?");

  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
    //
    top.location.href=currentPage;
  }
}

function NoFramesTOC()
{
  //
  // Generate name of TOC
  //
  TOCURL = BaseURL() + "TOC__Full.html";

  //
  // 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("La página actual será cargada nuevamente con la navegación en 'frames'.\nPara más informacion haga click sobre 'INFO'.\nDesea continuar?");

  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;
    Contents.focus();
    self.close();
  }
}

function MakeBookmarkAble()
{
  doBookmark = confirm("La página actual será cargada nuevamente usando una URL que pueda marcarse. Por favor use la función de bookmark de su browser después de que la página haya cargado nuevamente.\nPara más información haga click sobre 'INFO'.\nDesea continuar?");

  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.html?Page=" + contentsPage;

  return bookmarkURL;
}
