function hereYouAre()
{
    if( tag = document.location.href.match( /.*\/(.+?).html/ ) )
        tag = tag[1];
    else
        return; //we must be on the index page if no tag was found
    
    crumbs = tag.split('-');
    
    // get rid of any numbers as the last crumb
    if( crumbs[ crumbs.length-1 ].match( /\d+/ ) )
    	crumbs.pop();	
    
    // if we have one crumb, double up
    // so we can get the identical link on the second
    // nav bar (the '+' link in site_config.p)
    if( crumbs.length == 1 )
        crumbs.push( crumbs[0] );
    
    var currentList = document.getElementById('udm');

    // for each crumb we will go deeper in the list
    for( i=0; i < crumbs.length; i++)
    {
        if (!currentList)
        {
            break;
        }
        listItems = currentList.getElementsByTagName('LI')
        
        for( j=0; j < listItems.length ; )
        {
            currLink = listItems[j].getElementsByTagName('A')[0];
            
            // if our current link contains 'crumb.html'
            if( currLink.href.indexOf(crumbs[i]+'.html') != -1 )
            {
                // we've found a crumb link, so mark it
                listItems[j].className += ' hereYouAre';
                
                childList = listItems[j].getElementsByTagName('UL');
                
                // if there is an UL below this one, let the loop catch it
                if( childList.length > 0 )
                    currentList = childList[0];
                else
                    break; // if no deeper list, return from function
                 
                break;  // we are done with this j-loop, next crumb please
            }
            else if( ++j == listItems.length )
            {
            	// if we are on a third-level page
                if( crumbs.length == 3 )
              	{
              		// decrement i (so we redo the third level )
              		i--;
              		// set the sidenav to the current list
              		currentList = document.getElementById('sideNav');
              	}
              	else		
 	               return; // if we are on the last j-loop and we haven't found the crumb
            }
        }
    }   
}


if( window.addEventListener )
{
    window.addEventListener('load', hereYouAre, false);
}
else if (window.attachEvent){    window.attachEvent('onload', hereYouAre);}

