// JavaScript Document
var dropdowntimer = [];
var dropdownitem = null;
var currenthideeffect = [];
function showdropdown(event)
{
	var element = Event.element(event);
	if(dropdownitem == this)
	{
		clearTimeout(dropdowntimer[this.nummer]);
	}
	
	var ul = this;
	var a = ul.getElementsBySelector('a');
	if(a[0].hasClassName("on"))
		return;
	if(a[0])
	{
		a[0].removeClassName("on");
		a[0].addClassName("on");
	}
	//clearTimeout(dropdowntimer[ul.className]);	
	ul = ul.getElementsBySelector('div');	
	if(ul[0])
	{
		if(!ul[0].visible())
		{
			//ul[0].show();
			new Effect.BlindDown(ul[0],{ duration: 0.5, queue : {position: 'end' , scope: 'dropdown'+this.nummer } });
		}
	}

}

function hidedropdown(event)
{
	var element = Event.element(event);
	dropdownitem = this;	
	var ul = this;	
	var a = ul.getElementsBySelector('a');
	if(a[0]) a[0].removeClassName("on");		
	
	ul = ul.getElementsBySelector('div');
	if(ul[0])
	{
		if(ul[0].visible())	
		{
			//ul[0].hide();
			dropdowntimer[this.nummer] = setTimeout(function () {new Effect.BlindUp(ul[0],{ duration: 0.1, queue : {position: 'end' , scope: 'dropdown'+this.nummer }, afterFinish: function() {	if(a[0]) a[0].removeClassName("on");		 } }); }, 200);

		}
	}
}

function toggledropdown()
{
	var element = Event.element(event);
	dropdownitem = this;	
	var ul = this;	
	var a = ul.getElementsBySelector('a');
	if(a[0]) a[0].removeClassName("on");		
	
	ul = ul.getElementsBySelector('div');
	if(ul[0])
	{
		if(ul[0].visible())	
		{
			//ul[0].hide();
			dropdowntimer[this.nummer] = setTimeout(function () {new Effect.BlindUp(ul[0],{ duration: 0.1, queue : {position: 'end' , scope: 'dropdown'+this.nummer }, afterFinish: function() {	if(a[0]) a[0].removeClassName("on");		 } }); }, 200);

		}
		else
		{
			dropdowntimer[this.nummer] = setTimeout(function () {new Effect.BlindDown(ul[0],{ duration: 0.5, queue : {position: 'end' , scope: 'dropdown'+this.nummer }, afterFinish: function() {	if(a[0]) a[0].removeClassName("on");		 } }); }, 200);			
		}
	}	
}

function Dropdownmenu(menu)
{
	var lis = $(menu).getElementsBySelector('li.main');
	for(var i=0; i<lis.length; i++)
	{
		lis[i].nummer = i;		
		Event.observe(lis[i], 'mouseover', showdropdown);				
		Event.observe(lis[i], 'mouseout', hidedropdown);				
	}
}
