﻿// JavaScript in the footer of every page.
//
// Author:		John Bunch, StaffMe.net
// History:
//   07-07-2006	John Bunch    Module created.

// Allows links to the business model to open it in a new window.
function business_model() {
  window.open('/Flash/Business_Model.swf', 'Business_Model', 'height=500,width=717');
  return false;
}

// LINK ALTERATIONS.
// Remove, from the normal flow, the hidden images read by screen readers to provide
// the ability to skip the menu.  These are used by the Menu control and the Wizard controls.
// This is only necessary for Internet Explorer, and it would cause a problem in Firefox.
if (navigator.appName.indexOf("Microsoft") != -1)
  // Find the hyperlinks that end in "SkipLink" and change their positioning.
  for (var i = 0; i < document.links.length; ++i) {
    var a = document.links[i];
    if (a.href.slice(-8) == "SkipLink") {
      a.style.position = "absolute";
    }
  }
// If this is a secure page, change all "http:" links to "https:".
if (location.protocol == "https:")
  for (var i = 0; i < document.links.length; ++i) {
    var a = document.links[i];
    if (a.href.slice(0, 5) == "http:") {
      a.href = "https:" + a.href.slice(5);
    }
  }

// Whenever the cursor hovers over a dynamic menu item that has a submenu, change the image
// to a white arrow, then change it back to a charcoal arrow when the cursor leaves.
// Also set the arrow's dimensions.
// Input parameter:
//   Company_Division:  A copy of the session variable having the same name,
//                      but in a global JavaScript variable.

// The onmouseover event handler for a dynamic menu item having a submenu.
function Super_Menu_HoverDynamic() {
  // Locate the image within this menu item.
  var img = document.getElementById(this.id + '_img');
  // Put in a white arrow.  The matte is based on division_background_color, so the company
  // division is part of the image's filename.
  img.src = location.protocol + '//' + window.location.host + '/Images/Arrows/'
          + 'White_Arrow_' + Company_Division + '_Matte.gif';
  // Call the original ASP.NET function.
  Menu_HoverDynamic(this);
}
// The onmouseout event handler for a dynamic menu item having a submenu.
function Super_Menu_Unhover() {
  // Locate the image within this menu item.
  var img = document.getElementById(this.id + '_img');
  // Restore the charcoal arrow.
  img.src = location.protocol + '//' + window.location.host + '/Images/Arrows/Charcoal_Arrow.gif';
  // Call the original ASP.NET function.
  Menu_Unhover(this);
}
// Prepare the submenu images.
var images = document.getElementsByTagName("img");
for (var i in images) {
  var img = images[i];
  if (img.alt == "Submenu") {
    // Set the arrow's width and height to speed up the rendering of the page.
    img.width = 6
    img.height = 7
    // Locate the dynamic menu item containing the image.
    var menu_item = img.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
    // Assign an ID to the image, based on the menu item's ID.
    img.id = menu_item.id + '_img'
    // Replace the event handlers with my own versions that will also change the image.
    menu_item.onmouseover = Super_Menu_HoverDynamic
    menu_item.onmouseout = Super_Menu_Unhover
  }
}
