//code to change the style sheet on the fly, depending on the user's screen resolution

   function changeCSS() {
      //This function applies a different style sheet depending on the user's screen resolution.

         var css800x600 = "800600.css";
         var css1024x768 = "1024768.css";
         var theStylesheet = document.getElementById("cssDoc");
 
         if ((screen.width <= 800) && (screen.height <= 600))
            theStylesheet.href= css800x600;
         else if ((screen.width >= 1024) && (screen.height >= 768))
            theStylesheet.href= css1024x768;
         else theStylesheet.href= css1024x768;

      } //end function "changeCSS"



      function openPopup(graphicName,caption,windowHeight,windowWidth) {
         //This function opens a popup window that displays a graphic

         var url = "Popup.htm?" + graphicName + "&" + caption;

         window.open(url,'graphicWindow','width=' + windowWidth + ',height=' + windowHeight + ',location=no,menubar=no');

      } //end function


//code and functions related to the popup box:


   document.writeln("<div class=popupShadow id='popupShadow'></div>")
   document.writeln("<div id='popup' class=popup></div>")

   var cursorXPos; //X position of cursor (to place popup box)
   var cursorYPos; //Y position of cursor (to place popup box)

   var windowWidth; //the distance from the left to the right edge of the window
   var windowHeight; //the distance from the top to the bottom of the window

   var scrollDown; //the distance the window has been scrolled down
   var scrollRight; //the distance the window has been scrolled right


   function openPopupBox(msg) {
      //This function opens a popup box to display text. 

      //set up the popup and shadow
         var popupDiv = document.getElementById("popup"); //the popup itself
         var popupShadowDiv = document.getElementById("popupShadow"); //the popup's shadow

         popupDiv.innerHTML="<p class=popupbox>" + msg + "<img src='graphics/blackpixel.gif' id='bp'></p>";

        // popupDiv.style.height=auto;
        // popupDiv.style.width=auto;


      //size the popup and its shadow

         var px=document.getElementById("bp") //invisible pixel used for positioning
         px.style.visibility="hidden"; 

         //resize the popup: height = content + 14; width = 1.61 * height
         while((px.offsetTop + 14) > parseInt(popupDiv.style.height)) 

            {              
               popupDiv.style.height=(parseInt(popupDiv.style.height) + 1);
               popupDiv.style.width=(parseInt(popupDiv.style.height) * 1.61);

            }

         //resize the shadow
         //popupShadowDiv.style.width=parseInt(popupDiv.style.width); 
         //popupShadowDiv.style.height=parseInt(popupDiv.style.height);

      //position the popup and its shadow

         getScreenInfo();

         var popupTop;
      
         if ((cursorYPos + parseInt(popupDiv.style.height) + 5) > windowHeight) //div won't fit
            {
               popupTop = cursorYPos - parseInt(popupDiv.style.height) + scrollDown; 
            }
         else
            {
               popupTop = cursorYPos + scrollDown;
            }


         var popupLeft;

         if ((cursorXPos + parseInt(popupDiv.style.width) + 5) > windowWidth) //div won't fit
            {
               popupLeft = cursorXPos - parseInt(popupDiv.style.width) + scrollRight; 
            }
         else
            {
               popupLeft = cursorXPos + scrollRight;
            }


         var popupShadowTop = popupTop + 5;
         var popupShadowLeft = popupLeft + 5;

         popupDiv.style.left = popupLeft;
         popupDiv.style.top = popupTop;

         popupShadowDiv.style.left=popupShadowLeft;
         popupShadowDiv.style.top=popupShadowTop;
             
              

      //show the popup

         popupDiv.style.display="block";
         popupShadowDiv.style.display="block";

   } //end function "openPopupBox"


   function closePopupBox() {
      //This function closes the popup box. But you probably guessed that.

      var popup = document.getElementById("popup");
      var popupShadow = document.getElementById("popupShadow");

      popup.style.display = "none";
      popupShadow.style.display = "none";

   } //end function closePopupBox



   function getScreenInfo(e) {
      //This function determines information, such as the position
      //of the cursor, that is used in positioning the popup box

      cursorXPos = event.clientX
      cursorYPos = event.clientY

      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight; 

      scrollDown = document.documentElement.scrollTop; //for non-XHTML, this was document.body.scrollTop;  
      scrollRight = document.body.scrollLeft;

   } //end function getScreenInfo



//code to show and hide expanding text: 

   function expandText(targetSpan){
      //This function makes "expanding" text visible or invisible.
      //Such text is used to provide additional info on topic pages.  

      var theSpan = document.getElementById(targetSpan)

  
      if (theSpan.style.display == "none") 
         {
             theSpan.style.display = "inline";
         }
      else 
         {
             theSpan.style.display = "none";
         }
 
   } //end function "expandText"



//code to show or hide detailed help:

   function showHideDetail() {
      //This function enables a user to display only the Steps, 
      //or all content on a Topic page. 

      var controlText = document.getElementById("showDetail"); 

      //show or hide explanation, options, FAQs, utils
      if (document.getElementById("explan"))
         {
            expandText("explan");
         }


      if (document.getElementById("options"))
         {
            expandText("options");
         }


      if (document.getElementById("faqs"))
         {
            expandText("faqs");
         }


      if (document.getElementById("utils"))
         {
            expandText("utils");
         }


      //change link to say "Show quick help" or "Show detailed help"
      if (controlText.innerText == "Show detailed help")
         {
            controlText.innerHTML = "<a href=\"#\" onClick=\"showHideDetail();\">Show quick help</a>";
         }

      else
         {
            controlText.innerHTML = "<a href=\"#\" onClick=\"showHideDetail();\">Show detailed help</a>";
         }

   } //end function "showHideDetail"



//code to show or hide answers (to Frequently Asked Questions)
 
   function showHideAnswers() {
      //This function shows or hides all of the answers to Frequently Asked Questions.

      var currentSpan;
      var controlText = document.getElementById("answerControlText");
      var i = 1; 


      //run the while loop as long as there is another answer

      while (document.getElementById("answer" + i))   
         {

            currentSpan = document.getElementById("answer" + i);

            expandText(currentSpan.id);

            i++; 

         } //end while


         //change link to say "Show all answers" or "Hide all answers"
         if (controlText.innerText == "Show all answers (Click a question to view just that answer.)")
            {
               controlText.innerHTML = "<a href=\"javascript:void(0);\" onClick=\"showHideAnswers();\">Hide all answers</a>";
            }

         else
            {
               controlText.innerHTML = "<a href=\"javascript:void(0);\" onClick=\"showHideAnswers();\">Show all answers</a> (Click a question to view just that answer.)";
            }


   } //end function "showHideAnswers"



//code to show or hide the logo in the upper-right corner of the screen

   function showHideLogo(desiredState) {
      //This function hides the logo in the upper-right corner when the home page is loaded
      //(since that page already has the logo). It shows the logo at other times.

      var currentPage = parent.rightframe.location.href;
      var mainLogo = parent.topframe.document.getElementById("mainLogo");
      var prodLogo = parent.topframe.document.getElementById("productLogo");
      var desiredState;

 
      mainLogo.style.visibility = desiredState;
      prodLogo.style.visibility = desiredState;
 

      } //end function "showHideLogo()"



//code to print the current document

   function printMe() {
      //This function prints the current window.

      window.print();

   } //end function "printMe"
