/************************************************************************
 * 		Basisklasse für Tabs											*
 * 		C 2008 by René Lange & Thomas Müller & Steve Rohrlack @ mindbox	*
 ************************************************************************/

var AbstractTab = new Class({
	selector : '',
	title : '',
	rebuild : false,
	tours: new Array(),
	
	// EventHandler
	sendMessage : function (target, todo) {
		if ((this.selector == target) || (this.title == target)) {
			this.handleEvent(todo);
		}
	},

	// Nachrichten verarbeiten
	handleEvent : function (todo) {
		switch (todo) {
			case 'show': 			this.buildContent();
									break;
			case 'rebuildOn':		this.rebuild = true;
									break;
			case 'rebuildTab':		this.rebuildContent();
									break;
			case 'updateTour':		this.updateTour();
									break;
		}
	},

	// Tab initialisieren
	initTab : function(){		
	},
	
	// Tab leeren
	clear : function() {
		var sel = $(this.selector + 'Content');
		if (sel != null) {
			sel.empty();			
		}
	},
	
	// Bei Änderungen neu bauen
	checkForRebuild : function() {
		if (this.rebuild) {
			this.rebuildContent();
		}
	},

	// Bei Änderungen andere Aktionen ausführen
	checkForUpdate : function() {
	},
	
	// Inhalt erstellen
	buildContent : function() {		
	},
	
	// Neuladen des Tabs
	rebuildContent : function() { 
		this.clear();
		this.buildContent();
		this.rebuild = false;
	},
	
	// Tour updaten ohne neu zu laden
	updateTour : function() {
	},
	
	// Inhalte in DOM fürgen
	fillContent : function(el) {
		var contentSelector = this.selector + 'Content';
		$(contentSelector).adopt(el);
	},

	// Events an Elemente hängen
	addEvents : function() {		
	},

	// Anker werden mit einer Funktion versehen, damit sie nicht mehr wegspringen
	stopLinkHopping : function () {
		// Eigeneer Inhalt
		$(this.selector + 'Content').getElements('a').each(function(el) {
			switch (el.getProperty('class')) {			
				case 'tpShortDetails':
				case 'tpShowDetails':
				case 'tpLogin':
						break;
				default:
					if (el.hasClass('gDetails')) {
						el.addEvent('click',function(ev) {
							var ev = new Event(ev);
							ev.stop();
						})
					}
					break;
			}
		}.bind(this));
	}
});