Ext.BLANK_IMAGE_URL = 'js/ext-3.3.0/resources/images/default/s.gif';


function showMenu(event,target,o)
{
	var el = new Ext.Element(target);
	var menu = el.child('div');
	var li_a = el.child('a');
	if(menu)
	{
		//menu.setLeft(li_a.getLeft());
		menu.setVisible(true);
		
	}
	
}

function hideMenu(event,target,o)
{
	var el = new Ext.Element(target);
	var menu = el.child('div');
	var li_a = el.child('a');
	
	if(menu)
	{
		task = new Ext.util.DelayedTask(function(){ menu.setVisible(false);});
		task.delay(0);
	}
}

function showSubMenu(event,target,o)
{
	if(task)
	{
		task.cancel();
	}
}

function hideSubMenu(event,target,o)
{
	var el = new Ext.Element(target);
	
	task = new Ext.util.DelayedTask(function(){ 
		el.findParentNode('div',5,true).setVisible(false);
	});
	task.delay(0);
}

function runDropDownInit()
{
	
	var widgetMenus = Ext.query('div.menuList');
	
	for ( i = 0; i < widgetMenus.length; i++ ) {
		buildWidgetMenu( widgetMenus[i] );
	}
	
}

function buildWidgetMenu( menuLayer ) {
	
	var el = new Ext.Element( menuLayer );
	el.on('mouseover',showMenu,null,{delegate:'li'});
	el.on('mouseout',hideMenu,null,{delegate:'li'});
	
	var layerChild = el.query('div.submenu');
	
	for ( l = 0; l < layerChild.length; l++ ) {
		var sel = new Ext.Element( layerChild[l] );
		sel.on('mouseover',showSubMenu);
		sel.on('mouseout',hideSubMenu);
	}
	
}



Ext.onReady(
	function()
	{
		Ext.QuickTips.init();
		
		//init menu drop downs
		runDropDownInit();
		
	}
);
