/* 

	This menu is made by Amitas Websolutions for The young sensation
	
	www.amitas.nl

*/

//////////////// Vars!
	
var sub_array = [];
var sub_h_array = [];

var opacity_array = new Array(0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1);
var height_array = new Array(0.07,0.14,0.21,0.28,0.35,0.42,0.49,0.56,0.63,0.70,0.76,0.80,0.84,0.88,0.91,0.94,0.96,0.98,0.99,1);

var time = 13; //ms

//////////////// Functions!

function init_menu(show,sub_array_in)
{
	for (var x = 0;x < sub_array_in.length;x++)
	{
		sub_array[x] = sub_array_in[x];
		
		var y = document.getElementById(sub_array[x]);
		sub_h_array[x] = (y.offsetHeight - 0);
		
		if (x != show)
		{
			y.style.display = 'none';
		}
		
		else
		{
			y.style.display = 'block';
			document.getElementById('top_' + x).className = 'actief';
		}
	}
}

function sh(nr,top_el)
{			
	var id = 'sub_' + nr;
	var el = document.getElementById(id);
	var el_height = sub_h_array[nr];
	var display = el.style.display;

	hideRest(nr);
	
	if (display == 'block')
	{			
		top_el.className = '';
		
		for (var i = 0; i < height_array.length; i++)
		{
			setTimeout('timeOut(\'' + i + '\',\'' + id + '\',\'' + el_height + '\', \'down\');', i * time);
		}
		setTimeout('document.getElementById(\'' + id + '\').style.display = \'none\';',(height_array.length + 1) * time);
	}
	
	else if (display == 'none')
	{
		top_el.className = 'actief';

		for (var i = 0; i < height_array.length; i++)
		{
			setTimeout('timeOut(\'' + i + '\',\'' + id + '\',\'' + el_height + '\', \'up\');', i * time);
		}
		setTimeout('document.getElementById(\'' + id + '\').style.display = \'block\';',time);
	}
}

function timeOut(i, id, el_height, dir)
{
	var el = document.getElementById(id);
	
	if (dir == 'up')
	{
		el.style.height = ((el_height * height_array[i])) + 'px';
		setOpacity(id, opacity_array[i]);
	}
		
	else if (dir == 'down')
	{
		el.style.height = Math.round((el_height * (1 - height_array[i]))) + 'px';
		setOpacity(id, opacity_array[19 - i]);
	}
}

function setOpacity(id, opacity)
{
	var el = document.getElementById(id);

	el.style.opacity = opacity;
	el.style.MozOpacity = opacity;
	el.style.KhtmlOpacity = opacity;
	el.style.filter = 'alpha(opacity=' + (opacity*100) + ')';
}

function hideRest(nr)
{
	for (var x = 0;x < sub_array.length;x++)
	{
		if (x != nr && document.getElementById(sub_array[x]).style.display == 'block')
		{
			document.getElementById('top_' + x).className = '';
			
			for (var i = 0; i < height_array.length; i++)
			{
				setTimeout('timeOut(\'' + i + '\',\'' + sub_array[x] + '\',\'' + sub_h_array[x] + '\', \'down\');', i * time);
			}
			setTimeout('document.getElementById(\'' + sub_array[x] + '\').style.display = \'none\';',height_array.length * time);
		}
	}
}

function debug(str)
{
	var x = document.getElementById('debug');
	x.innerHTML = str + '<br />' + x.innerHTML;
}