// JavaScript Document
$(function(){
	
	// Adiciona Ativo para a tag A = href
	$("#menu li a[href='" + location.href.split("/")[location.href.split("/").length  - 1] + "']").each(function(){
		$(this).addClass("ativo")
	})
	// Adiciona #Ativo para o Li da tag A ativa
	$("#menu li a[class=ativo]").parent().parent().attr("id", "ativo")
	// Efeitos do menu
	$("#menu li[id!=ativo]").hover(function(){
		$("#menu li").removeClass("ativo")
		$(this).find('div:eq(1)').slideUp("fast", function(){
			$(this).parent().addClass("ativo")
			$(this).slideDown(200)
		})
	}, function (){
		$(this).find('div:eq(1)').slideUp(150, function(){
			$(this).parent().removeClass("ativo")
			$(this).slideDown(100)
		})
	})
	// Não exibe title
	$("#menu li a").attr("title", "")
	//
	//$(".macaya-suares-battan").css("height", parseInt($(".internacional").css("height"))-70 + "px")
	
	// Página Sócios Abre e Fecha detalhes
	$(".socios div").click(function(){
		if($(this).find(".detalhes-socio").css("display") != "block") {
			$(this).find(".detalhes-socio").slideDown("normal")
		} else {
			$(this).find(".detalhes-socio").slideUp("normal")	
		}
	})
	
	//Data e hora
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var currentYear = (new Date).getFullYear()
	var timeValue = "" + ((hours >12) ? hours -12 :hours)
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	timeValue += (hours >= 12) ? " PM" : " AM"
	timerRunning = true;
	
	mydate = new Date();
	myday = mydate.getDay();
	mymonth = mydate.getMonth();
	myweekday= mydate.getDate();
	weekday= myweekday;
	myyear= mydate.getYear();
	year = currentYear
 	
	
	
	if(myday == 0)
	day = " Domingo, "
	
	else if(myday == 1)
	day = " Segunda, "
	
	else if(myday == 2)
	day = " Ter&ccedil;a, "
	
	else if(myday == 3)
	day = " Quarta, "
	
	else if(myday == 4)
	day = " Quinta, "
	
	else if(myday == 5)
	day = " Sexta, "
	
	else if(myday == 6)
	day = " S&aacute;bado, "
	
	if(mymonth == 0)
	month = " de Janeiro de "
	
	else if(mymonth ==1)
	month = " de Fevereiro de "
	
	else if(mymonth ==2)
	month = " de Mar&ccedil;o de "
	
	else if(mymonth ==3)
	month = " de Abril de "
	
	else if(mymonth ==4)
	month = " de Maio de "
	
	else if(mymonth ==5)
	month = " de Junho de "
	
	else if(mymonth ==6)
	month = " de Julho de "
	
	else if(mymonth ==7)
	month = " de Agosto de "
	
	else if(mymonth ==8)
	month = " de Setembro de "
	
	else if(mymonth ==9)
	month = " de Outubro de "
	
	else if(mymonth ==10)
	month = " de Novembro de "
	
	else if(mymonth ==11)
	month = " de Dezembro de "
	
	dataHoraAtual = day + myweekday + month + year + " - " + timeValue
	
	//Inclui data no Strong da #Data
	$("#data strong").html(dataHoraAtual) 
	
	
	// Widget do twitter
	if ($(document).find("#twitter").length == 1){
	
		new TWTR.Widget({ id:'twitter', version: 2, type: 'profile',rpp: 3, interval: 6000,  width: 270,  height: 300, theme: { shell: { background: '#bedeeb', color: '#0099cc'}, tweets: {  background: '#ebf6fb',  color: '#666666', links: '#0099cc'}}, features: {scrollbar: false, loop: false, live: false, hashtags: true,timestamp: true,avatars: false,	behavior: 'all'}}).render().setUser('searchrh').start();
	
	}
	
	//Página Search na Mídia
	$(".listagem-search-midia li img, .listagem-search-midia li .conteudo-de-texto, .thumbs a img").css("opacity", "0.3")
	
	$(".listagem-search-midia li, .thumbs a").hover(function(){
		$(this).find("img").animate({
			opacity:1
		}, 240)
	}, function(){
		$(this).find("img").animate({
			opacity:0.3
		}, 100)
	})
	//
	if ($(".conteudo-de-texto").length >= 1) {
		$(".conteudo-de-texto").hover(function(){
			$(this).animate({
				opacity:1
			}, 240)
		}, function(){
			$(this).animate({
				opacity:0.3
			}, 100)
		})
	}
	
	//Formulários
	$("input, textarea").focus(function(){
		$(this).css("background", "#FBFFDF")
		$(this).parent().find("span").css("color", "#0099CC")
	})
	$("input, textarea").blur(function(){
		$(this).css("background", "#fff")
		$(this).parent().find("span").css("color", "#979797")
	})
	
	// Ir para o Topo da página
	//$(".topo").click().animate({scrollTo: $("#conteudo")}, 200)
	$("a.topo").click(function(){
		$('html,body').animate({scrollTop: $("#rastro").offset().top}, 900)
	})

})

