/* *******************************************************
** POPUPS.JS - JS-Powered Popups Library
** =====================================
** This library contains code to enable the various types
** of JS-powered popups on the Survival Kit Popups page. 
** Enjoy ... and please maintain this header!
**
** To load this library in an HTML doc, put the following
** line in the doc's HEAD (before any other SCRIPT tags):
**
** <SCRIPT SRC="popups.js" LANGUAGE="JavaScript"></SCRIPT>
**
** Author      Ver  Date    Comments
** ======      ===  ====    ========
** Rick Scott  1.0  2/1/00  First release
**
** Copyright 2000, Rick Scott, all rights reserved.
******************************************************* */

var firstWin = true;  // used in openWin() function

function writeStatusMsg(msg)  // write msg to status bar
  {
  // when used with onMouseOver/onMouseOut, you must code like this:
  // onMouseOver="return writeStatusMsg('status-bar message')"
  window.status = msg;
  return true;
  }

function setDefaultStatusMsg(msg)  // write default msg to status bar
  {
  window.defaultStatus = msg;
  }

function doMouseOver(id)  // process mouseOvers for Popups demo
  {
  if (!showStatus)
    window.status = "";
  else if (id == 'f1')
    window.status = "You are pointing to footnote #1.";
  else if (id == 'f2')
    window.status = "You are pointing to footnote #2.";
  else if (id == 'f3')
    window.status = "You are pointing to footnote #3.";
  else if (id == 'f4')
    window.status = "You are pointing to footnote #4.";
  else if (id == 'f5')
    window.status = "You are pointing to footnote #5.";
  else if (id == 'k1')
    window.status = "You are pointing to keyword #1.";
  else if (id == 'k2')
    window.status = "You are pointing to keyword #2.";
  else if (id == 'k3')
    window.status = "You are pointing to keyword #3.";
  else if (id == 'k4')
    window.status = "You are pointing to keyword #4.";
  else if (id == 'k5')
    window.status = "You are pointing to keywoid #5.";

  if (!showPopup)
    return;
  else if (id == 'f1')
    drc('And here is where you would put the footnote #1 text.',
        'Footnote #1 Caption');
  else if (id == 'f2')
    drc('And here is where you would put the footnote #2 text.',
        'Footnote #2 Caption');
  else if (id == 'f3')
    drc('And here is where you would put the footnote #3 text.',
        'Footnote #3 Caption');
  else if (id == 'f4')
    drc('And here is where you would put the footnote #4 text.',
        'Footnote #4 Caption');
  else if (id == 'f5')
    drc('And here is where you would put the footnote #5 text.',
        'Footnote #5 Caption');
  else if (id == 'k1')
    drc('And here is where you would put the keyword #1 text.',
        'Keyword #1 Caption');
  else if (id == 'k2')
    drc('And here is where you would put the keyword #2 text.',
        'Keyword #2 Caption');
  else if (id == 'k3')
    drc('And here is where you would put the keyword #3 text.',
        'Keyword #3 Caption');
  else if (id == 'k4')
    drc('And here is where you would put the keyword #4 text.',
        'Keyword #4 Caption');
  else if (id == 'k5')
    drc('And here is where you would put the keywoid #5 text.',
        'Keywoid #5 Caption');
}

function doMouseOut()  // process mouseOuts for Popups demo
  {
  if (showPopup)
    nd();
  if (showAlert)
    window.status = "";
  }

function doClick(id)   // process clicks for Popups demo
  {
  if (showAlert)
    {
    if (id == 'f1')
      alert('You clicked on footnote #1.');
    else if (id == 'f2')
      alert('You clicked on footnote #2.');
    else if (id == 'f3')
      alert('You clicked on footnote #3.');
    else if (id == 'f4')
      alert('You clicked on footnote #4.');
    else if (id == 'f5')
      alert('You clicked on footnote #5.');
    else if (id == 'k1')
      alert('You clicked on keyword #1.');
    else if (id == 'k2')
      alert('You clicked on keyword #2.');
    else if (id == 'k3')
      alert('You clicked on keyword #3.');
    else if (id == 'k4')
      alert('You clicked on keyword #4.');
    else if (id == 'k5')
      alert('You clicked on keyword #5.');
    }
  else if (showWindow)
    {
    if (id == 'f1')
      openWin("", "<B>Footnote #1</B><P>You just clicked on it.",
              "width=120,height=140");
    else if (id == 'f2')
      openWin("", "<B>Footnote #2</B><P>You just clicked on it.",
              "width=120,height=280");
    else if (id == 'f3')
      openWin("", "<B>Footnote #3</B><P>You just clicked on it.",
              "width=320,height=280");
    else if (id == 'f4')
      openWin("", "<B>Footnote #4</B><P>You just clicked on it.",
              "width=240,height=280");
    else if (id == 'f5')
      openWin("", "<B>Footnote #5</B><P>You just clicked on it.",
              "width=240,height=140");
    else if (id == 'k1')
      openWin("", "<B>Keyword #1</B><P>You just clicked on it.",
              "width=120,height=140");
    else if (id == 'k2')
      openWin("", "<B>Keyword #2</B><P>You just clicked on it.",
              "width=240,height=140");
    else if (id == 'k3')
      openWin("", "<B>Keyword #3</B><P>You just clicked on it.",
              "width=240,height=280");
    else if (id == 'k4')
      openWin("", "<B>Keyword #4</B><P>You just clicked on it.",
              "width=120,height=280");
    else if (id == 'k5')
      openWin("", "<B>Keyword #5</B><P>You just clicked on it.",
              "width=50,height=340");
    }
  }

function openWin(url, str, features)  // open popup window
  {
  // Netscape recognizes the popupWin object, so we can
  // write code that keeps a single popup window open.
  // IE does not recognize the popupWin object, we must
  // write code that opens multiple popup windows.
  // More info: www.dannyg.com/javascript/jsminifaq.html#q13

  if (navigator.appName.indexOf("Netscape") != -1)  // Netscape only!
    {
    if (!firstWin)  // can't reference popupWin unless it exists
      if (popupWin.document)  // if user didn't already close popupWin,
        popupWin.close();     // close it now (before opening new popupWin)
    }
  popupWin = window.open(url, "", features);  // Netscape and IE from here on
  if (str != "")
    {
    popupWin.document.write(str);
    popupWin.document.close();
    }
  firstWin = false;  // because popupWin now exists
  }

