
function showComments()
{
	var msgDiv = document.getElementById('comments-disabled-message');
	var commentsDiv = document.getElementById('comments-disabled-list');
	
	msgDiv.style.display = 'none';
	commentsDiv.style.display = 'block';
}

var EasyTabs = function (container, options){
	return {
		version: '1.0',
		options: {
			tabsClassName: 'tab',
			menuClassName: 'tabsMenu',
			menuItemClassName: 'tabsMenuLi',
			menuItemActiveClassName: 'active',
			onChange: function(tab, menuItem) {}
		},
		container: null,
		tabs: [],
		menu: null,
		menuItems: [],
		init: function(container, options){
			this.container = (typeof container=='string') ? document.getElementById(container) : container;
			if(!this.container) return;
			
			options = options || {};
			for(var oName in options){
				this.options[oName] = options[oName];
			}
			
			if(!this.getTabs()) return;
			this.makeMenu();
			this.initTabs();
		},
		getTabs: function(){
			var classExp = new RegExp('\\b'+ this.options.tabsClassName +'\\b')
			for(var i=0, node; node=this.container.childNodes[i]; i++){
				if(node.className && classExp.test(node.className))
					this.tabs.push(node);
			}
			return this.tabs.length;
		},
		makeMenu: function(){
			this.menu = document.createElement('ul');
			this.menu.className = this.options.menuClassName;
			this.container.insertBefore(this.menu, this.container.firstChild);
			
			for(var i=0, tab; tab=this.tabs[i]; i++){
				this.makeMenuItem(tab);
			}
			
if(this.tabs.length<2){
	this.menu.style.display = 'none';
}
		},
		makeMenuItem: function(tab){
			var self = this;
			
			var li = document.createElement('li');
			li.className = this.options.menuItemClassName;
			this.menu.appendChild(li);
			this.menuItems.push(li);
			
			var a = document.createElement('a');
			a.innerHTML = tab.title;
			a.href = tab.id.length ? '#t-'+ tab.id : '#';
			a.onclick = function(){
				return self.showTab(tab, li);
			};
			li.appendChild(a);
			
			tab.title = '';
			tab.style.display = 'none';
		},
		initTabs: function(){
			var tabToShow = 0;
			var urlHash = window.location.href.split('#t-')[1];
			if(urlHash){
				for(var i=0, tab; tab=this.tabs[i]; i++){
					if(tab.id==urlHash){
						tabToShow = i;
						break;
					}
				}
			}
			this.showTab(this.tabs[tabToShow], this.menuItems[tabToShow]);
		},
		showTab: function(tab, menuItem){
			if(tab.style.display!='none') return false;
			
			for(var i=0, t; t=this.tabs[i]; i++)
				t.style.display = 'none';
			for(var i=0, mi; mi=this.menuItems[i]; i++)
				mi.className = this.options.menuItemClassName;
			
			tab.style.display = '';
			menuItem.className += ' '+this.options.menuItemActiveClassName;
			
			this.options.onChange(tab, menuItem);
			
			return (tab.id.length>0);
		}
	}.init(container, options);
}

window.onload = function(){
	new EasyTabs('tabs');
};

