/*

   This is the script that resets the navigation frame to highlight the 
   section of the site that the user is currently in. It is used by all 
   pages on the site by setting a variable called SectionID equal to some 
   keyword indicating the section of the site that the page belongs to, 
   then calling this script with <script src="ResetNav.js">. If this 
   variable is not defined, or is a blank string, all section links will
   be shown as inactive, which is sometimes okay.
   
   Written February 2001, by John Brooking

*/

if (window.self != window.parent)   // True when in a frame
{
   // Set navdoc to the document contained in the navigational frame
   var navdoc = window.parent.frames[0].document;
   var currsrc, newsrc, secname, event_img;
   var i, pos;

   // Loop over all images on navigational page
   for ( i = 0; i < navdoc.images.length; ++i)
   {
      // Isolate their names from their path
      pos = navdoc.images[i].src.lastIndexOf('/');
      currsrc = (pos == -1)
                  ? navdoc.images[i].src
                  : navdoc.images[i].src.substr(pos+1);

      // If they start with a 'p' or an 's', they are a link image
      // Otherwise, ignore the image, we are not concerned with it
      if( currsrc.substr(0,1) == 'p' || currsrc.substr(0,1) == 's' )
      {
         // isolate the section name that this image is for
         secname = currsrc.substr(1, currsrc.length
                                     - ( currsrc.length - currsrc.indexOf('.'))
                                     - 1 );

         // Convert secondary into primary or vice-versa, if needed
         newsrc = '';
         if( secname == SectionID && currsrc.substr(0,1) == 's' )
            newsrc = 'p' + secname + currsrc.substr(currsrc.indexOf('.'));
         else if( secname != SectionID && currsrc.substr(0,1) == 'p' )
            newsrc = 's' + secname + currsrc.substr(currsrc.indexOf('.'));
         if( newsrc != '')
            navdoc.images[i].src = newsrc;

         // If event-related, make sure "Events" heading also highlighted
         if( secname == 'Events' )
            if( SectionID == 'Perform'
                  || SectionID == 'Auditn'
                  || SectionID == 'Classes'
                  || SectionID == 'Special'
                  || SectionID == 'AllEvnt'
               )
               navdoc.images[i].src = 'p' + secname + currsrc.substr(currsrc.indexOf('.'));
               

      } // if starts with 'p' or 's'

   } // for each image

} // if in a frame
