var AjaxUrl = 'wp-content/themes/thematic/Ajax.php';
function RefreshThickBox() {
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;	
	var thickboxL10n = {
		next: "Próximo &raquo;",
		prev: "&laquo; Anterior",
		image: "Imagem",
		of: "de",
		close: "Fechar"
	};
	try{convertEntities(thickboxL10n);}catch(e){};
}
function HoverDestaque(Id) {
	if(jQuery('#TituloVideoPlaylist_'+Id).is('.TituloVideoPlaylistActive')) {
	} else {	
		jQuery('.BordaThumbVideoPlaylist').not('.BordaThumbVideoPlaylistActive').css({'border-top':'2px solid #FFF','border-bottom':'2px solid #FFF'});
		jQuery('#BordaThumbVideoPlaylist_'+Id).css({'border-top':'2px solid #F39829','border-bottom':'2px solid #F39829'});
		
		jQuery('.TituloVideoPlaylist').not('.TituloVideoPlaylistActive').css('color','#EF3F27');
		jQuery('#TituloVideoPlaylist_'+Id).css('color','#F39829');
	}	
}
function UnhoverDestaque(Id) {
	if(jQuery('#TituloVideoPlaylist_'+Id).is('.TituloVideoPlaylistActive')) {
	} else {
		jQuery('.BordaThumbVideoPlaylist').not('.BordaThumbVideoPlaylistActive').css({'border-top':'2px solid #FFF','border-bottom':'2px solid #FFF'});
		jQuery('.TituloVideoPlaylist').not('.TituloVideoPlaylistActive').css('color','#EF3F27');
	}
}
function AbreSubMenu(Index) {
	jQuery('.MenuList').hide();
	jQuery('.MenuItem').eq(Index).show();
	
	//jQuery('#Menu').css('border-bottom','1px solid #939598');
	//jQuery('.MenuItem').eq(Index).css('border-bottom','1px solid #939598');
}

function FechaSubMenu(Index) {
	
	jQuery('.MenuItem').eq(Index).hide();
	//jQuery('#Menu').css('border-bottom','1px solid #FFF');
	//jQuery('.MenuItem').eq(Index).css('border-bottom','1px solid #FFF');
}

function ColoreSelecionado(Post) {
	jQuery('.BordaThumbVideoPlaylist').removeClass('BordaThumbVideoPlaylistActive');
	jQuery('.TituloVideoPlaylist').removeClass('TituloVideoPlaylistActive');
	
	jQuery('.BordaThumbVideoPlaylist').css({'border-top':'2px solid #FFF','border-bottom':'2px solid #FFF'});
	jQuery('.TituloVideoPlaylist').css('color','#EF3F27');	
	
	jQuery('#TituloVideoPlaylist_'+Post).addClass('TituloVideoPlaylistActive');
	jQuery('#BordaThumbVideoPlaylist_'+Post).addClass('BordaThumbVideoPlaylistActive');
	
	jQuery('#BordaThumbVideoPlaylist_'+Post).css({'border-top':'2px solid #F39829','border-bottom':'2px solid #F39829'});
	jQuery('#TituloVideoPlaylist_'+Post).css('color','#F39829');
}

function SelecionaPostDestaque(Post) {
	
	jQuery('#PostSelecionadoPlaylist').val(Post);
	ColoreSelecionado(Post);
	
	jQuery('#DivPostDestaque').css('height', 326);
	jQuery('#DivPostDestaque').fadeOut('fast', function() {
		  jQuery('#DivPostDestaque').html('');
		  jQuery('#TituloPostDestaque').html("Carregando...");
		  jQuery('#DivPostDestaque').addClass('AjaxLoadingVideo');
		  jQuery('#DivPostDestaque').show();
		  jQuery.get(AjaxUrl,  {Acao: "SelecionaPostDestaque", Post: Post }, function(data){	
				var Split = data.split("[xox]");
				jQuery('#DivPostDestaque').removeClass('AjaxLoadingVideo');
				jQuery('#DivPostDestaque').css('height', 'auto');
				document.getElementById('TituloPostDestaque').innerHTML = Split[0];
				document.getElementById('DivPostDestaque').innerHTML = Split[1];
				//jQuery('#TituloPostDestaque').html(Split[0]);
				//jQuery('#DivPostDestaque').html(Split[1]);
		  });				  
	});
}	
function GetDestaques(Pagina) {
	 jQuery('#PostPlaylist').css('height', 326);
	 jQuery('#PostPlaylist').fadeOut('fast', function() {
		  jQuery('#PostPlaylist').html('<div class="Aviso" style="font-weight: bold; font-size: 14px;">Carregando...</div>');
		  jQuery('#PostPlaylist').addClass('AjaxLoadingVideo');
		  jQuery('#PostPlaylist').show();
		  jQuery.get(AjaxUrl,  {Acao: "GetDestaques", Pagina: Pagina }, function(data){	
				
				
				jQuery('#PostPlaylist').removeClass('AjaxLoadingVideo');
				document.getElementById('PostPlaylist').innerHTML = data;
				//jQuery('#PostPlaylist').html(data);
				//alert(jQuery('#PostSelecionadoPlaylist').val());
				ColoreSelecionado(jQuery('#PostSelecionadoPlaylist').val());

		  });				  
	 });
}
function GetUltimasNoticias() {
	 jQuery('.LiDia').removeClass('LiDiaActive');
	 var x = jQuery("#MenuDiasIndex").offset().top - 50;
	 jQuery('html,body').animate({scrollTop: x}, 1200);	
	 jQuery('#ConteudosIndex').css('height', 326);
	 jQuery('#ConteudosIndex').fadeOut('fast', function() {
		  jQuery('#ConteudosIndex').html('<div class="Aviso" style="font-weight: bold; font-size: 14px;">Carregando...</div>');
		  jQuery('#ConteudosIndex').addClass('AjaxLoadingConteudo');
		  jQuery('#ConteudosIndex').show();
		  jQuery.get(AjaxUrl,  {Acao: "GetUltimasNoticias" }, function(data){	
																	   
				jQuery('#ConteudosIndex').removeClass('AjaxLoadingConteudo');
				document.getElementById('ConteudosIndex').innerHTML = data;
				//jQuery('#ConteudosIndex').html(data);
				jQuery('#ConteudosIndex').css('height', 'auto');	
				RefreshThickBox();
		  });				  
	 });
}

function SelecionaDia(Dia) {
	 var x = jQuery("#MenuDiasIndex").offset().top - 50;
	 jQuery('html,body').animate({scrollTop: x}, 1200);	
	 jQuery('.LiDia').removeClass('LiDiaActive');
	 jQuery('#Dia_'+Dia).addClass('LiDiaActive');
	 jQuery('#ConteudosIndex').css('height', 326);
	 jQuery('#ConteudosIndex').fadeOut('fast', function() {
		  jQuery('#ConteudosIndex').html('<div class="Aviso" style="font-weight: bold; font-size: 14px;">Carregando...</div>');
		  jQuery('#ConteudosIndex').addClass('AjaxLoadingConteudo');
		  jQuery('#ConteudosIndex').show();
		  jQuery.get(AjaxUrl,  {Acao: "GetPostsDia", Dia: Dia }, function(data){	
				jQuery('#ConteudosIndex').css('height', 'auto');															  
				jQuery('#ConteudosIndex').removeClass('AjaxLoadingConteudo');
				//jQuery('#ConteudosIndex').html(data);
				document.getElementById('ConteudosIndex').innerHTML = data;
				RefreshThickBox();
		  });				  
	 });
}

function Cadastrar(Id) {
	var Nome = jQuery('#Cadastro_Nome').val();
	var Sexo = jQuery('#Cadastro_Sexo').val();
	var Estado = jQuery('#Cadastro_Estado').val();
	var Cidade = jQuery('#Cadastro_Cidade').val();
	var Email = jQuery('#Cadastro_Email').val();
	if(document.getElementById('Cadastro_ReceberNoticias').checked) {
		var ReceberNoticias = 1;
	} else {
		var ReceberNoticias = 0;
	}
	if(jQuery('.Cadastro_Sexo:checked').length > 0) {
		Sexo = "M";	
	} else {
		Sexo = "F";		
	}
	var Humano = 'Sim';
    jQuery.get(AjaxUrl,  {Acao: "Cadastrar", Humano: Humano, Nome: Nome, Sexo: Sexo, Estado: Estado, Cidade: Cidade, Email: Email, ReceberNoticias: ReceberNoticias }, function(data){																																										
		if(data == 1) {
			alert("Todos os campos devem ser preenchidos!");
		} else {
			alert('Seu cadastro foi realizado!\nObrigado por participar!');
			window.location = '?index.php';
		}

    });
	
}
function Cadastrar_Forum(Id) {
	var Nome = jQuery('#Cadastro_Nome').val();
	//var Sexo = jQuery('#Cadastro_Sexo').val();
	var Endereco = jQuery('#Cadastro_end').val();
	var Estado = jQuery('#Cadastro_Estado').val();
	var Cidade = jQuery('#Cadastro_Cidade').val();
	var Email = jQuery('#Cadastro_Email').val();
	var Telefone = jQuery('#Cadastro_fone').val();
	var Profissao = jQuery('#Cadastro_prof').val();
	var Instituicao = jQuery('#Cadastro_inst').val();
	/*if(document.getElementById('Cadastro_ReceberNoticias').checked) {
		var ReceberNoticias = 1;
	} else {
		var ReceberNoticias = 0;
	}
	if(jQuery('.Cadastro_Sexo:checked').length > 0) {
		Sexo = "M";	
	} else {
		Sexo = "F";		
	}*/
	var Humano = 'Sim';
    jQuery.get(AjaxUrl,  {Acao: "Cadastrar_Forum", Humano: Humano, Nome: Nome, Endereco: Endereco, Estado: Estado, Cidade: Cidade, Email: Email, Telefone: Telefone, Profissao: Profissao, Instituicao: Instituicao }, function(data){																																										
		if(data == 1) {
			alert("Todos os campos devem ser preenchidos!");
		} else {
			alert('Seu cadastro foi realizado!\nObrigado por participar!');
			window.location = '?index.php';
		}

    });
	
}