var System = 
{
	Gui : 
	{
		member : 
		{
			currentActiveSwitches : new Array()
		},
		
		initTips : function (className)
		{

			var className = (typeof(className) == 'string')? '.'+className : '.tips';
		
			var tips = $$(className).each(function(el){
				var tipContent	= el.title;
				var tipBulle	= tipContent.split('::');
				var tipTitle	= tipBulle[0];
				var tipText		= tipBulle[1];
				el.store('tip:title', tipTitle);
				el.store('tip:text', tipText);
			});
			
			var tips = new Tips($$(className), {
				maxTitleChars : 75,
				onShow: function(tip) {
					tip.fade('in');
				},
				onHide: function(tip) {
					tip.fade('out');
				}
			});
		},
		
		refreshTips : function(className)
		{
			this.initTips(className);
		},
		
		
		fadeOut : function(el)
		{ 			
			el.morph({
				'opacity': [1,0]
			});	
		},

		fadeIn : function(el)
		{ 
			$(el).morph({
				'opacity': [0,1]
			});	
		},
		
		
		initSwitch : function(id, className)
		{
			this.member.currentActiveSwitches[id] = null;
			var firstProcessed = false;
			
			$$('.' + className).each(function(el) {
				
				if(!firstProcessed)
				{
					System.Gui.member.currentActiveSwitches[id] = el;
					firstProcessed = true;
				}
				else
				{
					elem = $(el.get('rel'));
					elem.set('opacity','0');
					elem.removeClass('undisplayed');
				}
				
				el.addEvent('click', function(e) {
					
					e.stop();
					
					if (System.Gui.member.currentActiveSwitches[id].get('rel') != el.get('rel')) {
						
						System.Gui.member.currentActiveSwitches[id].removeClass('active');
						el.addClass('active');
						
						System.Gui.fadeOut($(System.Gui.member.currentActiveSwitches[id].get('rel')));
						System.Gui.fadeIn($(el.get('rel')));
						
						System.Gui.member.currentActiveSwitches[id] = el;
					};
				});
			});
		}
	}
};

window.addEvent("domready", function() {
	System.Gui.initTips('tips');
	System.Gui.initSwitch('reiseziele', 'reiseziel-btn');
	System.Gui.initSwitch('livedabei', 'live-dabei-btn');
});
