// JavaScript Document
var currentYear = 1993;

function initbio(time)
{	
	$('.timelineitemArrow').corner('cc:#ececec bevel br bl 8px');
	$('.bioContenArrow').corner('cc:#ececec bevel tr tl 8px');
	
	$('.timelineitem').hover(
		function() 
		{
			$(this).children(".timelineitemArrow").stop(true, true).animate({"backgroundColor": "#f17100"}, timeOver);
			$(this).children(".timelineitemText").stop(true, true).animate({"color": "#000"}, timeOver);	
		},
		function() 
		{
			if(currentYear!=$(this).attr("ID"))
			{
				$(this).children(".timelineitemArrow").stop(true, true).animate({"backgroundColor": "#bfbfbf"}, timeOver);
				$(this).children(".timelineitemText").stop(true, true).animate({"color": "#333"}, timeOver);
			}
		}
	);
	$('.timelineitem').click(
		function() 
		{
			changeContentYear($(this).attr("ID"));
		}
	);
	
	$('.bioContainerPhotoItem').hover(
		function() 
		{
			$(this).children('a').children(".photoItemOver").stop(true, true).fadeIn();
		},
		function() 
		{
			$(this).children('a').children(".photoItemOver").stop(true, true).fadeOut();
		}
	);
	
	$(".videoPlayer").colorbox({initialWidth:500, initialHeight:300, innerWidth:735, innerHeight:498, iframe:true, opacity:0.9, transition:"elastic", arrowKey:false});
	$(".photoBio").colorbox({initialWidth:500, initialHeight:300, opacity:0.9, transition:"elastic", arrowKey:false, onComplete:putTitle});
	
	changeContentYear(currentYear);
	
	window.setTimeout(function() 
	{
		changeContentYear(currentYear);		
	}, 3000);
}

function setCurrentYear(year)
{
	currentYear = year;
}

function changeContentYear(year)
{
	currentYear = year;	
	$('.timelineitem').each(
		function() 
		{
			var yy = $(this).attr("ID");
			if(yy==year)
			{
				$(this).children(".timelineitemArrow").stop(true, true).animate({"backgroundColor": "#f17100"}, 300);
				$(this).children(".timelineitemText").stop(true, true).animate({"color": "#000"}, 300);
				$(this).css({"cursor":"default"});
				var lf = $(this).css("left");
				$('.bioContenArrowbox').stop(true, true).animate({"left": lf}, {queue:false, duration: 800, easing:"quartEaseInOut"});
				$('.bioContentItemTitulo span').html(year);
				$("#bio"+yy).fadeIn(500, function () {
					var hhx = $(this).css("height");
					hhx = hhx.replace("px", "");
					hhx = (Number(hhx) + 80);
					$("#bioContent").stop(true, true).animate({"height": hhx}, 500);
				});
			}else
			{
				$(this).children(".timelineitemArrow").stop(true, true).animate({"backgroundColor": "#bfbfbf"}, 300);
				$(this).children(".timelineitemText").stop(true, true).animate({"color": "#333"}, 300);
				$(this).css({"cursor":"pointer"});
				$("#bio"+yy).fadeOut();
			}
		}
	);
}
