var $j = jQuery.noConflict();

var image_loader = '<div style="text-align: center"><img src="../~cms/templates/images/loader.gif" alt="loading..." /></div>';

$j(document).ready(function()
{

});


//PAPEL DIGITAL inicio//
function trocar_papel_digital(id_elem,nr_elem)
{
	if(id_elem && nr_elem)
	{
		for(var i=0; i<nr_elem; i++)
		{
			var papel = document.getElementById('id_papeldigital'+i);
			if(id_elem == i)
			{
				papel.style.display = 'block';
			}
			else
			{
				papel.style.display = 'none';
			}
		}
	}
}

//PAPEL DIGITAL fim//

//METEOROLOGIA inicio//
function ajax_get_meteo(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#meteorologia";
	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_meteo", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );


}

function ajax_get_meteo_cidades(inf)
{

	var endereco_completo = document.getElementById('endereco_base').innerHTML;

	var id_elem = "#meteorologia_cidades";

	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_meteo_cidades", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}
//METEOROLOGIA fim//

//FARMACIAS inicio//
function ajax_get_farmacias(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#farmacias";
	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_farmacias", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

function ajax_get_farmacias_cidades(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#farmacias_cidades";

	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_farmacias_cidades", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}
//FARMACIAS fim//

//MARES inicio//
function ajax_get_mares(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#mares";
	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_mares", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

function ajax_get_mares_cidades(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#mares_cidades";

	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_mares_cidades", info: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}
//MARES fim//

//BOLSA vertical inicio//
function ajax_get_bolsa_v(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#bolsa_v";
	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_bolsa_v", info: inf},
        function(responseText){$j(id_elem).html(responseText);bolsa_ticker_v();},
        "html"
    );
}

var bolsa_first = 0;
var bolsa_speed = 700;
var bolsa_pause = 2000;

var bolsa_first2 = 0;
var bolsa_speed2 = 700;
var bolsa_pause2 = 2000;

function bolsa_ticker_v()
{
	bolsa_v_removeFirst()
	interval = setInterval(bolsa_v_removeFirst, bolsa_pause);
}

function bolsa_v_removeFirst(){
	bolsa_first = $j('ul#listticker_bolsa_v li:first').html();

	$j('ul#listticker_bolsa_v li:first').animate({opacity: 0}, bolsa_pause).fadeOut('fast',function() {$j('ul#listticker_bolsa_v li:first').remove();bolsa_v_addLast(bolsa_first)});
}

function bolsa_v_addLast(first){
	last = '<li style="display:none">'+first+'</li>';

	$j('ul#listticker_bolsa_v').append(last);

	$j('ul#listticker_bolsa_v li:last').animate({opacity: 1}, bolsa_speed).fadeIn('slow');
}

///////////

function ajax_get_bolsa_h(inf)
{
	var endereco_completo = document.getElementById('endereco_base').innerHTML;
	var id_elem = "#bolsa_h";
	$j.ajaxSetup ({cache: false});

    //$j(id_elem).html(image_loader);

    $j.post(
        endereco_completo+"/~informa_centralizada/index.php",
        {accao: "get_bolsa_h", info: inf},
        function(responseText){$j(id_elem).html(responseText);bolsa_ticker_h();},
        "html"
    );
}

function bolsa_ticker_h()
{
	bolsa_h_removeFirst()
	interval = setInterval(bolsa_h_removeFirst, bolsa_pause2);
}

function bolsa_h_removeFirst(){
	bolsa_first2 = $j('ul#listticker_bolsa_h li:first').html();

	$j('ul#listticker_bolsa_h li:first').animate({opacity: 0}, bolsa_pause2).fadeOut('fast',function() {$j('ul#listticker_bolsa_h li:first').remove();bolsa_h_addLast(bolsa_first2)});
}

function bolsa_h_addLast(first){
	last = '<li style="display:none">'+first+'</li>';

	$j('ul#listticker_bolsa_h').append(last);

	$j('ul#listticker_bolsa_h li:last').animate({opacity: 1}, bolsa_speed2).fadeIn('slow');
}
//BOLSA vertical  fim//

// Galeria Multimedia inicio //

function get_gm(inf)
{
	var id_elem = "#fo_gm_cat";
	var id_filtro = document.getElementById('tipo_gm_cat').value;

	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        "../~cms/modulos/galeria_multimedia/galeria_multimedia_proc.php",
        {accao: "fo_get_galeria_multimedia", info: inf, filtro: id_filtro},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

function get_gm_view(inf)
{
	var id_elem = "#fo_gm_view";
	var id_filtro = "todos";//document.getElementById('tipo_gm_cat').value;


	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        "../~cms/modulos/galeria_multimedia/galeria_multimedia_proc.php",
        {accao: "fo_get_galeria_multimedia_view", info: inf, filtro: id_filtro},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

function get_gm_destaque()
{
	var id_elem = "#fo_gm_destaque";
	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        "../~cms/modulos/galeria_multimedia/galeria_multimedia_proc.php",
        {accao: "fo_get_galeria_multimedia_destaque"},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

// Galeria Multimedia fim //

// Calendario V2 inicio //
function fo_get_calendario(data)
{
	var id_elem = "#fo_calendario";

	var inf = document.getElementById('info_calendar').value;

	$j.ajaxSetup ({cache: false});

    $j(id_elem).html(image_loader);

    $j.post(
        "../~cms/comuns/calendario/fo_calendario_ajax.php",
        {data: data, inf: inf},
        function(responseText){$j(id_elem).html(responseText);},
        "html"
    );
}

function get_mes(data)
{
	fo_get_calendario(data);
}

function pick_data(data)
{
	window.location = "index.php?info=YToxOntzOjU6Im9wY2FvIjtzOjE0OiJsaXN0YXJfZXZlbnRvcyI7fQ==&data="+data;
}

// Calendario V2 fim //
