$(document).ready(function(){

    $("#tab-filosofia").click(function(){
        hideTabs();
        changeImage(this);
        $("#filosofia").css("display", "block");
        return false;
    });

    $("#tab-performance").click(function(){
        hideTabs();
        changeImage(this);
        $("#performance").css("display", "block");
        $("#tabela-rentabilidade").css("display","block");
        return false;
    });

    $("#tab-como").click(function(){
        hideTabs();
        changeImage(this);
        $("#como").css("display", "block");
        return false;
    });

    $('#menu a img[src*=_on]').addClass('active');

    $('#menu a img:not(.active)').hover(function(){
        _img = $(this).attr('src').replace('_off', '_on');
        $(this).attr('src', _img);
        $('#menu a img.active').attr('src', $('#menu a img.active').attr('src').replace('_on', '_off'));
    },function(){
        _img = $(this).attr('src').replace('_on', '_off');
        $(this).attr('src', _img);
        $('#menu a img.active').attr('src', $('#menu a img.active').attr('src').replace('_off', '_on'));
    });

    $('#menu .miolo').hover(function(){
        $('#menu a img.active').attr('src', $('#menu a img.active').attr('src').replace('_on', '_off'));
    },function(){
        $('#menu a img.active').attr('src', $('#menu a img.active').attr('src').replace('_off', '_on'));
    });

    $('.zebra tbody tr:odd').addClass('cinzinha');

    if($('#home_content')[0]){

    }

});

function culture() {
    var c = /\/(pt|en|es)/.exec(window.location.pathname);
    return c? c[1] : 'pt';
}

function menu(url){
    if(url == '/index') {
        window.location = '/' + culture();
    }
    else{
        window.location = '/' + culture() + '/' + url;
    }
}

function changeImage(object){
    imagem = $("img", object);
    newSource = imagem.attr("src").replace(/_[a-z]+\./,"_on.");
    imagem.attr("src", newSource);
}

function hideTabs(){
    //Esconde o Conteúdo
    $(".conteudo-tab").hide();
    $("#tabela-rentabilidade").hide();
    //Muda as imagem para off
    newSource = $("#tab-filosofia img").attr("src").replace(/_[a-z]+\./,"_off.");
    $("#tab-filosofia img").attr("src", newSource);

    newSource = $("#tab-performance img").attr("src").replace(/_[a-z]+\./,"_off.");
    $("#tab-performance img").attr("src", newSource);

    newSource = $("#tab-como img").attr("src").replace(/_[a-z]+\./,"_off.");
    $("#tab-como img").attr("src", newSource);

}

// popup
function janela(url, nome, param) {
    window.open(url, nome, param);
}


