﻿fast.dropmenu = (new function() {
		
	var self = this;
	var id = "navigation";
	var cfg = new Object();
	
	var init = function() {
	
		var i = 0;	
		var a = $$("#"+id+" A");
	
		while( i < a.length ) {
			a[i].parent().addClass("hide");
			a[i].parent().attr("id",(id+"li"+i));
			
			a[i].parent().onmouseover(function(el){

				clearTimeout(cfg[el.e.id]);
				cfg[el.e.id]=setTimeout(function(){					
					el.setClass("show");
					var ntop = null;
					
					while( el.e && el.e.tagName != "DIV" ) {
						if( el.e.tagName == "LI" ) {
							ntop = el;
						};
						el = el.parent();
					};
					
					if( ntop.e != cfg.top && cfg.top ) {
						$(cfg.top).setClass("hide");
					};
					cfg.top = ntop.e;
				},100);
			});
			a[i].parent().onmouseout(function(el) {
				clearTimeout(cfg[el.e.id]);
				cfg[el.e.id]=setTimeout(function(){el.setClass('hide');},800);
			});
			a[i].onfocus(function(el) {
				while( el.e.tagName != "DIV" ) {
					if( el.e.tagName == "LI" ) {
						el.e.className="show";
					};
					el = el.parent();
				};
			});
			a[i].onblur(function(el) {
				var obj = el.e;
				while( obj.tagName != "DIV" ) {
					if( obj.tagName == "LI" ) {
						obj.className="hide";
					};
					obj = obj.parentNode;
				};
			});
			i++;
		};
	};
	$(id).onready(init);		
});

