dojo.require("dojo.fx");
dojo.require("dojo.fx.easing");

o2.addLazy(function(){
	dojo.query('a.toggle-link').onclick(function(e) {
		var queryId = this.getAttribute('rel');
		e.preventDefault();
		if(document.getElementById(queryId)) {
			e.preventDefault();
			if(dojo.style(queryId,"display").toString() == 'none') {
				dojo.fx.wipeIn({
					node: dojo.byId(queryId),
					duration: 400,
					easing: dojo.fx.easing.expoOut
				}).play();
				dojo.addClass(this,'toggle-link-open');
			} else {
				dojo.fx.wipeOut({
					node: dojo.byId(queryId),
					duration: 400,
					easing: dojo.fx.easing.expoOut
				}).play();
				dojo.removeClass(this,'toggle-link-open');
			}
		}
	});
	/* ON toggle */
	dojo.query('a.meta_toggle_link_left').onclick(function(e) {
		document.getElementById("meta_toggle_left").style.display='block';
		document.getElementById("meta_toggle_right").style.display='none';
		dojo.forEach( dojo.query("#tarif_bereichsseite_switcher a"), function(element) {
			dojo.removeClass(element,'active');
		});
		dojo.addClass(this,'active');
	});
	/* ON toggle */
	dojo.query('a.meta_toggle_link_right').onclick(function(e) {
		document.getElementById("meta_toggle_left").style.display='none';
		document.getElementById("meta_toggle_right").style.display='block';
		dojo.forEach( dojo.query("#tarif_bereichsseite_switcher a"), function(element) {
			dojo.removeClass(element,'active');
		});
		dojo.addClass(this,'active');
	});

	dojo.query('#smartphone-feeds #smartphones-switch-box a.smartphone-feed-link').onclick(function(e) {
		e.preventDefault();

		var thisTarget = dojo.attr(this,'href').slice(1);

		dojo.forEach( dojo.query("#smartphones-switch-box .smartphone-feed-list"), function(element) {
			dojo.style(element,'display','none');
		});
		dojo.style( dojo.byId(thisTarget) ,'display','block');

		dojo.forEach( dojo.query("#smartphones-switch-box .smartphone-feeds-nav a"), function(element) {
			dojo.removeClass(element,'active')
		});
		dojo.addClass(this,'active');

		return false;
	});	

});
