var links = new Array(); 
var step = 10;
var speed = 30;
var handler;
var handler2;
var openmenu;

function initmenu() {
	window.clearInterval(handler);
	i = 0;
	for ( a in links ) {
		i++;
		if ( el = document.getElementById('link_'+a) ) {
			el.style.display = 'block';
			document.getElementById('link_'+a).style.top = -i*60;
			document.getElementById('link_'+a).style.offsetHeight = i*60
		}
	}
	
	handler = window.setInterval( "showtime()", speed );
}

function showtime() {	
	var end = true;
	for ( a in links ) {
		if ( el = document.getElementById('link_'+a) ) {
			var top = parseInt (el.style.top);
			if ( top < 0 ) {
				el.style.top = (top+step)>0 ? 0 :(top+step);
				end = false;
			}
		}
	}
	if ( end ) { window.clearInterval(handler); }
}

function showchild(id) {
	if ( openmenu != id ) {
		CloseMenu();
	}
	if ( folder = document.getElementById('subfolder_'+id) ) {
		if ( openmenu != id ) {
			openmenu = id;
			folder.style.display = 'block';
			window.clearInterval(handler2);
			for (i=0; i<links[id].length; i++) {
				if ( el = document.getElementById('link_'+links[id][i]) ) {
					el.style.display = 'block';
					document.getElementById('link_'+links[id][i]).style.top = -i*30;
					document.getElementById('link_'+links[id][i]).style.offsetHeight = i*30
				}
			}
			handler2 = window.setInterval( "showtime2("+id+")", speed );
		}
	}
}

function showtime2(id) {	
	var end = true;
	for (i=0; i<links[id].length; i++) {
		a = links[id][i];
		if ( el = document.getElementById('link_'+a) ) {
			var top = parseInt (el.style.top);
			if ( top < 0 ) {
				el.style.top = (top+step)>0 ? 0 :(top+step);
				end = false;
			}
		}
	}
	if ( end ) { window.clearInterval(handler2); }
}

function CloseMenu() {
	openmenu = 0;
	for ( a in links ) {
		if ( el = document.getElementById('link_'+a) ) {
			if ( folder = document.getElementById('subfolder_'+a) ) {
				folder.style.display = 'none';
				for (i=0; i<links[a].length; i++) {
					if ( el2 = document.getElementById('link_'+links[a][i]) ) {
						el2.style.display = 'none';
					}
				}
			}
		}
	}
}

function hideHead()
{
	//alert('ss');
}