$(function() {
	$.nyroModalSettings({
		debug: false,
		processHandler: function(settings) {
			var url = settings.url;
			if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
				$.nyroModalSettings({
					type: 'swf',
					height: 355,
					width: 425,
					url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
				});
			}
		},
		endShowContent: function(elts, settings) {
			$('.resizeLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
					width: Math.random()*1000,
					height: Math.random()*1000
				});
				return false;
			});
			$('.bgLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
					bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
				});
				return false;
			});
		}
	});
});

$.fn.cycle.defaults.timeout = 6000;

function overlay(action,erro){
	if ( action == 'show' ){
		$('#overlay')
		//.height($('html').height())
		//.width($('html').width())
		.show();
		$('#alerta_login').html('<span><a href="#" style="color:#666666; text-decoration:none" onclick="overlay(\'hide\')">fechar&nbsp;&nbsp;<img alt="x" src="/homologacao_final/wp-content/themes/fundacao/_img/fechar_lb.gif"/></a></span>'+erro);
		$('#alerta_login').show();
		
	} else {
		$('#alerta_login').hide();
		$('#alerta_login').html("");
		$('#overlay').removeAttr('style').hide();
	}

}



$(function() {
	
	$('html').supersleight({shim: '_img/s.gif'});

    // run the code in the markup!    
    $('#s4').after('<div class="clear"></div><div id="nav" class="nav">').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 5000,
        pager:  '#nav'
    });
    
  $("#aumenta_fonte").click(function(){
    var currentFontSize = $('.cont').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    $('.cont').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  $("#reduz_fonte").click(function(){
    var currentFontSize = $('.cont').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
    $('.cont').css('font-size', newFontSize);
    return false;
  });

    $("#bt-show-perfil").click(function () {
      $(".show-perfil").toggle("fast");
    });    
    $("#bt-show-relatos").click(function () {
      $(".show-relatos").toggle("fast");
    }); 
	
    $("#bt-show-biblioteca").click(function () {
      $(".show-biblioteca").toggle("fast");
    });    
    $("#bt-show-miditeca").click(function () {
      $(".show-midiateca").toggle("fast");
    }); 	
	
});

function showResponde(){
	$('#show-box-responda').toggle();
}		
function removeError(){
	$('.msg-error').hide();
}

function mudaImagem(urlImagem)
{
	$("#imgFull").attr({src: urlImagem});
}

function change_estados(id_estado,id_combo_cidade,campo_municipio){
	$.post('wp-content/themes/fundacao/monta_estados.php', { id_estado:id_estado,municipio:campo_municipio}, function(data){
		$("#"+id_combo_cidade).html(data);
	});		
}

function changepais(pais,divDifBrasil,divBrasil){
	if( pais == 76){
		$("#"+divDifBrasil).fadeOut();
		$("#"+divBrasil).fadeIn();
	}
	else{
		$("#"+divDifBrasil).fadeIn();
		$("#"+divBrasil).fadeOut();

	}
}

function cad_chat(action,id_chat,id_user,chatok){
	var botimg = "#botPartChat"+id_chat;
	$.post('wp-content/themes/fundacao/add_chat.php', { add_chat:action,id_chat: id_chat,id_user:id_user}, function(data){

		if(data == "ok"){						
			$(botimg).fadeOut(300, function() { $("#botPartChat").attr("src","wp-content/themes/fundacao/_img/bt_usuariocadastrado.gif"); });
			$(botimg).fadeIn(300, function() {  });
		}

		if(data == "ok"){
			if(chatok == "ok")
			{
				var acessachat = '<a href="javascript:;" onclick="javascript:void(centerpopup(\'wp-content/themes/fundacao/chat/?user_id='+id_user+'&id_chat='+id_chat+'\',\'POPUP\',400,600));"><img id="botPartChat" src="wp-content/themes/fundacao/_img/bt_acessarchat.gif"/></a>';
				$(botimg).fadeOut(300, function() { $("#divClick"+id_chat).html(acessachat); });
				$(botimg).fadeOut(300, function() {  });
			}
			else
			{
				$(botimg).fadeOut(300, function() { $(botimg).attr("src","wp-content/themes/fundacao/_img/bt_usuariocadastrado.gif"); });
				$(botimg).fadeIn(300, function() {  });				
			}
		}
	});

	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("msie") != -1) { 
		location.reload(true);
	}else {
		location.reload(false);
	}
}





