﻿
function highlightCurrentLink() {
	page=document.location.href;
	
 	if (page.indexOf("categories") !=-1 )
 	{
	targetNode = document.getElementById("catNav");
	links = targetNode.getElementsByTagName("a");
	currentLocation=document.location.href;
	for (i=0; i<links.length; i++) 
	{
	linkHref = links[i].href;
		
		if (linkHref==currentLocation) 
		{
			links[i].setAttribute("className", "currentlink");
			links[i].setAttribute("class", "currentlink");   
		}
	}
	}

	else
	{
	if (page.indexOf("products") !=-1 )
	{
	catString = ("shopdisplaycategories\.asp?id");
	trail = document.getElementById("bread");
	link = trail.getElementsByTagName("a");
	for (i=0; i<link.length; i++) 
	{
	targeturl = link[i].href;
		if (targeturl.indexOf(catString) != -1) 
		{
		targetNode = document.getElementById("catNav");
		links = targetNode.getElementsByTagName("a");
		for (i=0; i<links.length; i++) 
		{
		sourceurl = links[i].href;
		//document.write(sourceurl + " targeturl is " + targeturl + "  ");
			if (sourceurl==targeturl) 
			{
			links[i].setAttribute("className", "currentlink");
			links[i].setAttribute("class", "currentlink"); 
			}
		}
		}
	}
	}

	}
}

// Piggy-back fucntion onto onLoad event ............................................
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(highlightCurrentLink);