//	Tab Menu
//	Tab Menu

function TabsMenu(id_root, tag_name)
{
	this.id_root = id_root;
	this.parent = document.getElementById(id_root);
	this.tag_name = tag_name;
	this.activeClass = 'active';
	this.normalClass = 'normal';
	this.active_index = null;
	this.active_tab = null;
	this.tabs_length = null;
	this.delay = 5000;
	this.timer = null;
	this.initializedContent();
}

TabsMenu.prototype.setActiveTab = function(index)
{
	if (this.active_index == index) return;
	
	try {
			this.active_tab.className = this.normalClass;
			this.active_tab.content.style.display = 'none';
	}catch(e){};
	
	var obj = this.parent.getElementsByTagName(this.tag_name)[index];
		obj.className = this.activeClass;
		obj.content.style.display = 'block';
	
	this.active_tab = obj;
	this.active_index = index;
}

TabsMenu.prototype.nextTab = function()
{
	var curr_index = this.active_index + 1;
	if (curr_index >= this.tabs_length) curr_index = 0;
	this.setActiveTab(curr_index);
}

TabsMenu.prototype.previousTab = function()
{
	var curr_index = this.active_index - 1;
	if (curr_index < 0) curr_index = this.tabs_length - 1;
	this.setActiveTab(curr_index);
}

TabsMenu.prototype.start = function(ref)
{
	this.timer = setInterval(function(){ref.nextTab();}, this.delay);
}

TabsMenu.prototype.stop = function()
{
	clearInterval(this.timer);
}

TabsMenu.prototype.setDelay = function(ms)
{
	this.delay = ms;
}

TabsMenu.prototype.setActiveClassName = function(active_class)
{
	this.activeClass = active_class;
}

TabsMenu.prototype.setNormalClassName = function(normal_class)
{
	this.normalClass = normal_class;
}

TabsMenu.prototype.initializedContent = function()
{
	var obj = this.parent.getElementsByTagName(this.tag_name);
	this.tabs_length = obj.length;
	for (var i = 0; i < this.tabs_length; i++)
	{
		obj[i].content = document.getElementById(this.id_root + '_' + i);
		obj[i].content.style.display = 'none';
	}
}
//// End Tab Menu
//// End Tab Menu
