var activeTab = 0;
var tabsTimer = null;

window.addEvent('domready', function ()
{
	if ($('libero'))
	{
		// ////////////////////////////////////////////////////////////
		// CONTENT NEWS
		//
		var contentNews = [new Fx.Slide('contentProduct'), new Fx.Slide('contentPress'), new Fx.Slide('contentCaseHistory')];
		contentNews.each(function (item, index) { item.hide(); });
		contentNews[0].show();

		// NEWS
		$('newsTabProduct').addEvent('click', function (e)
		{
			if (e) $clear(tabsTimer);
			contentNews.each(function (item, index) { item.hide(); });
			$('newsTabProduct').style.borderBottom = '0px';
			$('newsTabPress').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabCaseHistory').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabProduct').style.background = '#ffffff url("Images/box-title-libero.png") repeat-x top left';
			$('newsTabPress').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';
			$('newsTabCaseHistory').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';
			
			contentNews[0].show();
		});

		// MAGAZINE
		$('newsTabPress').addEvent('click', function (e)
		{
			if (e) $clear(tabsTimer);
			contentNews.each(function (item, index) { item.hide(); });
			$('newsTabProduct').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabPress').style.borderBottom = '0px';
			$('newsTabCaseHistory').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabProduct').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';
			$('newsTabPress').style.background = '#ffffff url("Images/box-title-libero.png") repeat-x top left';
			$('newsTabCaseHistory').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';			
			contentNews[1].show();
		});

		// CHANNELS
		$('newsTabCaseHistory').addEvent('click', function (e)
		{
			if (e) $clear(tabsTimer);
			contentNews.each(function (item, index) { item.hide(); });
			$('newsTabProduct').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabPress').style.borderBottom = 'dotted 1px #dddddd';
			$('newsTabCaseHistory').style.borderBottom = '0px';
			$('newsTabProduct').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';
			$('newsTabPress').style.background = '#ffffff url("Images/box-title.png") repeat-x top left';
			$('newsTabCaseHistory').style.background = '#ffffff url("Images/box-title-libero.png") repeat-x top left';
			contentNews[2].show();
		});
		// ////////////////////////////////////////////////////////////

		var tabsTimerFunc = function ()
		{
			if (activeTab == 0)
			{
				$('newsTabPress').fireEvent('click', null);
				activeTab = 1;
			}
			else if (activeTab == 1)
			{
				$('newsTabCaseHistory').fireEvent('click', null);
				activeTab = 2;
			}
			else if (activeTab == 2)
			{
				$('newsTabProduct').fireEvent('click', null);
				activeTab = 0;
			}
		};
		tabsTimer = tabsTimerFunc.periodical(8000);
	}
});