/*  
        Data: Agosto/2011
        Author: Anselmo Cobain (@anselmocobain)
        Autor URI: http://www.webflavia.com.br
*/

var nav = {
	voltar:function()
	{
		nav.atual = nav.repetir( nav.atual - 1 );
		nav.mover();
	},
	
	avancar:function()
	{
		nav.atual = nav.repetir( nav.atual + 1 );
		nav.mover();
		setTimeout("nav.avancar()", 6000);
	},
	
	repetir:function( value )
	{
		return value < 0 ? nav.total + value : ( value >= nav.total ? value % nav.total : value );
	},
	mover:function()
	{
		var alvo = $( '.fila' );
		alvo.animate( { left: nav.atual * -665 }, 900 );	
	},
	iniciar:function()
	{
		nav.atual = 0;
		nav.total = 4;
		setTimeout("nav.avancar()", 6000);
	}
}

function mostrar(value,pagina)
{
	if(pagina=="cursos")
	{
		t = Array('companytexto','aulasviptexto','intensivostexto','iliflextexto');
	}else{
		t = Array('yletexto','kettexto','pettexto','fcetexto','caetexto','tkttexto');
	}
	$('.'+value+'texto').toggle('slow');
	for( i = 0 ; i < t.length ; i++ )
	{
		if(t[i] != value+'texto')
		{
		$('.'+t[i]+'').hide();
		}
	}
}

function exames(value)
{
	a = Array('yle','ket','pet','fce','cae','tkt');
	for( i = 0 ; i < 6 ; i++ )
	{
		$('.'+a[i]+'').animate({marginTop: (15*value)},1500);
		value = -1 * value;
		$('.'+a[i]+'').mouseover(function(){
			$(this).css({'opacity':'0.5'});
			$(this).stop();
		});
		$('.'+a[i]+'').mouseout(function(){
			$(this).css({'opacity':'1'});
		});
	}
	value = -1 * value;
	setTimeout('exames('+value+')',1500);

}

function trocar(classe)
{
	legenda1 = $('.legenda').html();
	legenda2 = $('.'+classe+'').find('p').html();
	link1 = $('iframe').attr('title');
	link2 = $('.'+classe+'').find('img').attr('alt');
	$('.legenda').html(legenda2);
	$('.'+classe+'').find('p').html(legenda1);
	$('iframe').attr('src','http://www.youtube.com/embed/'+link2);
	$('iframe').attr('title', link2);
	$('.'+classe+'').find('img').attr('src','http://img.youtube.com/vi/'+link1+'/default.jpg');
	$('.'+classe+'').find('img').attr('alt', link1);
	
	return false;
}

function openJornal( url )
{
	window.open(url, "jornal", "menubar=yes,resizable=yes,width=820,height=620");
}

$(document).ready(function()
{
	nav.iniciar();
	exames(1);
	
	$('li').click(function(){
		$(this).find('article').slideToggle('slow');
	});
	
	$('.lista').click(function(){
		$(this).find('article').slideToggle('slow');
	});
	
	$('.aprovados h2').click(function(){
		p = 1;
	});
	
	$('.aprovados').click(function(){
		if(p == 1)
		{
			$(this).find('li').slideToggle('slow');
			p = 0;
		}
	});
	
	$('a.fancy').fancybox({
		'opacity'		: true,
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none'
	});

});
