var active_tab = '';

function show_tab(tab) {

	// bestaat er wel content voor onder deze knop?
	if (isset($('tab_' + tab))) {
		// de rest weg
		$$('.tab-content').setStyle('display', 'none');
		// deze tonen
		$('tab_' + tab).setStyle('display', 'block');
	}
	
	active_tab = tab;
}

window.addEvent('domready', function() {
	
	var tabs = [];
	
	// zoek tabjes (tabs bestaan op basis van de knopjes)
	$$('div.content-tabs span').each(function(button) {
		// weergeven
		button.addEvent('click', function() {
			show_tab(this.get('rel'));
			// has bijwerken
			location.hash = this.get('rel');
		});
		// onthouden
		tabs.include(button.get('rel'));
	});
	
	// in de basis tonen we de eerste tab
	var active = tabs[0];
	// is er al iets opgegeven?
	if (location.hash != '' && tabs.contains(location.hash.substr(1)))
		active = location.hash.substr(1);
	// weergeven
	show_tab(active);
	
	// hou de hash goed in de gaten
	(function() {
		if (location.hash != '' && location.hash.substr(1) != active_tab && tabs.contains(location.hash.substr(1))) {
			show_tab(location.hash.substr(1));
		}
	}).periodical(400);
});
