// JScript source code

var objHyperlinkCollection;							// store a collecion of Menu Spans

function initializeTopMenu() 
{
	// Menu Span Style
	
	// get the Main Span "topMenu"

	mainSpan = document.getElementById("topMenu");

	if(mainSpan != null)
	{
		// get a collection of menus (Spans)
		objHyperlinkCollection = mainSpan.getElementsByTagName("a");
		
		// Iterate through all collected Spans i.e. objHyperlinkCollection
		for (var index = 0; index < objHyperlinkCollection.length; index++)
		{
			// objHyperlink is the current span during iteration 
			var objHyperlink = objHyperlinkCollection[index];
			
			// Assign the click event to every Menu Header
			//  objHyperlink.childNodes.item(0) = Div 1 = Menu Header
			
			
			
			var spanUrl = objHyperlink.href;
			var indexOfLastDot = spanUrl.lastIndexOf(".");
			
			if(indexOfLastDot >= 0)
			{
				spanUrl = spanUrl.substring(0, indexOfLastDot);
			}
			

			var url = window.location.href.toLowerCase();
			var foundAtIndex = url.indexOf(spanUrl.toLowerCase());
			//alert(url);	
			//alert("windows url: " + url + "   spanurl: " + objHyperlink.href + " found at" + foundAtIndex);
			if(foundAtIndex == 1)
			{
				objHyperlink.className = "menulink1";
				if(objHyperlink.id == 'aIndex')
				{
					
					var objtrBottom = document.getElementById("trBottom");
					objtrBottom.style.display = 'none';
				}	
				else
				{
								
					var objtrBottom = document.getElementById("trBottom");
					objtrBottom.style.display = '';
				}
				
			}
			else if((url.indexOf('buyonline') > 0  && spanUrl.indexOf('store') > 0) || (spanUrl.indexOf('AboutHC') > 0  && (url.indexOf('/press') > 0 || url.indexOf('publications') > 0 || url.indexOf('partners') > 0 || url.indexOf('customers') > 0)))
			{
				objHyperlink.className = "menulink1";
				if(objHyperlink.id == 'aIndex')
				{
					
					var objtrBottom = document.getElementById("trBottom");
					objtrBottom.style.display = 'none';
				}	
				else
				{
								
					var objtrBottom = document.getElementById("trBottom");
					objtrBottom.style.display = '';
				}
			}
			else
			{
				objHyperlink.className = "menulink";
			}
		}
		
		
	}
}

function topMenuHandler()
{
	
	for (var index = 0; index < objHyperlinkCollection.length; index++)
	{
		var objHyperlink = objHyperlinkCollection[index];
		//alert("old: " +  objHyperlink.href + " :: " +  objHyperlink.id + " :: " + objHyperlink.parentNode.className);
		objHyperlink.className = "menulink";
		//alert("new: " +  objHyperlink.href + " :: "+ objHyperlink.parentNode.className);
	}
	this.className = "menulink1";
	
}
