/*!
 * Drop Down Menu
 * Tim Yip
 * Date: Sept 3 2010
 */
var dropDownMenu = (function ()
{
	var timeout         = 500;
	var closetimer		= 0;
	var ddmenuitem      = 0;

	var menu_open = function (){	
		menu_canceltimer();
		menu_close();
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
	};

	var menu_close = function (){
		if(ddmenuitem) {
		ddmenuitem.css('visibility', 'hidden');
		}
	};

	var menu_timer = function (){	
		closetimer = window.setTimeout(menu_close, timeout);
	};

	var menu_canceltimer = function (){
		if(closetimer){
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	};	
	
	$(document).ready(function()
	{	$('#navigation > li').bind('mouseover', menu_open);
		$('#navigation > li').bind('mouseout',  menu_timer);
	});
		
	document.onclick = menu_close;
})();
