
// Link[nr] = 'position [0 is menu/1 is item] | Link name | url | target (_self|blank|top|frame_name)'
var Link = new Array();

Link[0] = '0|Natural';
Link[1] = '1|Amphibien-Reptilien|amphibien.html|_self';
Link[2] = '1|Federvieh|federvieh.html|_self';
Link[3] = '1|Hunde|hund.html|_self';
Link[4] = '1|Pferde|pferd.html|_self';
Link[5] = '1|Pflanzen|pflanze.html|_self';
Link[6] = '1|Wildtiere|wild.html|_self';
Link[7] = '1|Nutztiere|nutztiere.html|_self';
Link[8] = '0|Bilder';
Link[9] = '1|Bilder|bilder.html|_self';
Link[10] = '0|Clipart';
Link[11] = '1|Seite 1|clipart-1.html|_self';
Link[12] = '1|Seite 2|clipart-2.html|_self';
Link[13] = '1|Seite 3|clipart-3.html|_self';
Link[14] = '0|Menschen';
Link[15] = '1|Karikatur|karikatur.html|_self';
Link[16] = '1|Real|normal.html|_self';
Link[17] = '0|Handbemalung';
Link[18] = '1|Handbemalung|handbemalung.html|_self';
Link[19] = '0|Amphib-Reptil- lustig';
Link[20] = '1|Amphib-Reptil- lustig|amp-rep-lustig.html|_self|';
Link[21] = '0|Hörnchen';
Link[22] = '1|Hörnchen|hoernchen.html|_self';
Link[23] = '0|Mäuse';
Link[24] = '1|Mäuse|maus.html|_self';
Link[25] = '0|Teddys';
Link[26] = '1|Teddys|teddy.html|_self';
Link[27] = '0|Lustiges';
Link[28] = '1|Lustiges|lustig.html|_self';
Link[29] = '0|Fantasy';
Link[30] = '1|Fantasy|fantasy.html|_self';
Link[31] = '0|Logos';
Link[32] = '1|Logos|logos.html|_self';
Link[33] = '0|Weihnachten';
Link[34] = '1|Weihnachten|weihnachten.html|_self';

var height    = 23; // Hoehe der Menuekoepfe
var iheight   = 20; // Hoehe der Menueelemente
var bgc       = '#4E82B2' // background color of the item
var over_bgc  = '#fff';
var tc        = '#ffffff' // text color of the item
var over_tc   = '#4E82B2';
var speed     = 0;
var timerID   = 0;
var width     = 152;
var N         = (document.all) ? 0 : 1;
var self_menu = new Array();

function write_menu()
{
	smc   = 0;
	mn    = 0;
	mni   = 1;
	start = -1;

	document.write('<div style="position: absolute;">');

	for (var i = 0; i < Link.length; i++)
	{
		la = Link[i].split('|');

		if (la[0] == 0)
		{
			if (start == 0)
			{
				document.write('</div>');

				h = csmc * iheight;
				tmn = mn; // - h;
				self_menu[smc] = new Array(tmn, h, 0, -2);

				smc++;
				mn--;
			}

			csmc = 0;

			document.write('<div id="down' + smc + '" class="menu" '
			             + 'style="top: ' + mn + 'px; height: ' + height + 'px;" '
			             + 'onclick="pull_down(' + smc + ', ' + mni + ');">'
			             + '  ' + la[1] + '</div>');

			self_menu[smc] = new Array(mn, height, 0, mni);

			smc++;
			mni++;
			mn += height;
			start = 1;
		}
		else
		{
			if (start == 1)
			{
				if (N)
					mn += 2;

				document.write('<div id="down' + smc + '" class="item_panel" '
				             + 'style="top: '+ mn + 'px;">');

				start = 0;
			}

			document.write('<a href="' + la[2] + '"'
			             + ((la[3] != '') ? ' target="' + la[3] + '"' : '')
			             + '><div id="d' + i + '" class="item" '
			             + 'style="height: ' + iheight + 'px;'
			             + ((N) ? ' width:150px;' : '')
			             + '" onmouseover="color(this.id);" '
			             + 'onmouseout="uncolor(this.id);">'
			             + ' ' + la[1] + '</div></a>');

			csmc++;
		}
	}

	if (start == 0)
	{
		document.write('</div>');

		h =  csmc * iheight;
		tmn = mn + 5; // - h;
		self_menu[smc] = new Array(tmn, h, 0);
		name = 'down' + (self_menu.length - 1);

		obj = document.getElementById(name);
		obj.style.borderBottomColor = '#008';
		obj.style.borderBottomWidth = '1px';
		obj.style.borderBottomStyle = 'solid';
	}

	document.write('</div>');
}

function color(obj)
{
	document.getElementById(obj).style.backgroundColor = over_bgc;
	document.getElementById(obj).style.color = over_tc;
}

function uncolor(obj)
{
	document.getElementById(obj).style.backgroundColor = bgc;
	document.getElementById(obj).style.color = tc;
}

function pull_down(nr, c)
{
	if (timerID == '')
	{
		to = self_menu[nr + 1][1]
		begin = nr + 2;

		if (timerID != '')
			clearTimeout(timerID);

		if (self_menu[nr + 1][2] == 0)
		{
			self_menu[nr + 1][2] = 1;

			if (nr == (self_menu.length - 2))
				to++;

			epull_down(begin, to, 0);
		}
		else
		{
			to = 0;
			self_menu[nr + 1][2] = 0;
			name = 'down' + (nr + 2);
			open_item = 0;

			for (var i = 0; i < nr; i++)
				if (self_menu[i][2] == 1)
					open_item += self_menu[i][1];

			if (N == false)
				open_item -= (c * 1);

			if (nr == (self_menu.length - 2))
			{
				val = self_menu[self_menu.length - 1][1];
				to = -1;
			}
			else
				val = parseInt(document.getElementById(name).style.top) - (open_item) - (c * height);

			epull_up(begin, to, val);
		}
	}
}

function epull_down(nr, to, nowv)
{
	name = 'down' + (nr - 1);
	obj = document.getElementById(name).style.clip = 'rect(0, ' + width + ', ' + (nowv + 1) + ', 0)';

	for (var i = nr; i < self_menu.length; i++)
	{
		name = 'down' + i;
		obj = document.getElementById(name);
		obj.style.top = parseInt(obj.style.top) + 1;
	}

	nowv++;

	if (nowv < to)
		timerID = setTimeout('epull_down(' + nr + ', ' + to + ', ' + nowv + ');', speed);
	else
		timerID = 0;
}

function epull_up(nr, to, nowv)
{
	name = 'down' + (nr - 1);
	obj = document.getElementById(name).style.clip = 'rect(0, ' + width + ', ' + nowv + ', 0)';

	for (var i = nr; i < self_menu.length; i++)
	{
		name = 'down' + i;
		obj = document.getElementById(name);
		obj.style.top = parseInt(obj.style.top) - 1;
	}

	nowv--;

	if(nowv > to)
		timerID = setTimeout('epull_up(' + nr + ', ' + to + ', ' + nowv + ');', speed);
	else
		timerID = 0;
}

function startup(nr)
{
	write_menu();

	if (nr != 0)
	{
		for (var i = 0; i < self_menu.length; i++)
		{
			if (self_menu[i][3] == nr)
				pull_down(i, nr);

			i == self_menu.length;
		}
	}
}
