$(function(){
	$("a.assistir").fancybox({
		'type'				: 'iframe',
		'overlayOpacity'	: 0.7,
		'overlayColor'		: '#443024',
		'titlePosition' 	: 'none',
		'width'				: 680,
		'height'			: 450,	
		'showCloseButton'	: false
	});	

	$("a.entrevista").fancybox({
		'type'				: 'iframe',
		'padding'			: 0,
		'overlayOpacity'	: 0.7,
		'overlayColor'		: '#443024',
		'titlePosition' 	: 'none',
		'width'				: 680,
		'height'			: 580,	
		'showCloseButton'	: false
	});	

	$("a.popup").fancybox({
		'type'				: 'iframe',
		'padding'			: 0,		
		'overlayOpacity'	: 0.7,
		'overlayColor'		: '#443024',
		'titlePosition' 	: 'none',
		'width'				: 680,
		'height'			: 450,	
		'showCloseButton'	: false
	});	
	
	$("li.rlz").each(function(){
		$(this).css('cursor','pointer');
	});
	
//	$("li.rlz").mouseleave(function(){
//		$('div.texto').css('display','none');
//	})	
	
	$("li.rlz").mouseenter(function(){
		txtId = $(this).attr('rlz');
		$('div.texto').css('display','none');
		$('div#'+txtId).fadeIn('slow');			
	})	
	
	$("a[rel=imprensa]").fancybox({ 
		'overlayOpacity'	: 0.7,
		'padding'			: 2,		
		'overlayColor'		: '#000000',										 
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'showCloseButton'	: false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle		
	})
	
	$('div.texto_imprensa span').click(function(){
		spanId = $(this).attr('id');
		$('a#'+spanId+'_img').trigger('click');
	});
	
	
	setTimeout('slideTabuleiro(2)',7000);
	setTimeout('slideImprensa(2)',7000);
		
});


function slideTabuleiro(n){
	$('div.tabuleiro').css('display',  'none');
	$('div#tab'+n).fadeIn('slow');
	n++;
	if (n == 4) n = 1;
	setTimeout('slideTabuleiro('+n+')',7000);
};


function slideImprensa(n){
	$('div.texto_imprensa span').css('display',  'none');
	$('span#texto'+n).fadeIn('slow');
	n++;
	nLen = ($('div.texto_imprensa span').length) + 1;
	if (n == nLen) n = 1;
	setTimeout('slideImprensa('+n+')',7000);
};


function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title">Imagem ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' &nbsp;&nbsp;&nbsp; <strong style="color:#999;">(Passe o mouse sobre a imagem para avançar ou retroceder)</strong><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="plugins/fancybox-1.3.1/closelabel.gif" /></a></span></div>';
}

$(function(){
	
	$('a[href^=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top - 80;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});	
  
});
