var tabs;

window.onload = function()
{
	tabs = new Tabs;
	tabs.init();
}


function Tabs()
{
	this.elements = new Array();
}

Tabs.prototype.init = function()
{
	var element, id;
	var tabNames = new Array('related_events', 'related_exhibitions', 'related_news', 'related_photos', 'related_products', 'related_resources');
	
	i = 0;
	for (j = 0; j < tabNames.length; j++) {
		element = new Section(tabNames[j]);
		
		if (element.tabName != null) {
			this.elements[i] = element;
			i++;
		}
	}
}

Tabs.prototype.toggleSection =  function(tabName)
{
	for (i = 0; i < this.elements.length; i++) {
		section = this.elements[i];
		
		if (section.tabName == tabName) {
			section.show();
		} else {
			section.hide();
		}
	}
}

function Section(tabName)
{
	element = document.getElementById(tabName);
	
	if (element != null) {
		this.tabName = tabName;
		this.tabElement = document.getElementById(tabName + '_tab');
		this.contentElement = element;
	}
}

Section.prototype.show = function()
{
	this.tabElement.className = 'front';
	this.contentElement.className = 'tab_shown';
}

Section.prototype.hide = function()
{
	this.tabElement.className = 'back';
	this.contentElement.className = 'tab_hidden';
}