$(document).ready(function(){
	
	// TARGET _blank
	$('a[rel=blank],#home-links a').click(function(){
		window.open(this.href);
		return false;
	});
	
	// TOOLTIP
	$('#conectar a, .conectar a').tipsy({gravity: 's'});
	
	// INPUT
	$('.input, .textarea').focusin(function(){
		$(this).prev().hide();
	}).focusout(function(){
		if ($(this).val() == ''){
			$(this).prev().show();
		}
	});
	
	// MENU
	$('#menu li').mouseenter(function(){
		$(this).addClass('hover');
	}).mouseleave(function(){
		$(this).removeClass('hover');
	});
	
	// INICIAL
		// Agenda
		$('#inicial .agenda .data').click(function(){
			if ($(this).attr('class')!='data ativo'){
				$(this).parent().find('.ativo').animate({backgroundPosition:"(100px 50%)"}, {duration:750})
				$(this).addClass('ativo').siblings().removeClass('ativo');
//				$(this).parent().find('.textos').fadeOut(500);
//				$(this).parent().find('.'+$(this).attr('rel')).fadeIn(500);
				$(this).parent().find('.textos').hide();
				$(this).parent().find('.'+$(this).attr('rel')).show();
			}
		}).mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(50px 50%)"}, {duration:250});
		}).mouseout(function(){
			if ($(this).attr('class')!='data ativo'){
				$(this).stop().animate({backgroundPosition:"(100px 50%)"}, {duration:750});
			}
		});

/*		$('#inicial .agenda div[class^=agenda-]').css('cursor','pointer').click(function(){
			window.location = $(this).find('a').attr('href');
		});*/
        var ppy_opt = {
            caption:    false,
            navigation: 'permanent'
        }
		$('.ppy').popeye(ppy_opt);
			
	// BAR
	$('#bar .fotos a').mouseenter(function(){
		$(this).find('span').fadeIn(250);
	}).mouseleave(function(){
		$(this).find('span').fadeOut(500);
	});
	$('#bar a[rel^="bar"]').colorbox({
		onOpen: function(){ $('#bar object').hide(); },
		onClosed: function(){ $('#bar object').show(); },
		transition:"fade"
	});
	$('#bar .youtube a').css('cursor','pointer').click(function(){
		$(this).hide().next().css({'left':'0', 'top':'0'});
	}).mouseenter(function(){
		$(this).find('img').stop().animate({ 'margin-top':"-32px" }, 500, 'swing');
	}).mouseleave(function(){
		$(this).find('img').stop().animate({ 'margin-top':"0px" }, 1000, 'swing');
	});
	
	// AGENDA
	$('#agenda .capa .agenda').css('cursor','pointer').click(function(){
		window.location = $(this).find('a').attr('href');
	});
	
	// FOTOS	$("#fotosSlider").overscroll();
	$('#fotos .capa .album').mouseenter(function(){
		$(this).find('.hover').fadeIn(250);
	}).mouseleave(function(){
		$(this).find('.hover').fadeOut(500);
	});
	$('#busca-album .dia, #busca-album .mes').find('.float').hide();
	var zIndex = 1;
	$('#busca-album .dia, #busca-album .mes').find('.nome').click(function(){
		zIndex++;
		$(this).parent().css('z-index', zIndex);
		$(this).parent().find('.float').slideDown(250);
	});
	$('#busca-album .dia, #busca-album .mes').mouseleave(function(){
		setTimeout("$('#busca-album .dia, #busca-album .mes').find('.float').slideUp(500);",750);
	}).focusout(function(){
		$(this).find('.float').hide();
	});
	$('#busca-album .dia .float a').mousedown(function(){
		if ($('#busca-album .mes .nome').text() == 'M\u00EAs' ){
			$(this).parent().parent().find('.nome').text($(this).text()).attr('rel', $(this).attr('class'));
			var dia = $(this).attr('class');
			$('.album').hide();
			$('a[rel^='+dia+']').fadeIn(250);
		} else {
			$(this).parent().parent().find('.nome').text($(this).text()).attr('rel', $(this).attr('class'));
			var dia = $(this).attr('class');
			var mes = $('#busca-album .mes .nome').attr('rel');
			$('.album').hide();
			$('a[rel='+dia+'-'+mes+']').fadeIn(250);
		}
	});
	$('#busca-album .mes .float a').mousedown(function(){
		if ($('#busca-album .dia .nome').text() == 'Dia' ){
			$(this).parent().parent().find('.nome').text($(this).text()).attr('rel', $(this).attr('class'));
			var mes = $(this).attr('class');
			$('.album').hide();
			$('a[rel$='+mes+']').fadeIn(250);
		} else {
			$(this).parent().parent().find('.nome').text($(this).text()).attr('rel', $(this).attr('class'));
			var mes = $(this).attr('class');
			var dia = $('#busca-album .dia .nome').attr('rel');
			$('.album').hide();
			$('a[rel='+dia+'-'+mes+']').fadeIn(250);
		}
	});
	$('#busca-album .todos').find('.nome').mousedown(function(){
		$('.album').fadeIn(250);
		$('#busca-album .dia .nome').attr('rel','').text('Dia');
		$('#busca-album .mes .nome').attr('rel','').text('M\u00EAs');
	});
	
	// CONTATO
	$('#contato .newsletter').click(function(){
		if ($(this).find('input').is(':checked') == false){
			$(this).addClass('newsletter-off');
		} else {
			$(this).removeClass('newsletter-off');
		}
	});
	$('#contato #assunto').focusin(function(){
		$(this).next().slideDown(250);
		$(this).css('background-position','left bottom');
	}).focusout(function(){
		$('#contato #assunto').css('background-position','left top').next().hide();
	})
	
	$('.options li').mousedown(function(){
		texto = $(this).text();
		$("#ass").hide();
		$("#assunto").css({'text-transform':'none', 'font-size':'12px'}).val(texto);
		if(texto=='Trabalhe conosco'||texto=='Bandas'){
			$('#anexos').show();
		} else {
			$('#anexos').hide();
		}
	});
	
}); //end document.ready

// formblur.js
function ajustaTextoFocus(campo, texto) {
	if(campo.value == texto)
		campo.value = "";
}
function ajustaTextoBlur(campo, texto) {
	if(campo.value == "")
		campo.value = texto;
}

// YOUTUBE PLAYER
var params = { allowScriptAccess: "always", transparency: "transparent" };
var atts = { id: "youtube", style: "z-index: 1; position:absolute; top:-9999px; left:-9999px;" };
function youtube(id){
	document.getElementById('youtube').loadVideoById(id,0);
}


