var includeSiteSection;
var imagesFolder;
var imageExtension;
var imageName;
var imageReplacement;
var pageName;
var siteSection;
                                       // imageTypes is a array of 
                                       //          a) Image Name
                                       //          b) Include siteSection on image Name
                                       //          c) Image subfolder
                                       //          d) Image extensions
                                       //          e) Replacement Image
var imageTypes     = new Array(new Array("menu-bar-underline", true,  "images/gif/",  ".gif", "images/gif/single-transparent-pixel.gif"), 
                               new Array("menu-photo",         false, "images/jpeg/", ".jpg", null), 
                               new Array("menu-testimonial",   false, "images/gif/",  ".gif", null));
var noOfTypes      = imageTypes.length;
var siteSections   = new Array("home", "nonprofit", "business", "personal", "links", "feedback", "sitemap");
var noOfImages     = siteSections.length;

function initializePage(currentPage)
{

   if (currentPage)                       // Is the page associated with a menu item??
   {
      pageName = currentPage;
      
                                       // Does the browser support images, 
      if (document.images)
      {
         document.images["menu-bar-" + currentPage.toLowerCase()].src = "images/gif/menu-bar-" + pageName.toLowerCase() + "-highlighted.gif";
         document.images[imageTypes[0][0] + "-" + pageName.toLowerCase()].src = "images/gif/single-white-pixel.gif";
         document.images[imageTypes[1][0]].src = "images/jpeg/menu-photo-" + pageName.toLowerCase() + ".jpg";
         document.images[imageTypes[2][0]].src = "images/gif/menu-testimonial-" + pageName.toLowerCase() + ".gif";
         loadRolloverImages();
      }                                // if (document.images)

   }
   else
   {
      pageName = "Home";
   }                                   // if (null != currentPage)

}                                      // function initializePage

function loadRolloverImages()
{
   var rollOverImages = new Array(noOfImages);
  
   for (var typeNo = 0; typeNo < noOfTypes; typeNo++)
   {
      imageName          = imageTypes[typeNo][0];
      includeSiteSection = imageTypes[typeNo][1];
      imagesFolder       = imageTypes[typeNo][2];
      imageExtension     = imageTypes[typeNo][3];

      for (var imageNo = 0; imageNo < noOfImages ; imageNo++)
      {
         siteSection = "-" + siteSections[imageNo];
         typeName = imageName + (includeSiteSection ? siteSection : "" );

         rollOverImages[typeName]     = new Image();
         rollOverImages[typeName].src = imagesFolder + typeName + (includeSiteSection ? "" : siteSection) + imageExtension;

      }                                // for (var typeNo = 0; typeNo < = NoOfTypes; typeNo++)

   }                                   // for (var imageNo = 0; imageNo < noOfImages ; imageNo++)
   

}                                      // loadRolloverImages()

function rollOver(imageType)
{
                                       // Does the browser support images, 
                                       //    is there an image to use for the replacement, 
                                       //    we aren't on thhe page already and
                                       //    there is an image to replace??
   if ((document.images) && (null != pageName) && (null != imageType) && (imageType != pageName))
   {
                                       // Yes, replace it
      for (var typeNo = 0; typeNo < noOfTypes; typeNo++)
      {
         imageName          = imageTypes[typeNo][0];
         siteSection        = "-" + imageType.toLowerCase();

         document.images[imageName + (imageTypes[typeNo][1] ? siteSection : "")].src = 
            imageTypes[typeNo][2] + imageName + siteSection + imageTypes[typeNo][3];

      }                                // for (var typeNo = 0; typeNo < noOfTypes; typeNo++)

   }                                   //    if ((null != pageName) && (null != imageName) && (imageName != pageName))

}                 		               // function rollOver

function rollOut(imageType)
{
                                       // Does the browser support images, 
                                       //    is there an image to use for the replacement, 
                                       //    we aren't on thhe page already and
                                       //    there is an image to replace??
   if ((document.images) && (null != pageName) && (null != imageType) && (imageType != pageName))
   {
                                       // Yes, replace it
      for (var typeNo = 0; typeNo < noOfTypes; typeNo++)
      {
         imageName          = imageTypes[typeNo][0];
         imageReplacement   = imageTypes[typeNo][4];

         document.images[imageName + (imageTypes[typeNo][1] ? "-" + imageType.toLowerCase() : "")].src = 
            (imageReplacement != null ? imageReplacement : imageTypes[typeNo][2] + imageName + "-" + pageName.toLowerCase() + imageTypes[typeNo][3]);

      }                                // for (var typeNo = 0; typeNo < noOfTypes; typeNo++)

   }                                   //    if ((null != pageName) && (null != imageName) && (imageName != pageName))

}                 		               // function rollOut
