/**
 * Código Javascript - Site Cia Suspensa
 * @author João Gabriel Fraga - jgfraga@gmail.com
 */

$('document').ready(function(){

	// Mostrar imagens de um espetáculo
	if( document.getElementById('imagens-espetaculo') && $('#imagens-espetaculo img').length > 0 ){
		var imagesholder = $('#imagesholder'),
			imagesespetaculo = $('#imagens-espetaculo').html(),
			active_image = imagesholder.find('.active'),
			ficha_tecnica = $('#ficha-tecnica');
      video = $('#videos-espetaculo');
			
			imagesholder.empty().append(imagesespetaculo);
			imagesholder.prepend(ficha_tecnica);
      imagesholder.prepend(video);
			
			imagesholder.find('a').click(function(){
				var image_src = $(this).attr('image-src'),
			     	active_image = imagesholder.find('.active');
				
				active_image.html('<img src="'+image_src+'" />');
				active_image.fadeIn();
				active_image.click(function(){
					$(this).fadeOut();
				})
			})
	}
  
})

var abrir_ficha_tecnica = function(){
	$('#imagesholder .active').fadeOut();
  esconder_video();
	$('#ficha-tecnica').fadeIn();
}

var esconder_ficha_tecnica = function(){
	$('#imagesholder .active').hide();
	$('#ficha-tecnica').fadeOut();
}

var abrir_video = function(){
	$('#imagesholder .active').fadeOut();
  esconder_ficha_tecnica();
	$('#videos-espetaculo').fadeIn();  
}

var esconder_video = function(){
	$('#imagesholder .active').hide();
	$('#videos-espetaculo').fadeOut();
}

