// JavaScript Document
	
	// Load function loops through all divs looking for anything with _menu that matches the link class 
	// ie attorneys_menu where attorneys is the class applied to the link under the nav div
	// Hides anything it finds and instantiates the mouse over observer. 
	
	document.observe("dom:loaded", function (e)
		{
			$$('#nav a').each(function (element)
			{

				var menu = $($A(element.classNames()).first() + "_menu");
				if( menu) {
					menu.hide();
					menu.style.visibility = "visible";
					element.observe('mouseover', function (e)
						{
							link_item = $A(Event.element(e).classNames());	
							show_drop(menu, link_item.first());		
						});
					
				}
			});
		}
	);
	
	// Function to show and hide div menu items. Looks for the div and the button to attach it to. 

	function show_drop(drop_div, button_class){
	
		$$('a.' + button_class).each(function (elm){
				button = elm.identify();
				button_width = $(button).getWidth();
				//button_height = $(button).getHeight() -1;
			}
		);
		
		//Find and attach to button
		
		$$('div.drop').each(function (elm){
			elm.hide();
			elm.clonePosition(button, { 
				setLeft:true,
				setTop:true,
				setWidth: 200,
				setheight: false,
				offsetLeft: 182,
				offsetTop: 0
				}
			);
			
			}
		);
		
		$$('div.drop').each(function (elm){
			elm.hide();
			elm.clonePosition(button, { 
				setLeft:true,
				setTop:true,
				setWidth: 200,
				setheight: false,
				offsetLeft: 182,
				offsetTop: 0
				}
			);
			
			}
		);
		
		$(drop_div).show();
		
		// Roll in out functions for the div's
		$(drop_div).observe('mouseout', function(){		
			clearTimeout(document.timer);	
			document.timer = setTimeout( function(){
				$(drop_div).hide()}, 
				500);
			}
		);
		
		$(drop_div).observe('mouseover', function(){								  	
			$(drop_div).show();
			clearTimeout(document.timer);
			}
		);
		
		// Roll in out functions for the div's
		$(button).observe('mouseout', function(){		
			clearTimeout(document.timer);	
			document.timer = setTimeout( function(){
				$(drop_div).hide()}, 
				500);
			}
		);
		
		$(button).observe('mouseover', function(){
			$(drop_div).show();
			clearTimeout(document.timer);
			}
		);
		
		
	}
