

function Tab(id)
{
	this.element = document.getElementById(id);
    //innerHTML
    //alert(document.getElementById(id).innerHTML)
	this.tabItems = [];
	this.tablistItems = [];
	this.activeTab = 1;
	this.toggleTimer = null;
	this.init();
}

Object.extend(Tab.prototype,
{
	init: function()
	{
		if (this.element)
		{
			var ul = document.createElement('ul'), li, a;
			var tab = this.element.firstChild, i = 1;
			while (tab)
			{
				if (tab.nodeType == 1)
				{
					this.tabItems[i] = tab;

					li = document.createElement('li');
					a = document.createElement('a');
					a.setAttribute('href', window.location.href + '#' + tab.id);
					a.appendChild(document.createTextNode(knopNaam[i]));
					addEvent(a, 'click', function(e) { e.preventDefault(); });
					addEvent(a, 'mouseover', this.setActive.bind(this, i));
					li.appendChild(a);

					if (i != this.activeTab)
					{
						tab.style.display = 'none';
					}
					else
					{
						addClass(li, 'active');
					}

					this.tablistItems[i] = li;
					ul.appendChild(li);

					i++;
				}

				tab = tab.nextSibling;
			}

			this.element.insertBefore(ul, this.element.firstChild);

			addEvent(this.element, 'mouseout', this.startToggle.bind(this));
			addEvent(this.element, 'mouseover', this.stopToggle.bind(this));
			this.startToggle();

			ul = null, li = null, a = null;
			addEvent(window, 'unload', this.cleanUp.bind(this));
		}
	},
	cleanUp: function()
	{
		this.stopToggle();
		this.tablistItems = null;
		this.tabItems = null;
		this.element = null;
	},
	setActive: function(i, e)
	{
		if (i != this.activeTab)
		{
			this.tabItems[this.activeTab].style.display = 'none';
			removeClass(this.tablistItems[this.activeTab], 'active');

			this.activeTab = i;
			this.tabItems[this.activeTab].style.display = '';
			addClass(this.tablistItems[this.activeTab], 'active');
		}

		if (e) e.preventDefault();
	},
	toggle: function()
	{
		var i = this.activeTab + 1;
		if (!this.tabItems[i]) i = 1;

		this.setActive(i);
		this.startToggle();
	},
	startToggle: function()
	{
		this.stopToggle();
		//verander deze waarde om de tijd sneller te laten lopen
		this.toggleTimer = setTimeout(this.toggle.bind(this), Math.round(40000 / (this.activeTab + 1)));
		//alert("autotoggle");
		sIFR.replace(handelgothic, {
  selector: '#wrapper_home h1',
  css: ['.sIFR-root { background-color: #FFFFFF; color: #FFFFFF; font-size: 300%}'
  ]
  , wmode: 'transparent'
  , filters: {
	  DropShadow: {
		  distance: 2
		  , color: '#000000'
		  , strength: 2
		  , alpha: .25
		  , blurX: 10
		  , blurY: 10
	  }
  }
});
	},
	stopToggle: function()
	{
		if (this.toggleTimer)
		{
			clearTimeout(this.toggleTimer);
			this.toggleTimer = null;
			sIFR.replace(handelgothic, {
  selector: '#wrapper_home h1',
  css: ['.sIFR-root { background-color: #FFFFFF; color: #FFFFFF; font-size: 300%}'
  ]
  , wmode: 'transparent'
  , filters: {
	  DropShadow: {
		  distance: 2
		  , color: '#000000'
		  , strength: 2
		  , alpha: .25
		  , blurX: 10
		  , blurY: 10
	  }
  }
});
		}
	}
});


