//Safe Console.log
window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);(typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a))}};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());

/*
	-------------------------------------------
	einserver.de v13
	Design & Code by Florian Pichler since 2004
	-------------------------------------------
*/
(function($) { 
	if (!(Browser.Platform.ios || Browser.Platform.android || Browser.Platform.webos) || (navigator.userAgent.match(/iPad/i) != null)) {
		var html = $(document.documentElement), body = $(document.body), top = $('top'), navLinks,
			ticketFx = [], textFx = [], timerShow = [], timerHide = [], active = false, 
		evHelper = function(event) {
			var t = $(event.target), id; 
			if (t.get('tag') != 'a') t = $(event.target).getParent();
			id = t.retrieve('id');
			clearTimeout(timerShow[id]);
			clearTimeout(timerHide[id]);
			return id;
		},
		show = function(event) {
			var id = evHelper(event);
			timerShow[id] = (function() {
				textFx[id].start(1);
			}).delay(150);
			ticketFx[id].start(0);
			if (id != active) {
				hideActive();
			}
		},
		hide = function(event) {
			var id = evHelper(event);
			if (id != active) {
				ticketFx[id].start(-125);
				timerHide[id] = (function() {
					textFx[id].start(0);
				}).delay(70);
				showActive();
			}
		},
		actHelper = function(x) {
			clearTimeout(timerShow[active]);
			clearTimeout(timerHide[active]);
			ticketFx[active].start(x);
		},
		showActive = function() {
			actHelper(0);
			timerShow[active] = (function() {
				textFx[active].start(1);
			}).delay(150);
		},
		hideActive = function() {
			actHelper(-125);
			timerHide[active] = (function() {
				textFx[active].start(0);
			}).delay(70);
		};
		navLinks = top.getElements('nav a').each(function(el) {
			var ticket = new Element('span.ein-ticket'),
				icon = new Element('span.ein-icon'),
				text = new Element('span.ein-text')
				id = el.getParent().get('id').replace('nav-',''),
				act = (html.hasClass(id));
			ticketFx[id] = new Fx.Tween(ticket, {
				'property': 'left',
				'link': 'cancel',
				'duration': 400,
				'transition': Fx.Transitions.Cubic.easeOut,
				'onComplete': function(el) {
					if (this.to[0].value == 0) {
						textFx[el.getParent().retrieve('id')].start(1);
					}
				}
			}).set((act) ? 0 : -125);
			textFx[id] = new Fx.Tween(text, {
				'property': 'opacity',
				'link': 'cancel',
				'duration': 150
			}).set((act) ? 1 : 0);
			if (act) active = id;
			el.addEvents({
				'mouseenter': show,
				'mouseleave': hide
			}).store('id', id).set({'title': el.get('text'), 'text': ''}).adopt(ticket,icon,text);
		});
		html.addClass('js-menu')
	} 
})(document.id);
