/******************************** NAVIGATION ********************************/

var NavigationBar = function(root) {
	var topLevel = yDom.getElementsByClassName('l1', 'li', root);
	for ( var i=0; i<topLevel.length; i++ ) {
		var li = topLevel[i];
		yEvent.addListener(li, 'mouseover', this.handleMouseOver, li, this);
		yEvent.addListener(li, 'mouseout', this.handleMouseOut, li, this);
	}
}



NavigationBar.prototype.timer = null;



NavigationBar.prototype.current = null;



NavigationBar.prototype.handleMouseOver = function(evt, li) {
	
	//Clear Timer
	if ( this.timer ) {
		clearTimeout(this.timer);
	}
	
	//Aktuelle Navi verstecken
	if ( this.current ) {
		yDom.removeClass(this.current, 'hover');
		this.current = null;
	}
	
	//Neue Navi zeigen
	yDom.addClass(li, 'hover');
	this.current = li;
}



NavigationBar.prototype.handleMouseOut = function(evt, li) {
	
	//Clear Timer
	if ( this.timer ) {
		clearTimeout(this.timer);
	}
	
	//Callback + Timer starten
	var callback = function() {
		yDom.removeClass(li, 'hover');
		this.current = null;
	}
	this.timer = setTimeout(callback.bind(this), 2000);	
}
