
lev0 = new Array ("11","1",false,false,"darkblue","#D1EBFF","FEF1C0","arial, sans-serif;","darkblue") ;

NS4 = (document.layers) ;
IE4 = (document.all) ;
sAgent = navigator.userAgent;
if (sAgent.indexOf("Mac") > -1) {
	NS4 = false;
	IE4 = false;
}

function popUp () {return} ;
function popDown () {return} ;
function beg () {return} ;

if (!NS4 && !IE4) event = null ;

if (NS4 || IE4)
	{
	menuWidth = 160;
	borWid = 1;
	itemPad = 2;
	sep = 1;
	mout = true;
	borderCol = "#8080FF";
	}
	



imgStr = "" ;

loader = window ;

loader.onload = beg ;
stStr = new Array ('\\','|','/','-'+'-')
stPos = 0 ;
areCreated = false ;
menuLoc = null ;
trgLoc = null ;
topCount = 1 ;
beingCreated = false ;
isOverMenu = false ;
currentMenu = null ;
oldLinkEl = null ;

function beg ()
	{
		menuLoc = window ;
		trgLoc = window ;

	if (NS4)
		{
		return;
		}
	if (IE4)
		{
		if (mout)
			menuLoc.document.onmouseover = clicked ;
		  else
			menuLoc.document.onmousedown = clicked ;
		}
	beingCreated = true ;
	while( eval ("window.mn" + topCount))
		{
			createMnIE(topCount) ;
		topCount++
		}
	status = "" ;
	areCreated = true ;
	beingCreated = false ;
	}


function createMnIE (menuCount,parMenu)
	{
	menu = createEl ("elMenu" + menuCount) ;
	menu.array = eval ("mn" + menuCount) ;
	menu.lev = 0 ;
	menu.setMenuTree = setMenuTree ;
	menu.setMenuTree(parMenu) ;
	menu.itemStr = "" ;
	while (menu.itemCount < menu.maxItems)
		{
		menu.itemCount++ ;
		if (++stPos == stStr.length)
			stPos = 0 ;
		status = "Vytváří se menu... " + stStr [stPos] ;
		itemName = "item" + menuCount + "_" + menu.itemCount ;
		arrayPointer = (menu.itemCount-1) * 2 ;
		dispText = menu.array [arrayPointer] ;
		hasMore =0
		htmStr = (hasMore) ? imgStr + dispText : dispText ;
		mybg="blue";
		
		menu.itemStr += "<SPAN ID=" + itemName + " STYLE=\"background-color:blue; width:" + menu.menuWidth + "\">&nbsp;" + htmStr + "</SPAN><br>" ;
		}

	menu.innerHTML = menu.itemStr ;
	itemColl = menu.children.tags("SPAN") ;
	for (i = 0 ; i < itemColl.length ; i++)
		{
		it = itemColl(i) ;
		it.setup = createIt ;
		it.setup(i+1,menu.array) ;
		}
	menu.lastItem = itemColl (itemColl.length - 1) ;
	menu.setup (parMenu) ;
	}

function createIt (theItem,theArray)
	{
	this.onmouseover = itemOver ;
	this.onmouseout = itemOut ;
	this.container = this.offsetParent ;
	arrayPointer = (theItem - 1) * 2 ;
	this.dispText = theArray [arrayPointer] ;
	this.linkText = theArray [arrayPointer + 1] ;

	if (this.linkText)
		{this.onclick = linkIt ;
		this.style.cursor = "hand" ;
		}
	levArr = eval ("lev0") ;
	fntSizIE = levArr [0] ;
	fntBold = levArr [2] ;
	fntItal = levArr [3] ;
	fntFam = levArr [7] ;

		with (this.style)
			{
			padding = itemPad ;
			color = this.container.menuFontColor ;
			fontSize = fntSizIE ;
			fontWeight = (fntBold) ? "bold" : "normal" ;
			fontStyle =	(fntItal) ? "italic" : "normal" ;
			fontFamily = fntFam ;
			borderBottomWidth = sep + "px" ;
			borderBottomColor = "#E2BA1B" ;
			borderBottomStyle = "outset" ;
			backgroundColor = this.container.menuBGColor ;
		}
	}	

function createEl (theEl,theWidth,theParent,theContainer)
	{
		elStr = "<DIV ID=" + theEl + " STYLE='background-color: #00FF00;position: absolute;'></DIV>" ;
		menuLoc.document.body.insertAdjacentHTML("BeforeEnd",elStr) ;

	return eval (theEl) ;
	}

function setMenuTree (parMenu)
	{

	levArr = eval ("lev0") ;
	this.menuWidth = menuWidth ;
	this.menuFontColor = levArr [4] ;
	this.menuFontOver = levArr [6] ;
	this.menuBGColor = levArr [5] ;
	this.menuBGOver = levArr [8] ;
	this.menuBorCol = borderCol ;
		this.treeParent = this ;
		this.startChild = this ;


	this.maxItems = this.array.length/2 ;
	this.setup = menuSetup ;
	this.itemCount = 0 ;
	}

function ensureVis ()
	{

    		winRight = menuLoc.document.body.scrollLeft + menuLoc.document.body.clientWidth ;
		rightPos = this.style.pixelLeft + this.menuWidth ;
		if (rightPos > winRight)
			{
				dif = rightPos - winRight ;
				this.style.pixelLeft -= dif ;
			}
		winBot = menuLoc.document.body.scrollTop + menuLoc.document.body.clientHeight ;
		botPos = this.style.pixelTop + this.fullHeight ;
		if (botPos > winBot)
			{
			dif = botPos - winBot ;
			this.style.pixelTop -= dif ;
			}
		winLeft = menuLoc.document.body.scrollLeft ;
		leftPos = this.style.pixelLeft ;
		if (leftPos < winLeft)
			{
				this.style.pixelLeft = 5 ;
			
		}
	}

function menuSetup (hasParent,openCont,openItem)
	{
	this.onmouseover = menuOver ;
	this.onmouseout = menuOut ;
	this.showIt = showIt ;
	this.ensureVis = ensureVis ;
	this.hideTree = hideTree ;
	this.hideParents = hideParents ;
	this.hideTop = hideTop ;
	this.hasChildVisible = false ;
	this.isOn = false ;
	this.currentItem = null ;
	this.hideSelf = hideSelf ;
		
		this.hasParent = false ;

		with (this.style)
			{
			width = this.menuWidth ;
			borderWidth = borWid ;
			borderColor = this.menuBorCol ;
			borderStyle = "solid" ;
			}
		this.lastItem.style.border = "" ;
		this.fullHeight = this.scrollHeight ;
		this.showIt (false) ;
		this.onselectstart = cancelSelect ;
		this.moveTo = moveTo ;
		this.moveTo (0,0) ;		
		
	}

function menuOver ()
	{
	this.isOn = true ;
	isOverMenu = true ;
	currentMenu = this ;
	}

function menuOut ()
	{
	if (IE4)
		{
		theEvent = menuLoc.event ;
		if (theEvent.srcElement.contains (theEvent.toElement))
			return ;
		}
	this.isOn = false ;
	isOverMenu = false ;
	}

function popMenu (e)
	{
	if (!areCreated)
		return true;
	eType = (NS4) ? e.type : event.type ;
	hideAll () ;
	if (linkEl.menuName=="") return true;
	linkEl = (NS4) ? e.target : event.srcElement ;
	currentMenu = eval(linkEl.menuName) ;
	currentMenu.hasParent = false ;
	currentMenu.treeParent.startChild = currentMenu ;
	
		menuLocBod = menuLoc.document.body ;
		se = event.srcElement ;
		xPos = se.offsetLeft ;
		yPos = se.offsetTop ;
		xPos += se.offsetWidth + (mout ? 0 : 6) ;
		while (se.offsetParent)
			{
			if (se.offsetParent == se || se.offsetParent == document.body)
				break ;
			xPos += se.offsetParent.offsetLeft ;
			yPos += se.offsetParent.offsetTop ;
			se = se.offsetParent ;
			}
		xPos = 111;
		
	currentMenu.moveTo (xPos,yPos) ;
	currentMenu.ensureVis () ;
	currentMenu.isOn = true ;
	currentMenu.showIt (true) ;
	return false ;
	}


function popUp (menuName,e,myel)

	{
	if (!areCreated)
		return ;
	linkEl = (NS4) ? e.target : event.srcElement ;
	if (linkEl != oldLinkEl)
		oldLinkEl = linkEl ;
	  else
		return ;
	if (!beingCreated && !areCreated)
		beg () ;
	linkEl.menuName = menuName ;
	popMenu (e) ;
	}

function itemOut ()
	{
	
		theEvent = menuLoc.event ;
    		if (theEvent.srcElement.contains(theEvent.toElement) || (theEvent.fromElement.tagName=="IMG" && theEvent.toElement.contains(theEvent.fromElement)))
			return;
		this.style.backgroundColor = this.container.menuBGColor ;
		this.style.color = this.container.menuFontColor ;
		
	}

function itemOver ()
	{
	
		theEvent = menuLoc.event ;
		this.style.backgroundColor = this.container.menuBGOver ;
		this.style.color = this.container.menuFontOver ;
		
	this.container.currentItem = this ;

	}

function moveTo (xPos,yPos)
	{
	this.style.pixelLeft = xPos +10;
	this.style.pixelTop = yPos ;
	}

function showIt(on)
	{
	this.style.visibility = (on) ? "visible" : "hidden" ;
	this.currentItem = null ;
	}

function linkIt ()
	{
	trgLoc.location.href = this.linkText ;
	return false ;
	}

function popDown (menuName)
	{
	if (!areCreated)
		return ;
	theEl = eval (menuName) ;
	theEl.isOn = false ;
	if (!NS4 && !IE4)
		theEl.hideTop () ;
	}

function hideAll ()
	{
	for (i = 1 ; i < topCount ; i++)
		{
		temp = eval ("elMenu" + i + ".startChild") ;
		temp.isOn = false ;
		temp.showIt (false) ;
		}
	}

function hideTree ()
	{ 
	if (isOverMenu)
		return ;
	this.hideParents () ;
	}

function hideTop ()
	{
	theEl = this ;
	theEl.hideSelf() ;
	}

function hideSelf ()
	{
	if (!this.isOn && !isOverMenu)
		this.showIt (false) ;
	}

function hideParents ()
	{
	tempMenu = this ;
	tempMenu.hideTop () ;
	}


function cancelSelect ()
	{
	return false ;
	}

function clicked ()
	{
	if (!isOverMenu && currentMenu!=null && !currentMenu.isOn)
		{
		theEl = currentMenu ;
		theEl.hideTree () ;
		}
	oldLinkEl = null ;
	}
