	if(Browser.Engine.name == 'trident' && Browser.Engine.version == 5){
		Browser.ie7	= true;
		//alert(Browser.ie);
	}

var TabSet = new Class({ /* class */
	options: {
		activeClass: 'active', //css class
		cookieName: '',
		cookieOptions: {
			duration: 30, //30 days
			path: '/'
		},
		startIndex: 0 //start with this item if no cookie or active
	},
	Implements: [Options,Events],
	initialize: function(tabs,contents,options) {
		
		if(!Browser.ie7){
		
				
			//handle arguments
			this.setOptions(options);
			this.tabs = $$(tabs);
			this.contents = $$(contents);
			//console.log(this.contents);
			
			
			this.contents.setStyles({
				height: '0px',
				overflow: 'hidden'
			}).addClass('inactive');
	
					
			//determine the "active" tab
			
			var active = (Cookie.read(this.options.cookieName) || this.options.startIndex);
			this.activeTab = this.tabs[active].addClass(this.options.activeClass);				
			this.activeContent = this.contents[active].setStyle('height','auto').removeClass('inactive').addClass('active');
			
		
		}
			
	
		
		
		//*/
		//this.contents.getElement(':first-child').fade('in').set('tween',{ onComplete: $empty }).tween('height',contentHeight);
		
		//process each tab and content
		this.tabs.each(function(tab,i) {
			this.processItem(tab,this.contents[i],i);
		},this);
		//tabs are ready -- load it!
		this.fireEvent('load');
	},
	processItem:function(tab,content,i) {
		var contentHeight = content.getScrollSize().y;
		//add a click event to the tab
		
		if(!Browser.ie7){
			
			tab.addEvent('click',function(e) {
				//stop!
				if(e) e.stop();
				//if it's not the active tab
				if(tab != this.activeTab) {
					//remove the active class from the active tab
					this.activeTab.removeClass(this.options.activeClass);
					//make the clicked tab the active tab
					(this.activeTab = tab).addClass(this.options.activeClass);
					//tween the old tab content up
					//tween the new content down
					this.activeContent.set('tween',{
						onComplete:function() {
							this.activeContent = content.addClass('active').removeClass('inactive').fade('in').set('tween',{ onComplete: function(){
								//alert('jetzt');
							}}).tween('height',contentHeight);
							//fire the tab change event
							this.fireEvent('change',[tab,content]);
						}.bind(this)
					}).setStyles({
						height: contentHeight,
						overflow: 'hidden'
					}).fade('out').tween('height',0).addEvent('onComplete',function() {
						
					})
					
					
					
					
					.addClass('inactive').removeClass('active');
					//save the index to cookie
					if(this.options.cookieName) Cookie.write(this.options.cookieName,i,this.options.cookieOptions);
				}
			}.bind(this));
		}
	}
});





/* usage */
window.addEvent('domready',function() {
/*

	Object.prototype.foreach = function( callback ) {
  for( var k in this ) {
    if( typeof this[ k ] != 'function' ) {
      callback( k, this[ k ] );
    }
  }
	}

	Browser.Engine.foreach( function( k, v ) {
		alert( k + ' ' + v );
	});

*/
	if(Browser.Engine.name == 'trident' && Browser.Engine.version == 5){
	/*
	alert(Browser.Engine.name);
		alert(Browser.Engine.version);
*/
	}

	

	if($$('div.mod_glossaryMenu').length){
		var tabset = new TabSet($$('div.mod_glossaryMenu ul li a'),$$('.mod_glossaryList dl'),{
			cookieName: 'demo-list'
		});
	}

});
