var stopArray=0,lang='sk';
var maxCountLevel=4;
//pole stringov zlozenych z indexov viditelnych menu v jednotlivych leveloch
var visibleInLevel, timeShow, delayRunning;
var xMouse,yMouse;
var initDone=false;

//---
var delayRunning=false;
var timeShow,startX=98,startY=161;
var menuNames=new Array("mn_shop");
var menuStartX,pageWidth;
var mn_shops_sk=261;

function Browser() {
	var b=navigator.appName;
	if (b.indexOf('Netscape')!=-1) this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser.\nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6.0')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is=new Browser();

if (is.ns || is.ie)
{
  document.onmousemove = mouseMove;
  if (is.ns) document.captureEvents(Event.MOUSEMOVE);
}

function mouseMove(e)
{
  if (is.ns) {xMouse=e.pageX; yMouse=e.pageY;}
  if (is.ie) {xMouse=event.x; yMouse=event.y;}
  if (is.ie5 || is.ie6) {xMouse=event.x+document.body.scrollLeft; yMouse=event.y+document.body.scrollTop;}
}

//init array parMLev - maximalne levelov
//zakladne menu na html nie je zaratene v level (-1)
function initMenu(parMLev,pageW,startYP)
{
	maxCountLevel = parMLev;
  if (startYP>0) startY=startYP;
  //lang=langPar;
  //if (langPar==null) lang='sk';
	visibleInLevel = new Array( maxCountLevel );
	timeShow = new Array( maxCountLevel );
	delayRunning = new Array( maxCountLevel );
	for(var i=0;i<visibleInLevel.length;i++)
	{
	  visibleInLevel[i] = "no";
		delayRunning[i] = false;
	}
  pageWidth=pageW;
  resizeMenu();
  initDone=true;
}
function resizeMenu(){
	var scrW=is.ie ? document.body.clientWidth : document.body.offsetWidth;
  scrW=(scrW>0) ? scrW : screen.width;
  startX=(scrW-pageWidth)/2;
}
function startDelay(parLevel)
{
	if (!initDone) return;
 //stopDelay(parLevel);
 delayRunning[parLevel] = true;
 eval( " timeShow[parLevel] = setTimeout('hideAllMenuInLevel("+parLevel+")',1000); ");
}

//stop delay for all down level 
function stopDelay(parLevel)
{			
	for(var i=0;i<=parLevel;i++)
	if (delayRunning[i])
	{
	 clearTimeout(timeShow[i]);
	 delayRunning[i] = false;
	} 
}
/* showing the menu table*/
function showMenu(parMenuName,parMenuLevel,action) 
{
	if (!initDone) return;
		menuStatus = (visibleInLevel[parMenuLevel]==parMenuName) ? 1 : 0;
    eval(" var thisX="+parMenuName+"_"+lang+"+startX;");
		/*if (action==0 && activeMn!=-1){
			 myClearDelay()
			 mnWindow(activeMn, 2);
		}*/	   
		if (menuStatus==0)// if hidden
		{ 
			 hideAllMenuInLevel(parMenuLevel);
			 visibleInLevel[parMenuLevel] = parMenuName;
        activeWin=document.getElementById(parMenuName).style;
        activeWin.visibility="visible";
        moveTo(thisX,startY);
      stopDelay(parMenuLevel);
		}
		else
		{
		//schova vsetky dalsie submenu ak idem mysou na uz otvorene menu
  		hideAllMenuInLevel(parMenuLevel+1);
  		if (action=='hide')
  		{
  		  visibleInLevel[parMenuLevel]="no";
        activeWin=document.getElementById(parMenuName).style;
        activeWin.visibility="hidden";
  		}
		}
}

function hideAllMenuInLevel(parLevel)
{
 		for(var i=parLevel;i<maxCountLevel;i++)
		{
 		 	if (visibleInLevel[i]!="no")
			   showMenu( visibleInLevel[i], i, "hide" );
		}
}

function moveTo(xL,yL)
{
  if (xL>-1) activeWin.left = xL;
  if (yL>-1) activeWin.top = yL;
}
