/***********************************************************************************
  * Javascript for whatsnew.xing.com
  * © 2010 deepblue networks AG
  * @author: Kai Hommel <kaho@db-n.com>
  **********************************************************************************/
  
/***********************************************************************************
  * Navigation
  **********************************************************************************/
var Navigation = {
	list: 'language',
	link: 'sel',
	sub: 'langSelect',
	fx: '',
	init: function() {
		var _this = this;
		this.setHover = this.setHover.bindAsEventListener(this);
		this.removeHover = this.removeHover.bindAsEventListener(this);
		this.stopFx = this.stopFx.bindAsEventListener(this);
		Event.observe($(this.link), 'click', this.setHover);
	},
	setHover: function(e) {
		e.stop();
		Event.stopObserving(this.link, 'click', this.setHover);
		Element.addClassName($(this.list), 'over');
		Event.observe(this.list, 'mouseenter', this.stopFx);
		Event.observe(this.list, 'mouseleave', this.removeHover);
		return false;
	},
	removeHover: function(e) {
		e.stop();
		var _this = this;
		Event.stopObserving(this.sub, 'mouseleave', this.removeHover);	
		this.fx = new Effect.Fade($(_this.sub), { 
			delay: 0.5, 
			duration: 0.5, 
			afterFinish: function() {
				Element.removeClassName($(_this.list), 'over');
				Event.observe(_this.link, 'click', _this.setHover);
			}
		});
		return false;
	},
	stopFx: function(e) {
		e.stop();
		this.fx.cancel();
		$(this.sub).setStyle({ opacity: 1 });
		return false;
	}
};
/***********************************************************************************
  * END Navigation
  **********************************************************************************/
  
document.observe('dom:loaded', function() {
	// init language navigation
	Navigation.init();
});
