/*
 * Prototype-based dropdown menus.
 * Note: this class is designed to be initialized after dom:loaded.
 */

var Delaydropdown = Class.create({
	initialize: function(element) {
		this.element = $(element);
		this.element.down('ul').hide();
		this.timerid = null;
		this.element.observe('mouseover', this.show.bind(this));
		this.element.observe('mouseout', this.timer.bind(this));
	},
	show: function() {
		if (this.timerid) 
			clearTimeout(this.timerid);
		this.element.down('ul').show();
	},
	timer: function() {
		if (this.timerid) 
			clearTimeout(this.timerid);
		this.timerid = setTimeout(this.hide.bind(this), 1);
	},
	hide: function() {
		this.element.down('ul').hide();
	}
});


