Tabblocks = {
	init: function () {
		if ($$('ul.tabs li').length > 0) {
			$$('ul.tabs li').each(Tabblocks.addClick);
			Tabblocks.switchTab.call($('tab-top5videos'), true);
		}
	},

	addClick: function (el) {
		el.addEvent('click', Tabblocks.switchTab);
	},

	switchTab: function (overrideCheck) {
		if (this.hasClass('active') && !overrideCheck) return;

		//remove the active class from all the <li> elements
		var tabs = this.getParent().getElements('li');
		tabs.each(function (el) {
			el.removeClass('active');
		});

		// hide all the <div class="content"> elements
		var contentDivs = this.getParent().getParent().getElements('div.content');
		contentDivs.each(function (el) {
			el.addClass('hide');
		});

		//add the class active to the clicked tab and show the related <div> element
		this.addClass('active');
		var contentDivId = this.get('id').replace(/^tab-/, '');
		$(contentDivId).removeClass('hide');
	}
}

window.addEvent('domready', Tabblocks.init);