
window.onload = function highlightLink(){

	//Get filename from the URL
	thisPage = document.URL.substring(document.URL.lastIndexOf("/")+1 ,document.URL.length);
	//alert(thisPage);
	
	//if (thisPage == ""){
	//document.getElementById("nav1").className = "current1";
	//}

	//Loop through all the links
	//alert(document.links.length);
	for (i=0; i<document.links.length; i++ )
	{
		//Get only the filename from the href of navigation link
		pageLink = document.links[i].href.substring(document.links[i].href.lastIndexOf("/")+1 ,document.links[i].href.length);
		//
		//alert(pageLink);
		//if the current filename & the link-ed file name are the same, change the background color of that link

		navnum = i;
		
		//alert(navnum);

		if (thisPage == pageLink)
		{
			//BG is the name of a class that I have defined, that sets background color to grey
			
			//top nav
			if(navnum <= 5){
			document.links[i].className = "current" + navnum;
			}
			
			//cart icon
			if(navnum == 6){
			document.links[i].className = "cart_icon_current";
			}
			
			//side
			if(navnum > 6){
			navnum--; //adjusted after adding the cart icon link to save time in editing multiple class names
			document.links[i].className = "sidecurrent" + navnum;
			}
			
			
			//alert (document.links[i].className);
			//alert (document.links.length);
		}

	}
}

