$(function(){
	$('.content-title').textShadow();
	$('a[rel="external"]').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	$('#header-slider').cycle({
		fx:     'fade',
		delay:  -5000,
		cleartypeNoBg: true
	});
	$('.noti-lista').cycle({ 
		fx: 'scrollLeft', 
		speed: 600, 
		timeout: 6000,
		next: '.noti-nav-right', 
		prev: '.noti-nav-left' 
	});
	$('#pub-01').cycle({ 
		fx: 'scrollDown', 
		speed: 600,
		timeout: 3000
	});
	$('.videos-lista li a').click(function () {
		var codigo = $(this).attr('rel');
		var obj  = '<object>';
			obj += '<param name="movie" value="http://www.youtube.com/v/'+codigo+'?fs=1&amp;showinfo=0&amp;rel=0"</param>';
			obj += '<param name="allowFullScreen" value="true"></param>';
			obj += '<embed';
			obj += '	src="http://www.youtube.com/v/'+codigo+'?fs=1&amp;showinfo=0&amp;rel=0"';
			obj += '	type="application/x-shockwave-flash"';
			obj += '	allowfullscreen="true"';
			obj += '	width="370" height="250"';
			obj += '	wmode="transparent">';
			obj += '</embed>';
			obj += '</object>';
		$('.videos-cont').html(obj);
		$('.videos-lista li a').removeClass('active');
		$(this).addClass('active');
		return false;
	});
	$('a[rel=fotos]').fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	$('a[rel=video]').click(function() {
		$.fancybox({
			'type' : 'iframe',
			'href' : this.href.replace(new RegExp('watch\\?v=', 'i'), 'embed/') + '?rel=0&autoplay=1',
			'overlayShow' : true,
			'centerOnScroll' : true,
			'speedIn' : 100,
			'speedOut' : 50,
			'width' : 640,
			'height' : 480
		});
		return false;
	});
	$('a[rel=musica]').click('click', function() {
		postUrl = $(this).attr('href');
		$.fancybox.showActivity();
		$.get(postUrl,function(data){
			$.fancybox(data,{'scrolling':false});
		});
		return false;
	});
	$('#lista-fotos li').hover(
		function(){
			var test = $(this).data();
			$.each($('#lista-fotos li'), function(key, value) {
				var test2 = $(value).data();
				if (test != test2) {
					$(value).addClass('opacity');
				}
			});
		},
		function(){
			$('#lista-fotos li').removeClass('opacity');
		}
	);
	$('.comuni-lista li').hover(
		function(){
			var test = $(this).data();
			$.each($('.comuni-lista li'), function(key, value) {
				var test2 = $(value).data();
				if (test != test2) {
					$(value).addClass('opacity');
				}
			});
		},
		function(){
			$('.comuni-lista li').removeClass('opacity');
		}
	);
	$('#menu-item-187 a').click( function() {
		var href = $(this).attr('href');
		window.open(href, 'player-colmeia', 'height=480, width=322, toolbar=no');
		return false;
	});
	$('#ao-vivo').click(function(){
		var href = $(this).attr('href');
		window.open(href, 'player-colmeia', 'height=480, width=322, toolbar=no');
		return false;
	});
    /* inicio efeito menu */
    $("#menu-principal").append('<li id="magic-line"></li>');
    /* Cache it */
    var $magicLine = $("#magic-line");
    $magicLine
        .width($(".current-menu-item").width())
        .css("left", $(".current-menu-item a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#menu-principal li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });    
    });
    /* fim efeito menu */
	$("div.apresent").hover(function() {
		$(this).css({'z-index' : '10'});
		$(this).find('img').stop()
			.animate({
				marginTop: '-7px', 
				marginLeft: '-8px', 
				top: '30%', 
				left: '30%', 
				width: '200px', 
				height: '170px',
				padding: '0'
			}, 150);
		
		} , function() {
		$(this).css({'z-index' : '0'});
		$(this).find('img').stop()
			.animate({
				marginTop: '0', 
				marginLeft: '0',
				top: '0', 
				left: '0', 
				width: '183px', 
				height: '150px',
				padding: '0'
			}, 150);
	});
});
