﻿
/***************************************************************

    Created By: Asa Sherrill <asa.sherrill@definition6.com>
    Date: 2/6/2006
    
    Page Based Highlighting is intended to be used with
    non-home page submenus. The script determines the 
    page based on the URL and checks it directly against 
    the href attribute of registered menu elements.
    
    If the href attribute is found in the url string then
    the element is granted a pre-determined style.'
    
    * Keep in mind that using server side resolution of urls 
    in ASP.NET 2.0 will result in altered IDs. 
    
    ** Also, using relative pathing will be helpful here
    in creating portability of this javascript.
    
*****************************************************************/

var MAXIMUM_ELEMENTS = 30;

var arr_RegisteredList = new Array( MAXIMUM_ELEMENTS );
var int_ListPointer = 0;
    
var str_SubOnClass = "PageBasedHighlighting_On";
var str_SubOffClass = "PageBasedHighlighting_Off";
    
/*****************************************************************/


function registerItem ( elementID ) {
/* Adds a menu item to the list to be considered
   by the algorithm */

    if ( int_ListPointer >= MAXIMUM_ELEMENTS ) {
        alert ( elementID + " was not registered. There is no more room in the array." );
    } else {
        arr_RegisteredList[ int_ListPointer ++ ] = elementID;
    }

}

function declareSubStateClasses ( offState, onState ) {
// Manually change the off and on state classes

  str_SubOnClass = onState;
  str_SubOffClass = offState; 
  
}


function subHighlight ( ) {
// Core Method
    
    var urlString = document.URL.toLowerCase();
    var cnt = 0;
    
    for ( var x = 0; x < int_ListPointer; x ++ ) {
    
         var tmpObj = document.getElementById ( arr_RegisteredList[x] );
      
         if ( urlString.indexOf ( tmpObj.href.toLowerCase() ) >= 0 ) {
     
            // Apply on-class to this element     
            tmpObj.className = str_SubOnClass;
                 
         } else {
         
            // Apply off-class to this element
            tmpObj.className = str_SubOffClass;
         } 
    }
}



