window.onload = init;
step = 15;
activeMenus = 0;
function init() {
	var menu = document.getElementById('menu').getElementsByTagName('a');
	for (var i=0; i<menu.length; i++) {	
		if (menu[i].id){
			menu[i].onmouseover = over;
			menu[i].onmouseout = out;
			var u = document.getElementById('drop-'+menu[i].id.substr(5));
			u.initialOffset = -u.offsetHeight-8;
			u.style.top = u.initialOffset + 'px';
			var a = document.getElementById('drop-'+menu[i].id.substr(5)).getElementsByTagName('a');
			for (var j=0; j<a.length; j++) {
				a[j].onmouseover = over;
				a[j].onmouseout = out;
			}
		}
	}
}

function over(){
	if (this.id) {var u = document.getElementById('drop-'+this.id.substr(5)); document.getElementById('dropdowns').style.visibility='visible';}
	else var u = this.parentNode.parentNode;
	activeMenus++;
	if (u.time!=undefined) {clearTimeout(u.time);}	
	u.time = setInterval(show(u), 20);
}

function out(){
	if (this.id) var u = document.getElementById('drop-'+this.id.substr(5));
	else var u = this.parentNode.parentNode;
	activeMenus--;
	if (u.time!=undefined) {clearTimeout(u.time);}	
	u.time = setInterval(hide(u), 20);
}

function show(obj) {return (function(){
	temp = Number(obj.style.top.split('px')[0]) + step;
	if (temp > 0) {obj.style.top = '0px'; clearInterval(obj.time); return}
	obj.style.top = temp +'px';
});}

function hide(obj) {return (function(){
	temp = Number(obj.style.top.split('px')[0]) - step;
	if (temp < obj.initialOffset) {
		obj.style.top = obj.initialOffset+'px'; clearInterval(obj.time);
		if (activeMenus==0) document.getElementById('dropdowns').style.visibility='hidden'; return}
	obj.style.top = temp +'px';
});}