// JavaScript Document

$j(function(){

	$j('#drop_down>li>ul').hide();
	setupToolboxEvents();
										 
});

function setupToolboxEvents() {

	this.toolBoxTimeoutID = 0;
	
	// setup events on the toolbox:
	$j('#drop_down>li').hover(function() {
		if ($j('#drop_down ul:animated').length > 0) return;
		
		// clear the timeout:
		clearTimeout(this.toolBoxTimeoutID);
		
		// get the li that the user is hovered over:
		var hoveredLI = $j(this);
		
		// method for sliding the element down:
		var slideDownFn = function() {
			hoveredLI.find('ul').slideDown(200);
		};
		
		// collapse currently expanded siblings:
        var expandedSiblings = hoveredLI.siblings().find('ul:visible');
		if (expandedSiblings.length > 0)
		{
			expandedSiblings.slideUp(200, slideDownFn);
		}
		else
		{
			slideDownFn();
		}
		
	}, function() {
		var hoveredLI = $j(this);
		this.toolBoxTimeoutID = setTimeout(function() {
			$j(hoveredLI).find('ul').slideUp(200);
		}, 500);
	});
	
};



