var AolsNews = {
	changeApertura: function()
	{
		NEWS = setTimeout(function()
		{
			var finded = null, active = false, firstO = null, firstN = null;
			$('#news_tabs li').each(function(o)
			{
				var a = o.byTag('a')[0], h = a.href.split('#')[1], n = I(h);
				if (!firstO) 
				{
					firstO = o;
					firstN = n;
				}
				if (o.hasClass('open')) 
				{
					n.removeClass('open');
					o.removeClass('open');
					finded = true;
				}
				else if (finded) 
				{
					n.addClass('open');
					o.addClass('open');
					finded = false;
					active = true;
				}
			});
			if (!active && firstO) 
			{
				firstN.addClass('open');
				firstO.addClass('open');
			}
			AolsNews.changeApertura();
		}, 20000);
	},
	stopApertura: function()
	{
		clearTimeout(NEWS);
	}
}, NEWS = null;

Event.add(window, 'domloaded', function()
{
	var firsted = false;
	$('#news_tabs li').each(function(o)
	{
		var a = o.byTag('a')[0], h = a.href.split('#')[1], n = I(h);
		if (n) 
		{
			if (!firsted) 
			{
				o.addClass('open');
				n.addClass('open');
				firsted = true;
			}
			a.addEvent('mouseover', function()
			{
				AolsNews.stopApertura();
				$('#news_lists .open').each(function(b)
				{
					b.removeClass('open');
				});
				o.addClass('open');
				n.addClass('open');
			}).addEvent('mouseout', function()
			{
				AolsNews.changeApertura();
			}).addEvent('click', function(e)
			{
				return e.stop();
			});
			n.addEvent('mouseover', function()
			{
				AolsNews.stopApertura();
			}).addEvent('mouseout', function()
			{
				AolsNews.changeApertura();
			});
			
		}
	});
	AolsNews.changeApertura();
	
	Require.module('widgets', function()
	{
		$('.user-blog').each(function(o)
		{
			var c = o.byClass('details')[0].cloneNode(true);
			
			o.tooltip({
				content: c,
				className: 'tooltip-normal',
				offset: {
					x: -28,
					y: -140
				}
			});
		});
		
	});
	
	Require.module('show', function()
	{
		var a = $('#last_video_rev a')[0];
		
		if (a) 
		{
			var li = I(a.parentNode), href = a.href;
			
			li.insertObject({
				url: href,
				title: a.title,
				width: 250,
				height: 210,
				type: 'flash'
			});
		}
	});
});
