$(document).ready(function() {
    
    $('#toggle-livros').click(function(){
        $('#livros').show();
        buttonOn('#toggle-livros');
        
        $('#bio').hide();
        buttonOff('#toggle-bio');
    });
    
    $('#toggle-bio').click(function(){
        $('#livros').hide();
        buttonOff('#toggle-livros');
        
        $('#bio').show();
        buttonOn('#toggle-bio');
    });

});

function buttonOn(id) {
    $(id + ' img:first-child').attr("src").replace("_off", "_on");
}

function buttonOff(id) {
    $(id + ' img:first-child').attr("src").replace("_on", "_off");
}

@@ -79,28 +79,34 @@
         
-$
+activate
 ('
-#
 livros')
 .show();
@@ -97,23 +97,16 @@
 livros')
-.show()
 ;%0A      
@@ -111,40 +111,31 @@
     
-buttonOn('#toggle-livros
+deactivate('bio
 ');%0A    
     
@@ -122,32 +122,36 @@
 ate('bio');%0A    
+%7D);%0A
     %0A        $('
@@ -147,29 +147,42 @@
     
-    $('#bio').hide();
+$('#toggle-bio').click(function()%7B
 %0A   
@@ -190,119 +190,127 @@
     
-buttonOff('#toggle-bio');%0A    %7D);%0A    %0A    $('#toggle-bio').click(fun
+deactivate('livros');%0A        activate('bio');%0A    %7D);%0A%0A%7D);%0A%0Afunction activate(se
 ction
-(
 )
+ 
 %7B%0A    
-    $('#livros').hide();%0A    
+$('#' + section).show();%0A
     
@@ -316,18 +316,17 @@
  buttonO
-ff
+n
 ('#toggl
@@ -331,57 +331,85 @@
 gle-
-livros');%0A        %0A  
+' + section);%0A%7D%0A%0Afunction deactivate(section) %7B%0A
     
-  
 $('#
-bio').show
+' + section).hide
 ();%0A
-    
     
@@ -407,33 +407,34 @@
 e();%0A    buttonO
-n
+ff
 ('#toggle-bio');
@@ -427,35 +427,31 @@
 #toggle-
-bio');%0A    %7D
+' + section
 );%0A
-%0A
 %7D
-);
 %0A%0Afuncti

Refactor toggle buttons code