var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var sPage = sPage.substring(sPage.lastIndexOf('\\') + 1);
var displaylang = "";
var displayname = "";
var dropmenuobj;

function changeClass(obj, cname){
		obj.className= cname;
}

function gensubmenu(what){
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	var b=0;
	var submenuhtml="";
	if (ie4 ){
		b=0;
		var oTable = document.createElement("TABLE");
	  var oRow, oCell;
	  var i, j;
		var oTBody0 = document.createElement("TBODY");
		oTable.appendChild(oTBody0);
 		
	 	oTable.width=what[1];
		oTable.className=what[2];
		oTable.cellPadding=0;
		oTable.cellSpacing=0;
		oTable.border=0;
		for(b=1;b<what.length-10;b++){
			oRow = document.createElement("TR");
    	oTBody0.appendChild(oRow);
    	
 			oCell = document.createElement("TD");
 			oCell.className=what[b+10][2][0];
 			
 			//oCell.onmouseover= function() {
			///	changeClass(this,what[b+10][2][1]);
			//}
//'changeClass(this,\"'+what[b+10][2][1]+'\");'; //'this.className=\"'+what[b+10][2][1]+'\";';
			oCell.onmouseover='this.className=\"'+what[b+10][2][1]+'\";';
 			oCell.onmouseout='this.className=\"'+what[b+10][2][0]+'\";';
 			//oCell.onmouseout= function() {
			//	changeClass(this,what[b+10][2][0]);
			//}
 			
 			var cellhtml="";
 			if(what[b+10][1]!=""){
				cellhtml=cellhtml+'<a href="'+what[b+10][1]+displaylang+'" class="'+what[b+10][2][2]+'">';
				cellhtml=cellhtml+what[b+10][0];
				cellhtml=cellhtml+'</a>';
			} else {
				cellhtml=cellhtml+'<span class="'+what[b+10][3]+'">';
				cellhtml=cellhtml+what[b+10][0];
				cellhtml=cellhtml+'</span>';
			}
      oCell.innerHTML = cellhtml;// alert(oCell.outerHTML);
			oRow.appendChild(oCell);

		}
		dropmenuobj.innerHTML="";
	
		dropmenuobj.appendChild(oTable) ; 
	}
	
	else { //if (ns6)
		b=0;
		
		submenuhtml='<table width='+what[1]+' class="'+what[2]+'" cellpadding=0 cellspacing=0 border=0>';
		for(b=1;b<what.length-10;b++){
			submenuhtml=submenuhtml+'<tr><td class="'+what[b+10][2][0]+'" onMouseover=\'this.className=\"'+what[b+10][2][1]+'\"\' onMouseout=\'this.className=\"'+what[b+10][2][0]+'\"\'>'
		
			if(what[b+10][1]!=""){
				submenuhtml=submenuhtml+'<a href="'+what[b+10][1]+displaylang+'" class="'+what[b+10][2][2]+'">';
				submenuhtml=submenuhtml+what[b+10][0];
				submenuhtml=submenuhtml+'</a></td></tr>';
			} else {
				submenuhtml=submenuhtml+'<span class="'+what[b+10][3]+'">';
				submenuhtml=submenuhtml+what[b+10][0];
				submenuhtml=submenuhtml+'</span></td></tr>';
			}
		}
		
		submenuhtml=submenuhtml+'</table>';
		dropmenuobj.innerHTML= submenuhtml;
	}
		//alert(dropmenuobj.id);
		//alert(dropmenuobj.innerHTML);
}
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
		document.write('<div id="dropmenudiv" style="z-Index:100; visibility:hidden;position:absolute;" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')




function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500

	//if (menuwidth!=""){
	//dropmenuobj.widthobj=dropmenuobj.style
	//dropmenuobj.widthobj.width=menuwidth
	//}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
			var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
			var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
			dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
	//edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	//alert (edgeoffset)
	return edgeoffset
}


function dropdownmenu(obj, e, menucontents, menuwidth){
//alert(menuwidth)
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	gensubmenu(menucontents, null)

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.style.left=getposOffset(obj, "left");
		dropmenuobj.style.top=getposOffset(obj, "top")+obj.offsetHeight;
		dropmenuobj.style.width = menuwidth;
	}
	dropmenuobj.style.visibility="visible"

	return clickreturnvalue()
}


function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
//genmenu();
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
	document.onclick=hidemenu