var pocetMenuPolozka = 4;

function topListaInit() {
	if (document.getElementById("top-lista")) {
		topListaInitPremenne();
		topListaFunguj();
		document.getElementById("top-lista").style.visibility = "visible";
	}
}

function topListaInitPremenne() {
	topListaPozicia = new Array (0,0,0,0,0);
	topListaRychlost = new Array (0,0,0,0,0);
	topListaZrychlenie = new Array (0,0,0,0,0);
	topListaSkryta = new Array (true,true,true,true,true);
	topListaOtvorena = new Array (false,false,false,false,false);
	topListaTimeout = new Array (0,0,0,0,0)
}

function topListaVysunPolozku(idPolozky) {
	for (i=0; i<pocetMenuPolozka; i++) {
		if (!topListaSkryta[i]) {
			topListaZrychlenie[i] = -2;
			topListaOtvorena[i] = false
		}
	};
	topListaZrychlenie[idPolozky-1] = 2;
	topListaSkryta[idPolozky-1] = false;
	document.getElementById("top-lista-polozka_" + idPolozky).style.display = "block"
}

function topListaSkryPolozku(idPolozky) {
	if (!topListaSkryta[idPolozky-1]) {
		topListaZrychlenie[idPolozky-1] = -2;
		topListaOtvorena[idPolozky-1] = false
	}
}


function topListaFunguj() {
	for (i=0; i<pocetMenuPolozka; i++) {
		if ((!topListaSkryta[i]) && (!topListaOtvorena[i])) {
			topListaRychlost[i] += topListaZrychlenie[i];
			topListaPozicia[i] += topListaRychlost[i];
			if (topListaPozicia[i] > 63) {
				topListaOtvorena[i] = true;
				topListaTimeout[i] = 225;
				topListaRychlost[i] = 0;
				topListaZrychlenie[i] = 0;
 				topListaPozicia[i] = 64
			};
			if (topListaPozicia[i] < 1) {
				topListaSkryta[i] = true;
				topListaRychlost[i] = 0;
				topListaZrychlenie[i] = 0;
				topListaPozicia[i] = 0;
				document.getElementById("top-lista-polozka_" + (i + 1)).style.display = "none";
			};
			document.getElementById("top-lista-polozka_" + (i + 1)).style.top = (topListaPozicia[i] - 37) + 'px';
		};
		if (topListaOtvorena[i]) {
			topListaTimeout[i]--;
			if (topListaTimeout[i] == 0) {
				topListaOtvorena[i] = false;
				topListaZrychlenie[i] = -2
			}
		}
	};
	setTimeout("topListaFunguj()",10)
}

