function changeCSS (mode){     // CSS MODULES
    $("text").className= mode;
}

function Percentage() {
    list = $$("pre");
    total = $$("pre").length;
    ratio = Math.floor(total/3);
    for (i=0 ; i< (total-ratio) ; i++) {
        random = Math.floor( (total) * Math.random() );
        //console.log(random);
        list[random].className = "invisible";
    }
}

function SaveTheText() {
	paragraphs = $$('pre')
	for (i=0; i< paragraphs.length; i++){
		content = paragraphs[i].innerHTML
		paragraphs[i].innerHTML='<blockquote>' + content + '</blockquote>'
	}

    emptyComments = $$('div.hidden:empty');
    //console.log(emptyComments);
    for (i=0 ; i < emptyComments.length ; i++) {
        // récupère #showComments vides puis le paragraphe associé
        uncommented = emptyComments[i].ancestors()[0].previousSiblings()[0]
        //paragraph = uncommented[uncommented.length-2];
        //console.log(paragraph);
        uncommented.className = "SaveTheText invisible";
   }
}

function Normal() {
	list = $$("pre");
	for (i=0 ; i<list.length ; i++){
	    list[i].className = "invisible";
	}    
}


function applyMode (mode) {
//mode = $("modeMenu").value;
    if (mode == "Percentage") { Percentage(); }
    if (mode == "SaveTheText") { SaveTheText(); }
    if (mode == "Normal") { Normal(); }
    else { changeCSS(mode); }
}



