Event.observe(window, 'load', function() {
	var flash = $('Flash');
	if(flash){
		var link_to_links = new Element('a', {href: "/home/links", style: "display: block; width: 130px; height: 140px;"});
		flash.appendChild(link_to_links);
	}
});

function loadMenu(){
	var mouse_currently_hovers_over_item;
	
	var menu_items = $$('#menu > li');
	
	menu_items.each(function(item){
//		console.log("item: ",item.id);
		item = $(item);
		if(!item.id) return;
		if(item.getElementsByTagName('li').length > 0){
			item.addClassName('expandable');
		}
		item.observe('mouseover',function(){
			mouse_currently_hovers_over_item = item.id;
//			console.log(item.id+".hasClassName: ["+item.identify()+"]" ,item.hasClassName('expandable'));
			if(item.hasClassName('expandable')){
				var sub = $(item.id + "-sub");
				window.setTimeout(function(){
					item.addClassName('expanded');
					if(item.id == mouse_currently_hovers_over_item){
						sub.show({ duration: 0.1 });
						sub.observe('mouseover',function(){
							mouse_currently_hovers_over_item = item;
						});
//						console.log("showing ul for ",item.id);
					}
				},200);
			}
		});
		item.observe('mouseout',function(){
			mouse_currently_hovers_over_item = null;
			if(item.hasClassName('expandable')){
				var sub = $(item.id + "-sub");
				window.setTimeout(function(){
					item.removeClassName('expanded');
					if(item.id != mouse_currently_hovers_over_item){
						sub.hide({ duration: 0.1 });
						sub.observe('mouseover',function(){
							mouse_currently_hovers_over_item = item;
							log2('hover over',sub.id);
						});
					}
				},200);
			}
		});
	});
	

//	console.log("finished loading menu");
}

function log2(string,object){
//	if(!object) var object = ''; 
//	$('GirlText').innerHTML += string+" "+object+"<br/>\n";
//	if(console.log) console.log(string,object);
}
