/*function animateSWF()
{
	var height = parseInt($('#flash1').css('height'));
	if(height > 140)
	{
		$('#flash1').css('height', (height - 5) + 'px');
		setTimeout('animateSWF()', 2);
	}
	var flash = document.getElementById('flash1');
	var height = parseInt(flash.style.height);
	if(height > 140)
	{
		flash.style.height = (height - 5) + 'px';	
		setTimeout('animateSWF()', 20);
	}
}*/
	/*$('ul#lista_talleres li a').click(function(event){	
		event.preventDefault();
		alert("hola");
		$('ul#lista_talleres li a.selected').removeClass('selected');
		$(this).addClass('selected');
	});*/
//setTimeout('animateSWF()', 3000);

/********************************
* NOTICIAS - HOME ***************
********************************/
$(document).ready(noticiasHome);

var t;
var next;
var selected = 1; /* Primera noticia a mostrar */
var seconds = 30; /* Segundos de espera de una noticia a otra */
var MAX_NOTICIAS = 4;
	
/*
* Muestra las noticias de la página Home y las va rotando cada X segundos.
*/
function noticiasHome()
{
	$('#noticiabody div[id^=noticia_]:not(#noticia_' + selected + ')').hide();
	next = $('#noticiabody div.paginacion ul li').eq(selected % 4);
	setTimeout('showNoticiaHome(next)', seconds * 1000);
	$('#noticiabody div.paginacion ul li').click(function(event){
		event.preventDefault();
		if(!$(this).hasClass('selected'))
		{
			clearTimeout(t);
			showNoticiaHome($(this));
		}
	});	
}
/*
* Muestra la noticia asociada al objeto pasado como parámetro.
* @param current_li jQueryObject El siguiente objeto de la noticia a mostrar.
*/
function showNoticiaHome(current_li)
{
	var li_selected = $('#noticiabody div.paginacion ul li.selected');
	var news_title = $('#noticia_' + selected + ' h3').html();
	li_selected.html('<a title="' + news_title + '" href="javascript:void(0);">' + li_selected.html() + '</a>');
	li_selected.removeClass('selected');
	// establecemos la nueva seleccionada
	current_li.html(current_li.children('a').html());
	current_li.addClass('selected');
	$('#noticiabody div[id^=noticia_]').hide();
	// index del li clickado.
	selected = $('#noticiabody div.paginacion ul li').index(current_li) + 1;
	$('#noticia_' + selected).fadeIn(700);
	next = $('#noticiabody div.paginacion ul li').eq(selected % MAX_NOTICIAS);
	t = setTimeout('showNoticiaHome(next)', seconds * 1000);
}
