var cssmenuid="cssmenu1"
var cssmenuids=[cssmenuid]
var csssubmenuoffset=22 //Offset of submenus from main menu. Default is 0 pixels.


function findpage(arr) {
	//já?
	if (window.location.href.search(arr[1])>-1) return true;
	//child?
	var l;
	for(l=3;l<arr.length;l++){
		if (arr[l].length>3) if (findpage(arr[l])) return true;
		if (window.location.href.search(arr[l][1])>-1) return true;
	}
	return false;
}




function node(arr) {
	var new_ul=document.createElement("ul");
	new_ul.style.visibility="hidden"
	var l;
	for(l=3;l<arr.length;l++){

			var new_li=document.createElement("li");
			var new_a=document.createElement("a");
				new_a.setAttribute("href", arr[l][1]);
				new_a.setAttribute('target', arr[l][2]);
				new_a.innerHTML = arr[l][0];
				//if (window.location.href.search(arr[l][1])>-1) {
				if (findpage(arr[l])) {
					//new_a.style.textDecoration = "underline";
					new_li.style.backgroundColor = "#F0F9FF";
					//new_li.style.background = "url(../img/lay_top_menusel.gif) center center repeat-x";
					new_a.style.color = "#16498a";
				}
				new_li.appendChild(new_a);
				//navi
				if (findpage(arr[l])) {
					var navi_a=document.createElement("a");
						navi_a.setAttribute("href", arr[l][1]);
						navi_a.setAttribute('target', arr[l][2]);
						navi_a.innerHTML = arr[l][0];
						document.getElementById("page_navi").innerHTML += " &raquo; ";
						document.getElementById("page_navi").appendChild(navi_a);
				}
				if (arr[l].length>3){
					var spanref=document.createElement("span")
						spanref.className="arrowdiv"
						spanref.innerHTML="&nbsp;&nbsp;&raquo;&nbsp;"
						spanref.style.textDecoration = "none"
		//				spanref.innerHTML="&nbsp;&nbsp;&nbsp;" + ultags[t].parentNode.parentNode.id
		//			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
						new_li.getElementsByTagName("a")[0].appendChild(spanref)
					//----------
					new_li.appendChild(node(arr[l]));
					new_li.onmouseover=function(){
								//this.getElementsByTagName("a")[0].style.background = "url(../img/lay_top_menubgo.gif) center bottom repeat-x"
								//this.style.background = "url(../img/lay_top_menubgo.gif) center center repeat-x"
								//this.style.border = "1px solid #D0D0D0"
								this.style.zIndex=1000
								this.getElementsByTagName("ul")[0].style.visibility="visible"
								this.getElementsByTagName("ul")[0].style.zIndex=0
					}
					new_li.onmouseout=function(){
								//this.getElementsByTagName("a")[0].style.background = "none"
								//this.style.border = "1px none #D0D0D0"
								this.style.zIndex=0
								this.getElementsByTagName("ul")[0].style.visibility="hidden"
								this.getElementsByTagName("ul")[0].style.zIndex=1000
					}
				}
				new_ul.appendChild(new_li);
	}
	return new_ul;	
}

function nodev(arr) {
	var new_ul=document.createElement("ul");
//	new_ul.style.visibility="hidden"
	var l;
	for(l=3;l<arr.length;l++){

			var new_li=document.createElement("li");
			var new_a=document.createElement("a");
				new_a.setAttribute("href", arr[l][1]);
				new_a.setAttribute('target', arr[l][2]);
				new_a.innerHTML = arr[l][0];
				//if (window.location.href.search(arr[l][1])>-1) {
				if (findpage(arr[l])) {
					new_a.style.textDecoration = "underline";
					//new_a.style.backgroundColor = "#F0F9FF";
					//new_li.style.background = "url(../img/lay_top_menusel.gif) center center repeat-x";
					new_a.style.color = "#16498a";
				}
				new_li.appendChild(new_a);
				if (arr[l].length>3){
					new_li.appendChild(nodev(arr[l]));
				}
				new_ul.appendChild(new_li);
	}
	return new_ul;	

}
				




function create_hmenu(){
	//navi
	if (document.getElementById('page_navi') != null){
		var navi_a=document.createElement("a");
			navi_a.setAttribute("href", "../docs/index.htm");
			navi_a.setAttribute('target', "_top");
			navi_a.innerHTML = "Domů";
			document.getElementById("page_navi").innerHTML = "Právě se nacházíte: ";
			document.getElementById("page_navi").appendChild(navi_a);
	}
	//hmenu
	var new_content=document.createElement("ul");
		new_content.id=cssmenuid;
	var i;
	for(i=0;i<TREE_NODES.length;i++){
		//alert (TREE_NODES[i][0]);
			var new_li=document.createElement("li");
			var new_a=document.createElement("a");
				new_a.setAttribute('href', TREE_NODES[i][1]);
				new_a.setAttribute('target', TREE_NODES[i][2]);
				if (findpage(TREE_NODES[i])) {
					//new_a.style.borderTop = "1px solid #16498a";
					new_a.style.background = "url(../img/lay_top_menusel.gif) center center repeat-x";
					//new_a.style.backgroundColor = "#FFFFFF";
					new_a.style.color = "#16498a";
					//navi
					if (document.getElementById('page_navi') != null){
						var navi_a=document.createElement("a");
							navi_a.setAttribute("href", TREE_NODES[i][1]);
							navi_a.setAttribute('target', TREE_NODES[i][2]);
							navi_a.innerHTML = TREE_NODES[i][0];
							document.getElementById("page_navi").innerHTML += " &raquo; ";
							document.getElementById("page_navi").appendChild(navi_a);
					}
					//menuv
					if (document.getElementById('menuv') != null){
						var mv_a=document.createElement("a");
							mv_a.setAttribute("href", TREE_NODES[i][1]);
							mv_a.setAttribute('target', TREE_NODES[i][2]);
							mv_a.innerHTML = TREE_NODES[i][0];
							mv_a.style.color = "#16498a";
							mv_a.style.fontSize = "12px";
							mv_a.style.fontWeight = "bold";
							mv_a.style.textDecoration = "underline";
							document.getElementById("menuv").appendChild(mv_a);
							document.getElementById("menuv").innerHTML += " <br /> ";
						document.getElementById("menuv").appendChild(nodev(TREE_NODES[i]));
					}
				}
				new_a.innerHTML = TREE_NODES[i][0];
				new_li.appendChild(new_a);
				if (TREE_NODES[i].length>3){
					new_li.appendChild(node(TREE_NODES[i]));
					new_li.getElementsByTagName("ul")[0].style.top=csssubmenuoffset+"px";
					new_li.onmouseover=function(){
								//this.getElementsByTagName("a")[0].style.background = "url(../img/lay_top_menubgo.gif) center bottom repeat-x"
								this.style.zIndex=100
								this.getElementsByTagName("ul")[0].style.visibility="visible"
								this.getElementsByTagName("ul")[0].style.zIndex=0
					}
					new_li.onmouseout=function(){
								//this.getElementsByTagName("a")[0].style.background = "none"
								this.style.zIndex=0
								this.getElementsByTagName("ul")[0].style.visibility="hidden"
								this.getElementsByTagName("ul")[0].style.zIndex=100
					}
				}
					
					
					
			new_content.appendChild(new_li);
		if (i<TREE_NODES.length-1){
			var new_li=document.createElement("li");
			new_li.innerHTML = "|";
			new_content.appendChild(new_li);
		}
	}



	document.getElementById("menuh").appendChild(new_content);

}
