/*
*  switcher pour afficher les statements
* required jQuery
*
* erational <http://www.erational.org>
* 2010.09.21
*
*/

$(document).ready(function(){

    // statement switch
		$("#statement").hide();	
		$("#statement").before("<a href='#' id='statement_button'>texte</a>");
    $("#statement").before("<a href='#' id='image_button'>images</a>");
    $("#image_button").hide();		
		
		$("#statement_button").click(function() {		   
        $("#statement").show();	
        $("#img-container").hide(); 
        $(this).hide();
        $("#image_button").show();       
    });
   
    
    $("#image_button").click(function() { 
        $("#statement").hide();	
        $("#img-container").show();	
        $(this).hide(); 
        $("#statement_button").show();                  
    });
    
    
    // folding menu fix
    // supprimer les menus d'un seul lien
    // pour placer le lien en tete de chapitre
    $("li.section-title").each(function(index) {
       //alert(index + ': ' + $(this).text());
      // un seul fils ?
      // nextAll pas dispo :c
       if (($(this).next().html() != "") &&  ($(this).next().next().html() == null)) {           
            var t = $(this).next("li a").children().attr("href");
            $(this).next().remove();
            var o = $(this).html();
            var nouveau_lien = "<a href='"+t+"'  onclick='do_click();'>"+o+"</a>";
            $(this).empty().append(nouveau_lien);
            $(this).click(function() { 
                document.location = t;                 
            }); 
       }
       
    });

    
    
});


