/*
CLCP v2.1 Clear Links to Current Page
Jonathan Snook
This code is offered unto the public domain
http://www.snook.ca/jonathan/
*/

window.onload = clearCurrentLink;

function clearCurrentLink(){

    var nav = document.getElementById("menu");
    var a = nav.getElementsByTagName("A");
	var thispage=window.location.href.split("#")[0];
	if(thispage.charAt(thispage.length-1)=="/")
	{
		//We don't want the flags highlighted
		thispage+="index.html";
	}


	
    for(var i=0;i<a.length;i++)
	{
        if(a[i].href == thispage)
		{
			removeNode(a[i]);	
			/*var b=nav.getElementsByTagName("A");
			for(var j=0;j<b.length;j++)
			{
		        if(b[j].href == thispage)
				{
					//	removeNode(b[j]);
				}
			}*/
		}
	}
	
	//Do the same for topmenu
	var nav = document.getElementById("nav");
    var a = nav.getElementsByTagName("A");
	var thispage=window.location.href.split("#")[0];
	if(thispage.charAt(thispage.length-1)=="/") //We don't want the flags highlighted
		thispage+="index.html";


	
    for(var i=0;i<a.length;i++)
	{
        if(a[i].href == thispage)
			removeNode(a[i]);	
	}
}

function removeNode(n){
    if(n.hasChildNodes())
		n.parentNode.className="current";
		
    // gets the text from the link and moves it to the previous node.
        for(var i=0;i<n.childNodes.length;i++) {
                var strong = document.createElement('strong');
        var label = n.childNodes[i].cloneNode(true);
        strong.appendChild(label);
        n.parentNode.appendChild(strong);
}
    n.parentNode.removeChild(n);

}