var i = 0;
var j = 0;

function start() {
	var navRootElement = document.getElementById("topnav");
    for (i=0; i<navRootElement.childNodes.length; i++){
         var node = navRootElement.childNodes[i];
         if (node.nodeName=="LI"){
			 
			var onMouseOver = node.firstChild.getAttribute('onmouseover');
			var onMouseOut = node.firstChild.getAttribute('onmouseout');	
			
			var id=node.className;
			var sId=id.replace("t","s");
			
			if(node.getAttribute('id') == 'tnav-act'){
				var actElement = document.getElementById(node.getAttribute('id'));
				var secActElement = document.getElementById(sId);
				var actImg = actElement.firstChild.firstChild.getAttribute("name");
				actElement.firstChild.setAttribute("onmouseover", "void(0);"); 
				actElement.firstChild.setAttribute("onmouseout", "void(0);"); 
				
			} 
			if(document.getElementById(sId) && node.getAttribute('id') != 'tnav-act'){
				var navSecElement = document.getElementById(sId);
				
				navSecElement.setAttribute("onmouseover", onMouseOver); 
				navSecElement.setAttribute("onmouseout", onMouseOut); 

				for (j=0; j<navSecElement.childNodes.length; j++)
      			{
					 var snode = navSecElement.childNodes[j];
					 if (snode.firstChild.nodeName=="A"){
						snode.firstChild.setAttribute("onmouseover", onMouseOver); 
						snode.firstChild.setAttribute("onmouseout", onMouseOut); 
					 }
					 
				}
			}
			node.onmouseover=function()
            {
				if(this.getAttribute('class') != 'tnav-act'){
					if (version == "n3" && document[actImg]) {document[actImg].src = eval(actImg+"_h.src");}
					else if (document.getElementById && document.getElementById(actImg)) {document.getElementById(actImg).src = eval(actImg+"_h.src");}
					if(secActElement) secActElement.style.left = '-10000px';
					var actId=this.className;
					var actsId=actId.replace("t","s");
					var snavWidth = this.firstChild.firstChild.getAttribute("width");
					if(this.firstChild.nextSibling.getAttribute("id") != null){
						var snavId = this.firstChild.nextSibling.getAttribute("id");
						//document.getElementById(snavId).style.width = (snavWidth-10)+'px';
						//document.getElementById(snavId).style.minWidth = (snavWidth-10)+'px';
						//document.getElementById(snavId).style.maxWidth = (snavWidth-10)+'px';
					}
					if(document.getElementById(actsId)) document.getElementById(actsId).style.left = 'auto';
				}
            }
            node.onmouseout=function()
            {
				if(this.getAttribute('class') != 'tnav-act'){
					if (version == "n3" && document[actImg]) {document[actImg].src = eval(actImg+"_n.src");}
					else if (document.getElementById && document.getElementById(actImg)) {document.getElementById(actImg).src = eval(actImg+"_n.src");}
					if(secActElement) secActElement.style.left = 'auto';
					var actId=this.className;
					var actsId=actId.replace("t","s");
					if(document.getElementById(actsId)) document.getElementById(actsId).style.left = '-10000px';
				}
            }
		}
	}
}
window.onload = function()
{
	start();
};

function openFlag(){
	var dropFlag = document.getElementById("countrynav");
	if(dropFlag.style.overflow == 'visible'){
			dropFlag.style.overflow = 'hidden';
	} else {
		dropFlag.style.overflow = 'visible';
	}
}

function showNL(){
	var layerNL = document.getElementById("layer-nl");
	if(layerNL.style.display == 'block'){
		layerNL.style.display = 'none';
	} else {
		layerNL.style.display = 'block';
	}

}

function openBullet(id){
	var bulletContent = document.getElementById("cbullet-"+id);
	if(bulletContent.style.display == 'block'){
		bulletContent.style.display = 'none';
	} else {
		bulletContent.style.display = 'block';
	}
}
function openDropdownText(id){
	var dropdownContent = document.getElementById("dropdowntext-"+id);
	if(dropdownContent.style.display == 'block'){
		dropdownContent.style.display = 'none';
	} else {
		dropdownContent.style.display = 'block';
	}
}
