
//*********************************************************************
// this function builds the link and button to be displayed at the 
// bottom of each glossary page.  The button (and animation) changes 
// based on where the glossary page is being displayed.  If in a pop-up
// then it's a close button, otherwise no button for qtips, in help 
// it's a done button.
function GetButton()
{
//alert("In GetButton")
var ButtonName = "";
var ReturnString ="";
var CloseHREF = "\</\\A>";
//var ButtonNum = NumImages;
//alert("GetButton thinks there are " + ButtonNum + " images.");


// determine which type of button to display
//alert(window.top.name);
if(window.top.name == "popup")
   {
   ButtonName = "JAcloseb"
   if(top.Seg1Now == "q")
      return ReturnString;
//   if(top.InLesson == true)
//      ButtonName = "returntolesson"

   }
else
      return "";
//   ButtonName = "JAcloseb"
 
// build the string
ReturnString = "<A HREF='javascript:GlossaryButton()'";
ReturnString += " ONMOUSEOVER='AnimateOn(\"" + ButtonName + "\")'"; 
ReturnString += " ONMOUSEOUT='AnimateOff(\"" + ButtonName + "\")'>"; 
ReturnString += "<IMG SRC='../images/" + ButtonName;
ReturnString += ".gif' alt='Close the Pop-up window ' BORDER='0'>" + CloseHREF;



//alert("Get Button Returning: " + ReturnString)
    return ReturnString;
    }
//*********************************************************************
function AnimateOn(BName)
   {
    DocImages = document.images.length
    document.images[DocImages-1].src = '../images/' + BName + '.gif'
    }
//*********************************************************************
function AnimateOff(BName)
   {
    DocImages = document.images.length
    document.images[DocImages-1].src = "../images/" + BName + ".gif"
    }
//*********************************************************************
// This function is executed when the done or close  button on a page is 
// clicked.
function GlossaryButton()
{
//alert("In GlossaryButton")

     // if we're in a pop-up close the window
     if(window.top.name.indexOf("popup") > -1)
        {
        window.close();
        return;
        }
      

     // determine the current page location
     var CurrentPage = self.location.toString();
       
     var Seg1 = top.FileName(1, CurrentPage);
     var Seg2 = top.FileName(2, CurrentPage);
     var Dir = top.Directory(CurrentPage);
     var ReturnPage = ""

     // if the dir length is 1, then we must be in a glossary letter directory
     if(Dir.length == 1)
        {
        Dir = top.Directory(top.ToolFile);
        Seg2 = top.FileName(2,top.ToolFile);
        }


   // if we're in a lesson, we want to return to the previous lesson page
   if(top.InLesson == true)
      top.ReturnToLesson(true);
   else
      {
      ReturnPage = "../../" + Dir + "/cc_" + Seg2; 
      if((Seg1 == "h") || (Seg1 == "g"))
         ReturnPage += "_help.html";
        
      if(window.top.name == "EpssWin")
         top.BodyFrame.location = ReturnPage;
      else
         top.BigBodyFrame.location = ReturnPage;
      }
    } 
//*********************************************************************
function GetNumImages()
  {
  NumImages = document.images.length - 1;
  //alert(NumImages);
  }
//***************************************************************
//   **** Main BODY Begins Here

var InLesson = false;

var NumImages = 0;
//alert("Main body thinks there are " + NumImages + " images.");
window.onload = GetNumImages;
var Button = "" 
Button = GetButton();
//alert(Button);

