
//apartat estą definit a la pągina php
//var iApartat;	//1-lanuvia, 2-elnuvi, 3-elsnuvis, ...

var gHome = 0;

var menu1_inicialitzat = false;

function initMenu1(home)
{
	gCapes["fletxaMenu1"] = MM_findObj("fletxaMenu1Div");
	if (home == "home") gHome = 1;
	menu1_inicialitzat = true;
}

var gMovimentFletxaMenu1 = 0;	// 0-quieta, 1-lanuvia, 2-elnuvi, 3-elsnuvis, ...

var gN = -1;
var gTop = 12;
var gTimerFletxaMenu1 = 0;
var distOp = 25;

function opMenu1(sobre, op)
{
	if (!menu1_inicialitzat) return;
	if (gHome == 1)
	{
		if (sobre == 0){
			gN = -1;
			gCapes["fletxaMenu1"].style.visibility = "hidden";
		}
		else{
			gTop = -8 + op*distOp;
			gN = 4;
			if(gTimerFletxaMenu1>0)	clearTimeout(gTimerFletxaMenu1);
			mostraOcultaFletxaMenu1();
		}
	}
	else
	{
		if (sobre == 0) op = iApartat;
		
		if (gMovimentFletxaMenu1 == 0)
		{
			gMovimentFletxaMenu1 = op;
			if (sobre == 0)	setTimeout("mouFletxaMenu1()", 100);
			else mouFletxaMenu1();
		}
		else{
			gMovimentFletxaMenu1 = op;
		}
	}
}

// home
function mostraOcultaFletxaMenu1()
{
	if (!menu1_inicialitzat) return;
	gCapes["fletxaMenu1"].style.top = gTop + "px";
	if (gN == 4 || gN == 2 || gN == 0) gCapes["fletxaMenu1"].style.visibility = "visible";
	else if (gN == 3 || gN == 1) gCapes["fletxaMenu1"].style.visibility = "hidden";
	gN--;
	if (gN >= 0) gTimerFletxaMenu1 = setTimeout("mostraOcultaFletxaMenu1()", 100);
}

// No home
function mouFletxaMenu1()
{
	if (!menu1_inicialitzat) return;
	if (!gCapes["fletxaMenu1"]) return;
	inc = 10;	// increment de la posició de la fletxa
	ms = 30;	// velocitat del timer (ms)
	ttop = parseInt(gCapes["fletxaMenu1"].style.top);

	ftop = -8 + gMovimentFletxaMenu1*distOp;

	if (ttop > ftop){
		ttop -= inc;
		if (ttop < ftop) ttop = ftop;
	}
	if (ttop < ftop){
		ttop += inc;
		if (ttop > ftop) ttop = ftop;
	}
	gCapes["fletxaMenu1"].style.top = ttop + "px";
	if (ttop != ftop) setTimeout("mouFletxaMenu1()", ms);
	else 							gMovimentFletxaMenu1 = 0;
		
}
