function ajouter_page()
{
    var doc = document.getElementById('pages');
    var n = parseInt(document.getElementById('nb_pages').value) + 1;

    var head = document.createElement('div');
    head.setAttribute('id', 'head_p'+n);
    head.className = 'page_header';

    var num = document.createElement('span');
    num.className = 'numPage';
    num.appendChild(document.createTextNode(n));

    var lien_swap = document.createElement('a');
    lien_swap.onclick = function() { return swap(n); };
    lien_swap.setAttribute('href', '#');
    lien_swap.appendChild(document.createTextNode('Afficher/Cacher'));

    var lien_suppr = document.createElement('a');
    lien_suppr.onclick = function() { return supprimer(n); };
    lien_suppr.setAttribute('href', '#');
    lien_suppr.appendChild(document.createTextNode('Supprimer'));

    head.appendChild(num);
    head.appendChild(lien_swap);
    head.appendChild(document.createTextNode(' | '));
    head.appendChild(lien_suppr);

    var texte = document.createElement('textarea');
    texte.setAttribute('rows', '6');
    texte.setAttribute('cols', '60');
    texte.setAttribute('name', 'texte_p'+n);

    var core = document.createElement('div');
    core.setAttribute('id', 'texte_p'+n);
    core.className = 'page_texte';
    core.appendChild(texte);

    doc.appendChild(head);
    doc.appendChild(core);

    document.getElementById('nb_pages').value = n;
    swap(n);

    return false;
}

function supprimer(i)
{
    var doc = document.getElementById('pages');
    doc.removeChild(document.getElementById('head_p'+i));
    doc.removeChild(document.getElementById('texte_p'+i));

    return false;
}

function swap(i)
{
    if(document.getElementById('texte_p'+i).style.display == 'block')
    {
        document.getElementById('texte_p'+i).style.display = 'none';
    }
    else
    {
        document.getElementById('texte_p'+i).style.display = 'block';
    }

    return false;
}

function swapAide()
{
    if(document.getElementById('aide').style.display == 'block')
    {
        document.getElementById('aide').style.display = 'none';
    }
    else
    {
        document.getElementById('aide').style.display = 'block';
    }

    return false;
}