Utilisateur:Dr Brains/SpecialPagePreview.js

Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/*  
{{Utilisateur:Dr Brains/onglets}}

<big>'''[[:fr:Utilisateur:Dr Brains/SpecialPagePreview.js|SpecialPagePreview.js]]'''</big> est un [[:fr:Projet:JavaScript|code javascript]] permettant de créer facilement une prévisualisation de n'importe quelle page du wiki local

Source d'origine : [[:en:User:Bradv]] [http://en.wikipedia.org/w/index.php?title=User:Bradv/NewPagePreview.js&oldid=259366737 ext]

== Installation ==

Pour installer ce script, ajoutez a votre [[Special:Ma Page/monobook.js|monobook.js]] ou autre suivant l'habillage sélectionné dans les [[Spécial:préférences|préférences]]:

<syntaxhighlight lang=javascript>
importScript('Utilisateur:Dr Brains/SpecialPagePreview.js');
</syntaxhighlight>

== Fonctions == 

Ce script ajoute un lien de prévisualisation rapide à côté de chaque lien pertinent<ref>C'est à dire liens internes et non-liés à une image</ref> :
* Dans l'historique
* Dans les tables de diff
* Dans les pages spéciales
* Dans l'espace encyclopédique et les autres espaces de noms
** Toute la page
** Ou de façon sélective :
*** Les infoboxes
*** Les modèles {{m|Article principal}}, {{m|Article détaillé}}, {{m|Article connexe}} et affiliés 
*** Les boîtes déroulantes et palettes de navigation
*** Les images<ref>L'icône des images "thumb" est remplacé. L'image doit se trouver physiquement sur le serveur pour être visible, ça ne marche donc pas pour les images de Commons...</ref>
*** Les catégories
*** Les liens de section {{bleu|<nowiki>[modifier]</nowiki>}}
 
* Il modifie également l'historique en changeant le bouton "Comparer les version sélectionnées" par un lien affichant une pop-up du diff concerné et ajoute un lien "suivi" pour voir dans une pop-up les changements depuis sa dernière édition.
* Dans les pages spéciales [[Special:Watchlist]], [[Special:Recentchanges]] et [[Special:Recentchangeslinked]], ajout d'un lien "suivi" pour voir dans une pop-up les changements depuis sa dernière édition et d'un lien "suivre" ou "stop" pour ajouter ou retirer la page de sa liste de suivi sans changer de page.
* En mode édition<ref>Il ne peut y avoir qu'une seule édition à la fois, que ce soit dans une pop-up ou dans la fenêtre principale</ref>, la liste des modèles et catégories utilisées est affublée d'un lien de prévisualisation pour chaque entrée et les boutons "Prévisualiser" et "Modification en cours" sont doublées par des boutons lançant la prévisualisation demandée<ref>Pour une raison inconnue, le rendu de la prévisualisation ne marche pas. J'espère régler ce bug un de ces jours.</ref>. C'est le cas également du bouton "Publier" lorsque la modification a lieu dans une pop-up.
* Ces fonctions sont largement paramétrables à travers un menu d'options.
 
A noter que la totalité de ces fonctions sont appliqués à la fenêtre nouvellement ouverte, en plus de la gestion du masquage/démasquage du sommaire, des {{m|Boîte déroulante}} et des {{m|Méta palette de navigation}}, ainsi que l'affichage correct du modèle {{m|Icône de titre}}

Ce script est censé fonctionner quel que soit le skin actif et a été testé avec IE 8.0, Firefox 3.5, Opera 10 et Chrome 3.5 
<references/>

== Bugs connus ==

* Le rendu de prévisualisation ne fonctionne pas.
* Les pages avec une apostrophe dans le titre posent des problèmes malgré l'utilisation de la fonction <tt>encodeURIComponent()</tt>.

== Axes de développement == 

* Faire fonctionner dans une pop-up en mode édition la fonction "insertTags()" des caractères spéciaux.
* Rendre le comportement des modèles avec javascript non encore couverts ( {{m|images}}, géolocalisation, etc... ).

== Illustrations ==
 
{{Boîte déroulante début|couleurFondT=#aaaaaa|titre=demo}}
<gallery perrow="2" widths="400" heights="280">
Fichier:Demo SpecialPagePreview.png|Aperçu des liens ajoutés dans les modifications récentes
Fichier:Demo SpecialPagePreviewOptions1.png|Aperçu du menu d'options
Fichier:Demo SpecialPagePreview0.png|Il suffit de cliquer sur un des nouveaux liens crées...
Fichier:Demo SpecialPagePreview1.png|... et la page demandée s'affiche.
</gallery>
{{Boîte déroulante fin}}
 
== CODE SOURCE ==
{{Projet:JavaScript/Script}}
{{Boîte déroulante début|titre=Code source}}
<!--
*/
// --><syntaxhighlight lang="javascript"> 
// ###############################################################################################################################################################################
/* 
Ajax Preview 
Source d'origine : [[:en:User:Bradv]] [http://en.wikipedia.org/w/index.php?title=User:Bradv/NewPagePreview.js&oldid=259366737 ext]
Adaptation : [[:fr:User:Dr Brains]]
[[Catégorie:MediaWiki:Fonction Monobook en JavaScript]] <nowiki>
// #############################################################################################################################################################################
*/


// ########################################################################################### FONCTIONS GENERIQUES

// * Test Navigateur *

    var agt=navigator.userAgent.toLowerCase();
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

    if(is_ie){
        LargeurEcran = parseInt(screen.width);
        HauteurEcran = parseInt(screen.height);
    }else{
        LargeurEcran = parseInt(window.innerWidth);
        HauteurEcran = parseInt(window.innerHeight);
    }

// * Mise à jour du cookie *
 
function setPreviewCookie (cookieName, cookieValue, expires, path) {
        document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; EXPIRES=' + expires.toGMTString() : '') + "; PATH=/" ; 
}

// * Interrogation du cookie *
 
function getPreviewCookie(cookieName) {
        var cookieValue = null;
        var posName = document.cookie.indexOf(escape(cookieName) + '=' );
        if (posName != -1) {
                        var posValue = posName + (escape(cookieName) + '=' ).length;
                        var endPos = document.cookie.indexOf(';', posValue) ;
                if (endPos != -1) {
                        cookieValue = unescape(document.cookie.substring(posValue, endPos));
                } else {
                        cookieValue = unescape(document.cookie.substring(posValue));
                }
        }
        return decodeURIComponent(cookieValue);
}

// * Suppression d'un élément *

function supprimerAncienElement(OldElement){
          if(!OldElement)return;
          if(is_ie){
                    OldElement.removeNode(true);
          }else {
                    if(OldElement.parentNode){document=OldElement.parentNode.removeChild(OldElement);}
          }
}

// * Recherche d'un élement dont on connait l'Id (non unique, donc sans utiliser getElementById() ) *

function getElementWithId( elementParentNode , elementTagName , elementId ){
      if(!elementParentNode) elementParentNode = document;
      var TheElement = false;
      var Elements = elementParentNode.getElementsByTagName(elementTagName);
      var elementcount = 0;
      while(elementcount<Elements.length){
            var Id = Elements[elementcount].id;
            if(Id){
                  if(Id.indexOf(elementId)!=-1){
                        TheElement = Elements[elementcount];
                  }
            }
            elementcount++
      }
      return TheElement;
}

// ##################################################################################################################################################################
//////////////////////////////////////////////////////////////////////////////// PARTIE PERSONNALISABLE /////////////////////////////////////////////////////////////

if(typeof(showPreview_TextOptions) == 'undefined') 
window.showPreview_TextOptions  = "Textes" 


// ------------------------------------------------------------- Liens de prévisualisation //

if(typeof(showPreview_previewTitle) == 'undefined') 
window.showPreview_previewTitle  = "Cliquer pour prévisualiser";
if(typeof(showPreview_LinkContainer_Before_Bis) == 'undefined') 
window.showPreview_LinkContainer_Before_Bis  = '';
if(typeof(showPreview_LinkContainer_After_Bis) == 'undefined') 
window.showPreview_LinkContainer_After_Bis  = '';
if(typeof(showPreview_Seperator) == 'undefined') 
window.showPreview_Seperator  = ' ';

// ------------------------------------------------------------- Fenêtre de prévisualisation //



if(typeof(showPreview_LoadingText_1) == 'undefined') 
window.showPreview_LoadingText_1  = "Requête";
if(typeof(showPreview_LoadingText_2) == 'undefined') 
window.showPreview_LoadingText_2  = "Réception";
if(typeof(showPreview_LoadingText_3) == 'undefined') 
window.showPreview_LoadingText_3  = "Affichage";
if(typeof(showPreview_LoadingText_4) == 'undefined') 
window.showPreview_LoadingText_4  = "OK !";
if(typeof(showPreview_RCid) == 'undefined') 
window.showPreview_RCid = " - Id RC : ";
if(typeof(showPreview_Actu) == 'undefined') 
window.showPreview_Actu  = " - Actuelle : ";
if(typeof(showPreview_Diff) == 'undefined') 
window.showPreview_Diff = " - Diff : ";
if(typeof(showPreview_Revision) == 'undefined') 
window.showPreview_Revision = " - Révision : ";

// -------------------------- Boutons //

if(typeof(showPreview_CloseButton) == 'undefined') 
window.showPreview_CloseButton = " Cliquer pour fermer la fenêtre";
if(typeof(showPreview_ResizeButton) == 'undefined') 
window.showPreview_ResizeButton = " Cliquer pour redimensionner la fenêtre";
if(typeof(showPreview_MagnifyButton) == 'undefined') 
window.showPreview_MagnifyButton = " Cliquer pour agrandir la fenêtre";
if(typeof(showPreview_CollapseButton) == 'undefined') 
window.showPreview_CollapseButton = " Cliquer pour réduire la fenêtre";

// -------------------------- Liens //

if(typeof(showPreview_LinkContainer_Before) == 'undefined') 
window.showPreview_LinkContainer_Before = '[';
if(typeof(showPreview_LinkContainer_After) == 'undefined') 
window.showPreview_LinkContainer_After  = ']';
if(typeof(showPreview_SubjectText) == 'undefined') 
window.showPreview_SubjectText  = "page principale";
if(typeof(showPreview_TalkText) == 'undefined') 
window.showPreview_TalkText = "discuter";
if(typeof(showPreview_ContribText) == 'undefined') 
window.showPreview_ContribText = "contributions";
if(typeof(showPreview_EditText) == 'undefined') 
window.showPreview_EditText  = "modifier";
if(typeof(showPreview_SourceText) == 'undefined') 
window.showPreview_SourceText  = "voir la source";
if(typeof(showPreview_HistText) == 'undefined') 
window.showPreview_HistText  = "historique";
if(typeof(showPreview_MoveText) == 'undefined')
 window.showPreview_MoveText   = "renommer";
if(typeof(showPreview_DeleteText) == 'undefined') 
window.showPreview_DeleteText  = "supprimer";
if(typeof(showPreview_UndeleteText) == 'undefined') 
window.showPreview_UndeleteText = "restaurer";
if(typeof(showPreview_ProtectText) == 'undefined') 
window.showPreview_ProtectText  = "protéger";
if(typeof(showPreview_Unprotext) == 'undefined') 
window.showPreview_Unprotext  = "déprotéger";
if(typeof(showPreview_WatchText) == 'undefined') 
window.showPreview_WatchText  = "suivre";
if(typeof(showPreview_UnwatchText) == 'undefined') 
window.showPreview_UnwatchText  = "stop";

// ------------------------------------------------------------- Liens Activation et options //

if(typeof(showPreview_On) == 'undefined') 
window.showPreview_On  = "Prévisualisation" 
if(typeof(showPreview_TitleOn) == 'undefined') 
window.showPreview_TitleOn = "Cliquer pour activer la prévisualisation" 
if(typeof(showPreview_Off) == 'undefined') 
window.showPreview_Off  = "Désactiver"
if(typeof(showPreview_TitleOff) == 'undefined') 
window.showPreview_TitleOff  = "Cliquer pour désactiver la prévisualisation"
if(typeof(showPreview_Options) == 'undefined') 
window.showPreview_Options = "Options" 
if(typeof(showPreview_TitleOptions) == 'undefined') 
window.showPreview_TitleOptions  = "Cliquer pour modifier les options"
if(typeof(showPreview_OptionsOff) == 'undefined') 
window.showPreview_OptionsOff = "Masquer les options" 
if(typeof(showPreview_TitleOptionsOff) == 'undefined') 
window.showPreview_TitleOptionsOff = "Cliquer pour masquer les options"  

// ------------------------------------------------------------- Boutons Menu Options //

if(typeof(showPreview_OptionsSave) == 'undefined') 
window.showPreview_OptionsSave = "Enregistrer les préférences";
if(typeof(showPreview_OptionsCancel) == 'undefined') 
window.showPreview_OptionsCancel = "Annuler";
if(typeof(showPreview_OptionsRaz) == 'undefined') 
window.showPreview_OptionsRaz = "Rétablir les valeurs par défaut";
if(typeof(showPreview_OptionsTitleSave) == 'undefined') 
window.showPreview_OptionsTitleSave = "Cliquer pour mettre à jour vos préférences";
if(typeof(showPreview_OptionsTitleCancel) == 'undefined') 
window.showPreview_OptionsTitleCancel = "Cliquer pour quitter le menu options";
if(typeof(showPreview_OptionsitleRaz) == 'undefined') 
window.showPreview_OptionsTitleRaz = "Cliquer pour rétablir les valeurs par défaut";

// -------------------------------------------------------------Accesskey Boutons Mode édition //

if (typeof ajaxSaveKey != 'string') ajaxSaveKey  = 's';
if (typeof ajaxPreviewKey != 'string') ajaxPreviewKey = 'p';
if (typeof ajaxDiffKey != 'string') ajaxDiffKey  = 'v';

// ------------------------------------------------------------- Onglet "suivi" //

var TextSince = "suivi"
var TitleSince = "Voir les changements depuis votre dernière édition";
var HistoryWait = "Analyse de l'historique... veuillez patienter...";
var TitleMore = "Vous n'avez pas édité cette page (récemment).  Remonter plus loin dans l'historique ? ";
var TextAgain = "Relancer l\'analyse";
var TitleAgain = "Cliquer pour relancer l\'analyse";
var TextLimits = "Profondeur de recherche : ";

// ------------------------------------------------------------------------------------------------------------------------ MENU OPTIONS //

var Option = new Array();
var DefaultOption = new Array();

// ------------------------------------------------------------------------------------------------------------------------ Styles Liens //

if(typeof(showPreview_StylesLinksOptions) == 'undefined') 
window.showPreview_StylesLinksOptions  = "Styles liens"

if(typeof(showPreview_StylesLinksOptions_Button) == 'undefined') 
window.showPreview_StylesLinksOptions_Button  = "Styles CSS : " 
Option[0] = "Style_Preview_Button";DefaultOption[0] = "cursor:pointer;font-size:1em;color:#207050 !important;";
var Style_Preview_Button =  DefaultOption[0];

if(typeof(showPreview_StylesLinksOptions_Button_Hover) == 'undefined') 
window.showPreview_StylesLinksOptions_Button_Hover  = "Styles CSS au survol : "
Option[1] = "Style_Preview_Button_Hover";DefaultOption[1] = "cursor:pointer;font-size:1em;color:#002BB8 !important;text-decoration:underline;";
var Style_Preview_Button_Hover =  DefaultOption[1];

if(typeof(showPreview_StylesLinksOptions_Image_Position) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_Position  = "Position du lien ou de l\'image : " 
if(typeof(showPreview_StylesLinksOptions_Image_PositionLeft) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_PositionLeft = "Gauche";
if(typeof(showPreview_StylesLinksOptions_Image_PositionRight) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_PositionRight = "Droite";
Option[2] = "Style_Preview_Image_PositionLeft";DefaultOption[2] = "true";
var Style_Preview_Image_PositionLeft =  DefaultOption[2];

if(typeof(showPreview_StylesLinksOptions_Image_Height) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_Height  = "Hauteur de l\'image : " 
Option[3] = "Style_Preview_Image_Height";DefaultOption[3] = "0.8em";
var Style_Preview_Image_Height =  DefaultOption[3];

if(typeof(showPreview_StylesLinksOptions_Image_Width) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_Width  = "Largeur de l\'image : " 
Option[4] = "Style_Preview_Image_Width";DefaultOption[4] = "0.8em";
var Style_Preview_Image_Width =  DefaultOption[4];

if(typeof(showPreview_StylesLinksOptions_Image_Target) == 'undefined') 
window.showPreview_StylesLinksOptions_Image_Target  = "Cible de l\'image : "
Option[5] = "Style_Preview_Image_Target";DefaultOption[5] = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/61/Searchtool.svg/15px-Searchtool.svg.png";
var Style_Preview_Image_Target =  DefaultOption[5];

if(typeof(showPreview_StylesLinksOptions_Char) == 'undefined') 
window.showPreview_StylesLinksOptions_Char  = "Substitut textuel : " 
Option[33] = "showPreview_previewText";DefaultOption[33] = '⊕';
var showPreview_previewText = DefaultOption[33];

// ------------------------------------------------------------------------------------------------------------------------ Styles Pop-up //

if(typeof(showPreview_StylesPopOptions) == 'undefined') 
window.showPreview_StylesPopOptions = "Styles pop-up" 

if(typeof(showPreview_StylesPopOptions_Content) == 'undefined') 
window.showPreview_StylesPopOptions_Content  = "Styles du contenu de la pop-up : " 
Option[7] = "Style_Preview_Content";DefaultOption[7] = "margin-top:0.3em;padding-right:1em;border-bottom:1px solid #cccccc;font-size:1em ;line-height:0.9em;";
var Style_Preview_Content =  DefaultOption[7];

if(typeof(showPreview_StylesPopOptions_LoadingSpan) == 'undefined') 
window.showPreview_StylesPopOptions_LoadingSpan  = "Styles de la barre d\'avancement : "
Option[6] = "Style_Preview_LoadingSpan";DefaultOption[6] = "font-size:0.8em;";
var Style_Preview_LoadingSpan =  DefaultOption[6];

if(typeof(showPreview_StylesPopOptions_TopBar) == 'undefined') 
window.showPreview_StylesPopOptions_TopBar = "Styles de la barre de menu : " 
Option[8] = "Style_Preview_TopBar";DefaultOption[8] = "border-bottom:2px solid #aaaaaa;padding-bottom:0.3em;margin-bottom:0.1em;cursor:move;";
var Style_Preview_TopBar =  DefaultOption[8];

if(typeof(showPreview_StylesPopOptions_H1) == 'undefined') 
window.showPreview_StylesPopOptions_H1  = "Styles du titre de la pop-up : " 
Option[9] = "Style_Preview_H1";DefaultOption[9] = "border-bottom:font-size:1.2em;font-weight:bold;cursor:pointer;";
var Style_Preview_H1 =  DefaultOption[9];

Option[10] = "Style_Preview_TopBar";DefaultOption[10] = "";
Style_Preview_OtherLinks =  DefaultOption[10];

if(typeof(showPreview_StylesPopOptions_OtherpageLink) == 'undefined') 
window.showPreview_StylesPopOptions_OtherpageLink  = "Styles du lien vers la page associée : " 
Option[11] = "Style_Preview_OtherpageLink";DefaultOption[11] = "font-size:1em;cursor:pointer;";
var Style_Preview_OtherpageLink =  DefaultOption[11];

if(typeof(showPreview_StylesPopOptions_UserContribLink) == 'undefined') 
window.showPreview_StylesPopOptions_UserContribLink= "Styles du lien vers la page des contributions : " 
Option[47] = "Style_Preview_UserContribLink";DefaultOption[47] = "font-size:1em;cursor:pointer;";
var Style_Preview_UserContribLink = DefaultOption[47] ;

if(typeof(showPreview_StylesPopOptions_EditLink) == 'undefined') 
window.showPreview_StylesPopOptions_EditLink = "Styles du lien modifier : " 
Option[12] = "Style_Preview_EditLink";DefaultOption[12] = "font-size:1em;cursor:pointer;";
var Style_Preview_EditLink =  DefaultOption[12];

if(typeof(showPreview_StylesPopOptions_HistoryLink) == 'undefined') 
window.showPreview_StylesPopOptions_HistoryLink = "Styles du lien historique : " 
Option[13] = "Style_Preview_HistoryLink";DefaultOption[13] = "font-size:1em;cursor:pointer;";
var Style_Preview_HistoryLink =  DefaultOption[13];

if(typeof(showPreview_StylesPopOptions_MoveLink) == 'undefined') 
window.showPreview_StylesPopOptions_MoveLink = "Styles du lien renommer : "
Option[14] = "Style_Preview_MoveLink";DefaultOption[14] = "font-size:1em;cursor:pointer;";
var Style_Preview_MoveLink =  DefaultOption[14];

if(typeof(showPreview_StylesPopOptions_DeleteLink) == 'undefined') 
window.showPreview_StylesPopOptions_DeleteLink  = "Styles du lien supprimer : " 
Option[15] = "Style_Preview_DeleteLink";DefaultOption[15] = "font-size:1em;cursor:pointer;";
var Style_Preview_DeleteLink =  DefaultOption[15];

if(typeof(showPreview_StylesPopOptions_ProtectLink) == 'undefined') 
window.showPreview_StylesPopOptions_ProtectLink = "Styles du lien protéger : " 
Option[16] = "Style_Preview_ProtectLink";DefaultOption[16] = "font-size:1em;cursor:pointer;";
var Style_Preview_ProtectLink = DefaultOption[16];

if(typeof(showPreview_StylesPopOptions_WatchLink) == 'undefined') 
window.showPreview_StylesPopOptions_WatchLink  = "Styles du lien suivre : "
Option[17] = "Style_Preview_WatchLink";DefaultOption[17] = "font-size:1em;cursor:pointer;";
var Style_Preview_WatchLink = DefaultOption[17];

// ------------------------------------------------------------------------------------------------------------------------ Options //

if(typeof(showPreview_ParamsOptions) == 'undefined') window.showPreview_ParamsOptions = "Options" 

if(typeof(showPreview_ParamsOptionsGlobal) == 'undefined') window.showPreview_ParamsOptionsGlobal = "Activations globales";

if(typeof(showPreview_PreviewButtons) == 'undefined') 
window.showPreview_PreviewButtons = "Utiliser une image"
Option[19] = "PreviewButtons";DefaultOption[19] = "true";
var PreviewButtons = DefaultOption[19] ;

if(typeof(showPreview_AddPreviewLinks) == 'undefined') 
window.showPreview_AddPreviewLinks = "Dupliquer les liens"
Option[20] = "AddPreviewLinks";DefaultOption[20] = "true";
var AddPreviewLinks = DefaultOption[20] ;

if(typeof(showPreview_PreviewOnDiff) == 'undefined') 
window.showPreview_PreviewOnDiff = "Activer dans les diff"
Option[18] = "PreviewOnDiff";DefaultOption[18] = "true";
var PreviewOnDiff = DefaultOption[18] ;


if(typeof(showPreview_PreviewOnHistory) == 'undefined') 
window.showPreview_PreviewOnHistory = "Activer dans l\'historique"
Option[21] = "PreviewOnHistory";DefaultOption[21] = "true";
var PreviewOnHistory = DefaultOption[21] ;

if(typeof(showPreview_PreviewOnSpecialPages) == 'undefined') 
window.showPreview_PreviewOnSpecialPages  = "Activer dans les pages spéciales"
Option[22] = "PreviewOnSpecialPages";DefaultOption[22] = "true";
var PreviewOnSpecialPages = DefaultOption[22] ;

if(typeof(showPreview_PreviewOnArticlePages) == 'undefined') 
window.showPreview_PreviewOnArticlePages  = "Activer dans l\'espace encyclopédique"
Option[23] = "PreviewOnArticlePages";DefaultOption[23] = "false";
var PreviewOnArticlePages = DefaultOption[23] ;

if(typeof(showPreview_PreviewOnOtherPages) == 'undefined') 
window.showPreview_PreviewOnOtherPages  = "Activer dans les autres espaces de noms"
Option[24] = "PreviewOnOtherPages";DefaultOption[24] = "false";
var PreviewOnOtherPages = DefaultOption[24] ;

if(typeof(showPreview_PreviewOnEdit) == 'undefined') 
window.showPreview_PreviewOnEdit= "Activer en mode édition"
Option[51] = "PreviewOnEdit";DefaultOption[51] = "false";
PreviewOnEdit = DefaultOption[51] ;

if(typeof(showPreview_PreviewOnSidebar) == 'undefined') 
window.showPreview_PreviewOnSidebar= "Activer dans la barre de navigation"
Option[34] = "PreviewOnSidebar";DefaultOption[34] = "true";
var PreviewOnSidebar= DefaultOption[34] ;

if(typeof(showPreview_PreviewOnPersonal) == 'undefined') 
window.showPreview_PreviewOnPersonal= "Activer dans les liens personels"
Option[36] = "PreviewOnPersonal";DefaultOption[36] = "true";
var PreviewOnPersonal= DefaultOption[36] ;

if(typeof(showPreview_PreviewOnCactions) == 'undefined') 
window.showPreview_PreviewOnCactions= "Activer dans les onglets"
Option[52] = "PreviewOnCactions";DefaultOption[52] = "true";
PreviewOnCactions = DefaultOption[52] ;

if(typeof(showPreview_ParamsOptionsSelect) == 'undefined') window.showPreview_ParamsOptionsSelect = "Activations sélectives";

if(typeof(showPreview_PreviewOnCategories) == 'undefined') 
window.showPreview_PreviewOnCategories= "Activer dans les catégories"
Option[35] = "PreviewOnCategories";DefaultOption[35] = "false";
var PreviewOnCategories= DefaultOption[35] ;

if(typeof(showPreview_PreviewOnOnglet) == 'undefined') 
window.showPreview_PreviewOnOnglet= "Activer dans les modèles à onglets"
Option[56] = "PreviewOnOnglet";DefaultOption[56] = "true";
var PreviewOnOnglet = DefaultOption[56] ; 

if(typeof(showPreview_PreviewOnArticlePrincipal) == 'undefined') 
window.showPreview_PreviewOnArticlePrincipal  = "Activer dans les modèles : Article principal, Article détaillé, Article connexe"
Option[41] = "PreviewOnArticlePrincipal";DefaultOption[41] = "true";
PreviewOnArticlePrincipal= DefaultOption[41] ;

if(typeof(showPreview_PreviewOnInfobox) == 'undefined') 
window.showPreview_PreviewOnInfobox= "Activer dans les modèles : Infobox"
Option[42] = "PreviewOnInfobox";DefaultOption[42] = "true";
PreviewOnInfobox= DefaultOption[42] ;

if(typeof(showPreview_PreviewOnCollapsibleBoxes) == 'undefined') 
window.showPreview_PreviewOnCollapsibleBoxes= "Activer dans les modèles : Boîte déroulante et Palette de navigation"
Option[43] = "PreviewOnCollapsibleBoxes";DefaultOption[43] = "true";
PreviewOnCollapsibleBoxes = DefaultOption[43] ;

if(typeof(showPreview_PreviewOnImage) == 'undefined') 
window.showPreview_PreviewOnImage= "Activer sur les images"
Option[50] = "PreviewOnImage";DefaultOption[50] = "true";
PreviewOnImage = DefaultOption[50] ;

if(typeof(showPreview_PreviewOnEditSection) == 'undefined') 
window.showPreview_PreviewOnEditSection= "Activer sur les liens de section [modifier]"
Option[53] = "PreviewOnEditSection";DefaultOption[53] = "false";
PreviewOnEditSection = DefaultOption[53] ;

if(typeof(showPreview_PreviewSearchButton) == 'undefined') 
window.showPreview_PreviewSearchButton= "Activer le bouton \"prévisualiser\" dans la zone de recherche";
Option[57] = "PreviewSearchButton";DefaultOption[57] = "true";
PreviewSearchButton = DefaultOption[57] ; 

if(typeof(showPreview_previewLastDiff) == 'undefined') 
window.showPreview_previewLastDiff= "Activer l\'onglet \"suivi\"";
Option[54] = "previewLastDiff";DefaultOption[54] = "true";
previewLastDiff = DefaultOption[54] ;

if(typeof(showPreview_defaultdiffs) == 'undefined') 
window.showPreview_defaultdiffs= "Profondeur de recherche : ";
Option[55] = "defaultdiffs";DefaultOption[55] = "200";
defaultdiffs = DefaultOption[55] ; 

if(typeof(showPreview_PreviewMenuPosition) == 'undefined') 
window.showPreview_PreviewMenuPosition = "Position des liens de l\'interface";

if(typeof(showPreview_PreviewMenuPosition_SiteSub) == 'undefined') 
window.showPreview_PreviewMenuPosition_SiteSub  = "Sous le titre"
Option[37] = "PreviewMenuPosition_SiteSub";DefaultOption[37] = "false";
var PreviewMenuPosition_SiteSub= DefaultOption[37] ;

if(typeof(showPreview_PreviewMenuPosition_Sidebar) == 'undefined') 
window.showPreview_PreviewMenuPosition_Sidebar= "Dans la boîte à outils"
Option[38] = "PreviewMenuPosition_Sidebar";DefaultOption[38] = "true";
var PreviewMenuPosition_Sidebar= DefaultOption[38] ;

if(typeof(showPreview_PreviewMenuPosition_Personal) == 'undefined') 
window.showPreview_PreviewMenuPosition_Personal= "Avec les liens personnels"
Option[39] = "PreviewMenuPosition_Personal";DefaultOption[39] ="false";
var PreviewMenuPosition_Personal= DefaultOption[39] ;

if(typeof(showPreview_PreviewMenuPosition_Cactions) == 'undefined') 
window.showPreview_PreviewMenuPosition_Cactions= "Onglets"
Option[40] = "PreviewMenuPosition_Cactions";DefaultOption[40] = "false";
var PreviewMenuPosition_Cactions= DefaultOption[40] ;

if(typeof(showPreview_PreviewMenuPosition_SkinManager) == 'undefined') 
window.showPreview_PreviewMenuPosition_SkinManager= "SkinManager"
Option[48] = "PreviewMenuPosition_SkinManager";DefaultOption[48] = "false";
PreviewMenuPosition_SkinManager = DefaultOption[48] ;

// ------------------------------------------------------------------------------------------------------------------------ Paramètres //

if(typeof(showPreview_SettingsOptions) == 'undefined') 
window.showPreview_SettingsOptions  = "Paramètres"; 

if(typeof(showPreview_ParamOptions_AdresseSite) == 'undefined') 
window.showPreview_ParamOptions_AdresseSite  = "Adresse locale par défaut : "; 
Option[25] = "AdresseSite";DefaultOption[25] = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=';
var AdresseSite = DefaultOption[25] ;

if(typeof(showPreview_ParamOptions_MaxPreviewNumber) == 'undefined') 
window.showPreview_ParamOptions_MaxPreviewNumber  = "Nombre maximum de fenêtres de prévisualisation : "; 
Option[26] = "MaxPreviewNumber";DefaultOption[26] = '10';
var MaxPreviewNumber = DefaultOption[26] ;

if(typeof(showPreview_ParamOptions_InitialDecalTop) == 'undefined') 
window.showPreview_ParamOptions_InitialDecalTop  = "Décalage d\'origine en hauteur : ";
Option[27] = "InitialDecalTop";DefaultOption[27] = '150';
var InitialDecalTop = DefaultOption[27] ;

if(typeof(showPreview_ParamOptions_InitialDecalLeft) == 'undefined') 
window.showPreview_ParamOptions_InitialDecalLeft  = "Décalage d\'origine en largeur : ";
Option[28] = "InitialDecalLeft";DefaultOption[28] ='100';
var InitialDecalLeft = DefaultOption[28];

if(typeof(showPreview_ParamOptions_DecalageTop) == 'undefined') 
window.showPreview_ParamOptions_DecalageTop  = "Décalage en hauteur entre deux fenêtres de prévisualisation : "; 
Option[29] = "DecalageTop";DefaultOption[29] = '40';
var DecalageTop = DefaultOption[29] ;

if(typeof(showPreview_ParamOptions_DecalageLeft) == 'undefined') 
window.showPreview_ParamOptions_DecalageLeft  = "Décalage en largeur entre deux fenêtres de prévisualisation : "; 
Option[30] = "DecalageLeft";DefaultOption[30] = '50';
var DecalageLeft = DefaultOption[30] ;

if(typeof(showPreview_ParamOptions_MaxDecalTop) == 'undefined') 
window.showPreview_ParamOptions_MaxDecalTop  = "Décalage maximum en hauteur : "; 
Option[31] = "MaxDecalTop";DefaultOption[31] = '300';
var MaxDecalTop = DefaultOption[31] ;

if(typeof(showPreview_ParamOptions_MaxDecalLeft) == 'undefined') 
window.showPreview_ParamOptions_MaxDecalLeft  = "Décalage maximum en largeur : ";
Option[32] = "MaxDecalLeft";DefaultOption[32] = '320';
var MaxDecalLeft = DefaultOption[32];

if(typeof(showPreview_ParamOptions_PreviewWindowWidth) == 'undefined') 
window.showPreview_ParamOptions_PreviewWindowWidth= "Largeur de la fenêtre de prévisualisation : ";
Option[44]="PreviewWindowWidth"; DefaultOption[44] = '70em';
PreviewWindowWidth = DefaultOption[44] ;

if(typeof(showPreview_ParamOptions_PreviewWindowHeight) == 'undefined') 
window.showPreview_ParamOptions_PreviewWindowHeight= "Hauteur de la fenêtre de prévisualisation : ";
Option[45]="PreviewWindowHeight"; DefaultOption[45] = '45em';
PreviewWindowHeight = DefaultOption[45] ;

if(typeof(showPreview_ParamOptions_Style_Preview_TopBarHeight) == 'undefined') 
window.showPreview_ParamOptions_Style_Preview_TopBarHeight= "Hauteur de la barre de menu : ";
Option[49]="Style_Preview_TopBarHeight"; DefaultOption[49] = '2.5em';
Style_Preview_TopBarHeight = DefaultOption[49] ;


//////////////////////////////////////////////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE //////////////////////////////////////////////////////////////
// #############################################################################################################################################################################

for(a=0;a<Option.length;a++){
    var CookiePreviewOption = getPreviewCookie(Option[a]);
    if ((CookiePreviewOption != "") && (CookiePreviewOption != null) && (CookiePreviewOption != "null")){
        DefaultOption[a] = CookiePreviewOption ;
    }
}

Style_Preview_Button =  DefaultOption[0];
Style_Preview_Button_Hover =  DefaultOption[1];
Style_Preview_Image_PositionLeft =  DefaultOption[2];
Style_Preview_Image_Height =  DefaultOption[3];
Style_Preview_Image_Width =  DefaultOption[4];
Style_Preview_Image_Target =  DefaultOption[5];
showPreview_previewText = DefaultOption[33];
Style_Preview_Content =  DefaultOption[7];
Style_Preview_LoadingSpan =  DefaultOption[6];
Style_Preview_TopBar =  DefaultOption[8];
Style_Preview_H1 =  DefaultOption[9];
Style_Preview_OtherLinks =  DefaultOption[10];
Style_Preview_OtherpageLink =  DefaultOption[11];
Style_Preview_EditLink =  DefaultOption[12];
Style_Preview_HistoryLink =  DefaultOption[13];
Style_Preview_MoveLink =  DefaultOption[14];
Style_Preview_DeleteLink =  DefaultOption[15];
Style_Preview_ProtectLink = DefaultOption[16];
Style_Preview_WatchLink = DefaultOption[17];
PreviewOnDiff = DefaultOption[18] ;
PreviewButtons = DefaultOption[19] ;
AddPreviewLinks = DefaultOption[20] ;
PreviewOnHistory = DefaultOption[21] ;
PreviewOnSpecialPages = DefaultOption[22] ;
PreviewOnArticlePages = DefaultOption[23] ;
PreviewOnOtherPages = DefaultOption[24] ;
AdresseSite = DefaultOption[25] ;
MaxPreviewNumber = parseFloat(DefaultOption[26]) ;
InitialDecalTop = parseFloat(DefaultOption[27]) ;
InitialDecalLeft = parseFloat(DefaultOption[28]);
DecalageTop = parseFloat(DefaultOption[29]) ;
DecalageLeft = parseFloat(DefaultOption[30]) ;
MaxDecalTop = parseFloat(DefaultOption[31]) ;
MaxDecalLeft = parseFloat(DefaultOption[32]);
showPreview_previewText = DefaultOption[33];
PreviewOnSidebar= DefaultOption[34] ;
PreviewOnCategories= DefaultOption[35] ;
PreviewOnPersonal= DefaultOption[36] ;
PreviewMenuPosition_SiteSub = DefaultOption[37];
PreviewMenuPosition_Sidebar= DefaultOption[38] ;
PreviewMenuPosition_Personal= DefaultOption[39] ;
PreviewMenuPosition_Cactions= DefaultOption[40] ;
PreviewOnArticlePrincipal= DefaultOption[41] ;
PreviewOnInfobox= DefaultOption[42] ;
PreviewOnCollapsibleBoxes = DefaultOption[43] ;
PreviewWindowWidth = DefaultOption[44] ;
PreviewWindowHeight = DefaultOption[45] ;
Style_Preview_UserContribLink = DefaultOption[47] ;
PreviewMenuPosition_SkinManager = DefaultOption[48] ;
Style_Preview_TopBarHeight = DefaultOption[49] ;
PreviewOnImage = DefaultOption[50] ;
PreviewOnEdit = DefaultOption[51] ;
PreviewOnCactions = DefaultOption[52] ;
PreviewOnEditSection = DefaultOption[53] ;
previewLastDiff = DefaultOption[54] ; 
defaultdiffs = DefaultOption[55] ; 
PreviewOnOnglet = DefaultOption[56] ; 
PreviewSearchButton = DefaultOption[57] ; 





showPreview_On = '<img src="http://upload.wikimedia.org/wikipedia/commons/1/1e/Crystal_Clear_action_forward.png" height="15px" width="15px" alt=""/> ' + showPreview_On;

showPreview_Off = '<img src="http://upload.wikimedia.org/wikipedia/commons/0/0c/Crystal_Clear_action_exit.png" height="15px" width="15px"  alt=""/> ' + showPreview_Off;

showPreview_Options = '<img src="http://upload.wikimedia.org/wikipedia/commons/d/da/Crystal_Clear_app_utilities_Blue.png" height="15px" width="15px"  alt=""/> ' + showPreview_Options;

showPreview_OptionsOff = '<img src="http://upload.wikimedia.org/wikipedia/commons/c/c1/Crystal_Clear_app_utilities.png" height="15px" width="15px"  alt=""/> ' + showPreview_OptionsOff;





// ** INITIALISATION VARIABLES **

// Initialisation du nombre de fenêtres de prévisualisation
var PreviewNumber = 1;                               

// Initialisation du compte de prévisualisations
var PreviewCount = 1;     

// Initialisation du compte de prévisualisations réduites
var CollapsedCount = 0;

// Initialisation de la prévisualisation en mode edit
if( (mw.config.get('wgAction')=="edit") || (mw.config.get('wgAction')=="submit") ){
     var PreviewEdit = true;
}else{
     var PreviewEdit = false;
}

// Initialisation de la propriété CSS index-z
var DecalZ = 101;                              

// Initialisation du décalage en X et Y
var DecalTop = (0-(InitialDecalTop+DecalageTop));
var DecalLeft = (0-(InitialDecalLeft+DecalageLeft));

// ** INITIALISATION STYLES **

document.write('<style type="text/css">');

// * STYLES PERSONALISABLES *
HauteurFenetre = ( parseFloat(Style_Preview_TopBarHeight.split("em").join("")) - parseFloat(PreviewWindowHeight.split("em").join("")) );

document.write('.Preview_Button {' + Style_Preview_Button + '}' );
document.write('.Preview_Button:hover {' + Style_Preview_Button_Hover + '}' );
document.write('.Preview_MenuLink {' + Style_Preview_Button + '}' );
document.write('.Preview_MenuLink:hover {' + Style_Preview_Button_Hover + '}' );
document.write('.Preview_Content {height: '+HauteurFenetre+'em;' + Style_Preview_Content + '}' );
document.write('.Preview_TopBar {height:'+Style_Preview_TopBarHeight+';' + Style_Preview_TopBar + '}' );
document.write('.Preview_H1 {' + Style_Preview_H1 + '}' );
document.write('.Preview_OtherpageLink {' + Style_Preview_OtherpageLink + '}' );
document.write('.Preview_UserContribLink {' + Style_Preview_UserContribLink + '}' );
document.write('.Preview_EditLink {' + Style_Preview_EditLink + '}' );
document.write('.Preview_HistoryLink {' + Style_Preview_HistoryLink + '}' );
document.write('.Preview_MoveLink {' + Style_Preview_MoveLink + '}' );
document.write('.Preview_DeleteLink {' + Style_Preview_DeleteLink + '}' );
document.write('.Preview_ProtectLink {' + Style_Preview_ProtectLink + '}' );
document.write('.Preview_WatchLink {' + Style_Preview_WatchLink + '}' );
document.write('.Preview_LoadingSpan {' + Style_Preview_LoadingSpan + '}' );

// * STYLES NON PERSONALISABLES *


document.write('#p-cactions { top:0.8em }' );
document.write('#p-cactions li {padding: 0.1em 0.8em  0.3em !important;}' );
document.write('#p-cactions li span {padding: 0 !important;}' );
document.write('#p-cactions li a {padding: 0 !important;}' );
document.write('#p-cactions li.selected a {padding: 0 !important; z-index:0 !important; }' );

document.write('#contentSub {display:inline !important;margin:0 !important;padding:0 !important;}' );
document.write('span.subpages {display:inline;margin:0;padding:0;}' );
document.write('#PreviewUl {display:inline;list-style-image:none;list-style-position:outside;st-style-type:none;margin:0;padding:0;}' );
document.write('#PreviewUl li {display:inline;list-style-image:none;list-style-position:outside;st-style-type:none;margin:0.2em;margin-left:0.5em;margin-right:0.5em;}' );

document.write('span .subpages {display:inline;}');

document.write('</style>');

//############################################################################################################################################################################
//
// ------------------------------------------------------------ FONCTIONS addOnloadHook() ------------------------------------------------------------------------------------
//
//############################################################################################################################################################################

/* ******************************************************************************** ACTIVATION PAR ESPACE DE NOMS ET PAR ACTION ****/


if( (mw.config.get('wgNamespaceNumber')>-1) && ((mw.config.get('wgAction')=="edit")||(mw.config.get('wgAction')=="submit")) ){      // ------------------------------ Mode édition //
    addOnloadHook( makeLinkPreview);
    addOnloadHook( initEditPreview)
    if(PreviewOnEdit=="true"){
        addOnloadHook(initPreview);
    }
}else if(mw.config.get('wgAction') == "history"){               // ------------------------------ Historique //    
    addOnloadHook( makeLinkPreview, 'ul', 'contentSub');  
    addOnloadHook(makePreviewCompareLinks, document, mw.config.get('wgPageName'));
    if( PreviewOnHistory=="true"){
       addOnloadHook(initPreview, 'ul', 'contentSub');
    }  
}else if(document.URL.indexOf("&diff=")!=-1){               // ------------------------------ Diff //    
    addOnloadHook( makeLinkPreview, 'none');  
    if( PreviewOnDiff=="true"){
       addOnloadHook(initDiffPreview);
    }  
}else{
    if(mw.config.get('wgNamespaceNumber') == -1){  // ------------------------------ Pages spéciales //
        if(mw.config.get('wgCanonicalSpecialPageName') == "Recentchanges" ){ 
            addOnloadHook( OptimizedPreviewRC);
            addOnloadHook( makeLinkPreview, 'ul', "recentchangestext");
            if( PreviewOnSpecialPages=="true") addOnloadHook(initPreview, 'ul', 'recentchangestext');

        }else if(mw.config.get('wgCanonicalSpecialPageName') == "Recentchangeslinked" ){
            addOnloadHook( OptimizedPreviewRC); 
            addOnloadHook( makeLinkPreview, 'ul', 'contentSub' );
            if( PreviewOnSpecialPages=="true" ) addOnloadHook(initPreview, 'ul', 'contentSub');
        }else if(
        (mw.config.get('wgCanonicalSpecialPageName') == "Log")
        ||
        (mw.config.get('wgCanonicalSpecialPageName') == "Contributions" )
        ||
        (mw.config.get('wgCanonicalSpecialPageName') == "Categories" )
        ||
        ( (mw.config.get('wgCanonicalSpecialPageName') == "Watchlist") && (document.URL.indexOf("edit")==-1) && (document.URL.indexOf("raw")==-1) )
        ){ 
            addOnloadHook( OptimizedPreviewSuivi)
            addOnloadHook(makeLinkPreview, 'ul');
            if( PreviewOnSpecialPages=="true") addOnloadHook(initPreview, 'ul'); 
        }else if(
        (mw.config.get('wgCanonicalSpecialPageName') == "Listfiles")
        ||
        (mw.config.get('wgCanonicalSpecialPageName') == "Specialpages" )
        ){ 
            addOnloadHook(makeLinkPreview, 'td');
            if( PreviewOnSpecialPages=="true") addOnloadHook(initPreview, 'td');
        }else{ 
            addOnloadHook(makeLinkPreview, 'li');
            if( PreviewOnSpecialPages=="true") addOnloadHook(initPreview,'li');
        }
    }else if((mw.config.get('wgNamespaceNumber')==0)&&(mw.config.get('wgAction')=="view")){ // ------------------------------ Espace Encyclopédique //

        addOnloadHook(makeLinkPreview);
        if(PreviewOnArticlePages=="true") addOnloadHook(initPreview);


    }else if((mw.config.get('wgNamespaceNumber')>0)&&(mw.config.get('wgAction')=="view")){    // ------------------------------ Autres espaces de noms //

        addOnloadHook(makeLinkPreview);
        if(PreviewOnOtherPages=="true") addOnloadHook(initPreview);


    }else{       // --------------------------------------------------------------------------------------------------------- Autres cas //

        addOnloadHook(makeLinkPreview, 'none');
    }
}

// -------------------------------------------------------------------------------------- Sidebar //

if( PreviewOnSidebar=="true" ){
            addOnloadHook( initSidebarPreview);
}

if( PreviewSearchButton=="true" ){
            addOnloadHook(initSearchPreview);
}

// -------------------------------------------------------------------------------------- Onglets //

if( PreviewOnCactions=="true" ){
            addOnloadHook( initCactionsPreview);
}

// -------------------------------------------------------------------------------------- Liens personnels //

if(PreviewOnPersonal=="true"){
            addOnloadHook( initPersonalPreview);
}

/* ******************************************************************************** ACTIVATION SELECTIVE (CONTENU DE LA PAGE) ****/

// -------------------------------------------------------------------------------------- {{m|Onglets}} //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnOnglet=="true") ){
            addOnloadHook( initOngletPreview);
}

// -------------------------------------------------------------------------------------- {{m|Article Principal}} //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnArticlePrincipal=="true") ){
            addOnloadHook( initArticlePrincipalPreview);
}

// -------------------------------------------------------------------------------------- Barre de catégories //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnCategories=="true") ){
            addOnloadHook( initCatPreview);
}

// -------------------------------------------------------------------------------------- Infoboxes //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnInfobox=="true") ){
            addOnloadHook( initInfoboxPreview);
}

// -------------------------------------------------------------------------------------- Boîtes déroulantes & Palettes de navigation //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnCollapsibleBoxes=="true") ){
            addOnloadHook( initCollapsibleBoxesPreview);
}

// -------------------------------------------------------------------------------------- Images //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnImage=="true") ){
            addOnloadHook( initImagePreview);
}

// -------------------------------------------------------------------------------------- Liens de section [modifier] //

if( (  ((mw.config.get('wgNamespaceNumber')==0)&&(PreviewOnArticlePages!="true")) || ((mw.config.get('wgNamespaceNumber')>0) && (PreviewOnOtherPages!="true"))  ) && (PreviewOnEditSection=="true") ){
            addOnloadHook( initSectionEditPreview);
}

// -------------------------------------------------------------------------------------- Onglet "suivi" //

if(previewLastDiff=="true"){
            addOnloadHook(makePreviewLastDiff);
}

//################################################################################################################################################################################
// ------------------------------------------------------------ FONCTIONS GLOBALES -----------------------------------------------------------------------------------------
//################################################################################################################################################################################

// #################################################################################################################### CREATION DU MENU D'OPTIONS

function makeMenuOptionPreview(){
        var PageContent=document.getElementById('content');

        var ContentSubTitle=document.getElementById('siteNotice');
        if(ContentSubTitle){                        
                ContentSubTitle.style.display = 'none';            

                MENUOPTIONS = '<fieldset id="PreviewOptionsField" >';
                MENUOPTIONS += '<legend>'
                +'<input type="button" style="display:inline;" value="' + showPreview_ParamsOptions + '" onclick="displayPreviewParams();"/> '
                +'<input type="button" style="display:inline;" value="' +showPreview_StylesLinksOptions + '" onclick="displayPreviewLinkStyles();"/> '
                +'<input type="button" style="display:inline;" value="' +showPreview_StylesPopOptions + '" onclick="displayPreviewPopStyles();"/> '
                +'<input type="button" style="display:inline;" value="' +showPreview_SettingsOptions + '" onclick="displayPreviewSettings();"/>'
                + '</legend>';

/* ******************** OPTIONS D'ACTIVATION *************************************************************************** */

                MENUOPTIONS +='<fieldset id="PreviewParams">'
                +'<legend>' + showPreview_ParamsOptions + '</legend>';

                MENUOPTIONS +='<fieldset id="ParamsOptionsGlobal"><legend>'+ showPreview_ParamsOptionsGlobal +'</legend>'

                checkBoxOn ='';
                if(PreviewOnSidebar=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnSidebar" type="checkbox" name="PreviewOnSidebar" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnSidebar" >'+ showPreview_PreviewOnSidebar+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnPersonal=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnPersonal" type="checkbox" name="PreviewOnPersonal" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnPersonal" >'+ showPreview_PreviewOnPersonal+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnCactions=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnCactions" type="checkbox" name="PreviewOnCactions" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnCactions" >'+ showPreview_PreviewOnCactions+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnSpecialPages=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnSpecialPages" type="checkbox" name="PreviewOnSpecialPages" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnSpecialPages" >'+ showPreview_PreviewOnSpecialPages +'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnArticlePages=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnArticlePages" type="checkbox" name="PreviewOnArticlePages" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnArticlePages" >'+ showPreview_PreviewOnArticlePages +'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnOtherPages=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnOtherPages" type="checkbox" name="PreviewOnOtherPages" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnOtherPages" >'+ showPreview_PreviewOnOtherPages +'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnHistory=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form >'
                +'<input id="PreviewOnHistory" type="checkbox" name="PreviewOnHistory" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnHistory" >'+ showPreview_PreviewOnHistory +'</label><br/>'
                +'</form>';
                var checkBoxOn ='';
                if(PreviewOnDiff=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnDiff" type="checkbox" name="PreviewOnDiff" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnDiff" >'+ showPreview_PreviewOnDiff+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnEdit=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnEdit" type="checkbox" name="PreviewOnEdit" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnEdit" >'+ showPreview_PreviewOnEdit+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewSearchButton=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewSearchButton" type="checkbox" name="PreviewSearchButton" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewSearchButton" >'+ showPreview_PreviewSearchButton+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(previewLastDiff=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="previewLastDiff" type="checkbox" name="previewLastDiff" value="Activer" '+checkBoxOn+' />'
                +'<label for"previewLastDiff" >'+ showPreview_previewLastDiff+'</label> - '
                +'<label for"defaultdiffs" >'+ showPreview_defaultdiffs+'</label>'
                +'<input id="defaultdiffs" type="text" size="5" value="' +defaultdiffs+ '" /><br/>'
                +'</form>';
                MENUOPTIONS +='</fieldset>';
                MENUOPTIONS +='<fieldset id="ParamsOptionsSelect"><legend>'+ showPreview_ParamsOptionsSelect +'</legend>'
                checkBoxOn ='';
                if(PreviewOnEditSection=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnEditSection" type="checkbox" name="PreviewOnEditSection" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnEditSection" >'+ showPreview_PreviewOnEditSection+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnOnglet=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnOnglet" type="checkbox" name="PreviewOnOnglet" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnOnglet" >'+ showPreview_PreviewOnOnglet+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnCategories=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnCategories" type="checkbox" name="PreviewOnCategories" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnCategories" >'+ showPreview_PreviewOnCategories+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnArticlePrincipal=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnArticlePrincipal" type="checkbox" name="PreviewOnArticlePrincipal" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnArticlePrincipal" >'+ showPreview_PreviewOnArticlePrincipal+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnInfobox=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnInfobox" type="checkbox" name="PreviewOnInfobox" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnInfobox" >'+ showPreview_PreviewOnInfobox+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnCollapsibleBoxes=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnCollapsibleBoxes" type="checkbox" name="PreviewOnCollapsibleBoxes" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnCollapsibleBoxes" >'+ showPreview_PreviewOnCollapsibleBoxes+'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewOnImage=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form  >'
                +'<input id="PreviewOnImage" type="checkbox" name="PreviewOnImage" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewOnImage" >'+ showPreview_PreviewOnImage+'</label><br/>'
                +'</form>';
                MENUOPTIONS +='</fieldset>';

/* ******************** POSITION DES LIENS *************************************************************************** */

                if(PreviewMenuPosition_SiteSub=="true") siteSubPreview = ' checked="checked" ';
                else siteSubPreview = ' ';
                if(PreviewMenuPosition_Sidebar=="true") siteSidePreview = ' checked="checked" ';
                else siteSidePreview = ' ';
                if(PreviewMenuPosition_Personal=="true") sitePersoPreview = ' checked="checked" ';
                else sitePersoPreview = ' ';
                if(PreviewMenuPosition_Cactions=="true") siteCacPreview = ' checked="checked" ';
                else siteCacPreview = ' ';
                if(PreviewMenuPosition_SkinManager=="true") siteSkinPreview = ' checked="checked" ';
                else siteSkinPreview = ' ';
                MENUOPTIONS +='<fieldset id"PreviewMenuPosition" ><legend>'+ showPreview_PreviewMenuPosition +'</legend><form id="PreviewMenuPosition" >'
                +'<input id="PreviewMenuPosition_SiteSub" type="radio" name="position" '+siteSubPreview+' value="'+showPreview_PreviewMenuPosition_SiteSub+'" />'
                +'<label for"PreviewMenuPosition_SiteSub" >'+showPreview_PreviewMenuPosition_SiteSub+'</label><br />'
                +'<input id="PreviewMenuPosition_Sidebar"  type="radio" name="position" '+siteSidePreview+' value="'+showPreview_PreviewMenuPosition_Sidebar+'" />'
                +'<label for"PreviewMenuPosition_Sidebar" >'+showPreview_PreviewMenuPosition_Sidebar+'</label><br />'
                +'<input id="PreviewMenuPosition_Personal"  type="radio" name="position" '+sitePersoPreview+' value="'+showPreview_PreviewMenuPosition_Personal+'" />'
                +'<label for"PreviewMenuPosition_Personal" >'+showPreview_PreviewMenuPosition_Personal+'</label><br />'
                +'<input id="PreviewMenuPosition_Cactions"  type="radio" name="position" '+siteCacPreview+' value="'+showPreview_PreviewMenuPosition_Cactions+'" />'
                +'<label for"PreviewMenuPosition_Cactions" >'+showPreview_PreviewMenuPosition_Cactions+'</label><br />';
                var SkinManagerDiv = document.getElementById("Skin_Manager_Div");
                if(SkinManagerDiv){
                    MENUOPTIONS +=  ''
                    +'<input id="PreviewMenuPosition_SkinManager"  type="radio" name="position" '+siteSkinPreview+' value="'+showPreview_PreviewMenuPosition_SkinManager+'" />'
                    +'<label for"PreviewMenuPosition_SkinManager" >'+showPreview_PreviewMenuPosition_SkinManager+'</label><br />';
                }
                MENUOPTIONS +='</form></fieldset>';

                MENUOPTIONS +='</fieldset>';

/* ******************** PARAMÈTRES *************************************************************************** */

                MENUOPTIONS +='<fieldset id="PreviewSettings" >'
                +'<legend>' +showPreview_SettingsOptions + '</legend><form ><ul>'
                +'<li><label for"AdresseSite" >'+ showPreview_ParamOptions_AdresseSite +'</label>'
                +'<input id="AdresseSite" type="text" size="40" value="' +AdresseSite + '" /></li>'
                +'<li><label for"MaxPreviewNumber" >'+ showPreview_ParamOptions_MaxPreviewNumber +'</label>'
                +'<input id="MaxPreviewNumber" type="text" size="5" value="' +MaxPreviewNumber + '" /></li>';
                MENUOPTIONS +='<li><label for"PreviewWindowWidth" >'+ showPreview_ParamOptions_PreviewWindowWidth+'</label>'
                +'<input id="PreviewWindowWidth" type="text" size="5" value="' +PreviewWindowWidth+ '" /></li>';
                MENUOPTIONS +='<li><label for"PreviewWindowHeight" >'+ showPreview_ParamOptions_PreviewWindowHeight+'</label>'
                +'<input id="PreviewWindowHeight" type="text" size="5" value="' +PreviewWindowHeight+ '" /></li>';
 
                MENUOPTIONS +='<li><label for"Style_Preview_TopBarHeight" >'+ showPreview_ParamOptions_Style_Preview_TopBarHeight+'</label>'
                +'<input id="Style_Preview_TopBarHeight" type="text" size="5" value="' +Style_Preview_TopBarHeight+ '" /></li>';

                MENUOPTIONS +='<li><label for"InitialDecalTop" >'+ showPreview_ParamOptions_InitialDecalTop+'</label>'
                +'<input id="InitialDecalTop" type="text" size="5" value="' +InitialDecalTop+ '" /></li>';

                MENUOPTIONS +='<li><label for"InitialDecalLeft" >'+ showPreview_ParamOptions_InitialDecalLeft+'</label>'
                +'<input id="InitialDecalLeft" type="text" size="5" value="' +InitialDecalLeft+ '" /></li>';

                MENUOPTIONS +='<li><label for"DecalageTop" >'+ showPreview_ParamOptions_DecalageTop+'</label>'
                +'<input id="DecalageTop" type="text" size="5" value="' +DecalageTop+ '" /></li>';

                MENUOPTIONS +='<li><label for"DecalageLeft" >'+ showPreview_ParamOptions_DecalageLeft+'</label>'
                +'<input id="DecalageLeft" type="text" size="5" value="' +DecalageLeft+ '" /></li>';

                MENUOPTIONS +='<li><label for"MaxDecalTop" >'+ showPreview_ParamOptions_MaxDecalTop +'</label>'
                +'<input id="MaxDecalTop" type="text" size="5" value="' +MaxDecalTop + '" /></li>'
                +'<li><label for"MaxDecalLeft" >'+ showPreview_ParamOptions_MaxDecalLeft +'</label>'
                +'<input id="MaxDecalLeft" type="text" size="5" value="' +MaxDecalLeft + '" /></li>'
                +'</ul></form></fieldset>';  


/* ******************** STYLES DES LIENS *************************************************************************** */

                MENUOPTIONS +='<fieldset id="PreviewStylesLinks" >'
                +'<legend>' +showPreview_StylesLinksOptions + '</legend>';
                checkBoxOn ='';
                if(AddPreviewLinks=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form >'
                +'<input id="AddPreviewLinks" type="checkbox" name="AddPreviewLinks" value="Activer" '+checkBoxOn+' />'
                +'<label for"AddPreviewLinks" >'+ showPreview_AddPreviewLinks  +'</label><br/>'
                +'</form>';
                checkBoxOn ='';
                if(PreviewButtons=="true")checkBoxOn = 'checked="checked"';
                MENUOPTIONS +='<form >'
                +'<input id="PreviewButtons" type="checkbox" name="PreviewButtons" value="Activer" '+checkBoxOn+' />'
                +'<label for"PreviewButtons" >'+ showPreview_PreviewButtons +'</label><br/>'
                +'</form>';

                MENUOPTIONS += '<form id="PreviewImageOptions" ><ul>';
                MENUOPTIONS +='<li><label for"Style_Preview_Image_Target" >'+ showPreview_StylesLinksOptions_Image_Target +'</label><br/>'
                +'<input id="Style_Preview_Image_Target" type="text" size="150" value="' + Style_Preview_Image_Target + '"/></li>';
                MENUOPTIONS +='<li><label for"Style_Preview_Image_Height" >'+ showPreview_StylesLinksOptions_Image_Height +'</label><br/>'
                +'<input id="Style_Preview_Image_Height" type="text" size="5" value="' + Style_Preview_Image_Height + '"/></li>' ;
                MENUOPTIONS +='<li><label for"Style_Preview_Image_Width" >'+ showPreview_StylesLinksOptions_Image_Width +'</label><br/>'
                +'<input id="Style_Preview_Image_Width" type="text" size="5" value="' + Style_Preview_Image_Width + '"/></li>' ;
                MENUOPTIONS +='<li><label for"showPreview_previewText" >'+ showPreview_StylesLinksOptions_Char +'</label><br/>'
                +'<input id="showPreview_previewText" type="text" size="1" value="' + showPreview_previewText + '"/></li>' ;
                MENUOPTIONS += '</ul></form>';

                if(Style_Preview_Image_PositionLeft=="true"){
                        ImagePositionLeft= ' checked="checked" ';  ImagePositionRight= ''; 
                }else {
                        ImagePositionLeft = '';  ImagePositionRight= ' checked="checked" '; 
                }
                MENUOPTIONS +='<form id="PreviewMenuPosition" ><ul><li>'
                +'<label for"Style_Preview_Image_Position" >'+ showPreview_StylesLinksOptions_Image_Position +'</label><br/>'
                +'<input id="Style_Preview_Image_PositionLeft" type="radio" name="PositionLink" '+ImagePositionLeft+' value="'+showPreview_PreviewMenuPosition_SiteSub+'" />'
                +'<label for"Style_Preview_Image_PositionLeft" >'+showPreview_StylesLinksOptions_Image_PositionLeft+'</label>'
                +'<input id="Style_Preview_Image_PositionRight"  type="radio" name="PositionLink" '+ImagePositionRight+' value="'+showPreview_PreviewMenuPosition_Sidebar+'" />'
                +'<label for"Style_Preview_Image_PositionRight" >'+showPreview_StylesLinksOptions_Image_PositionRight+'</label>';
                MENUOPTIONS +='</li></ul></form>';

                MENUOPTIONS += '<form id="PreviewButtonsCSS"><ul>';
                MENUOPTIONS +='<li><label for"Style_Preview_Button" >'+ showPreview_StylesLinksOptions_Button +'</label><br/>'
                +'<input id="Style_Preview_Button" type="text" size="150"  value="' + Style_Preview_Button + '"/></li>' ;
                MENUOPTIONS +='<li><label for"Style_Preview_Button_Hover" >'+ showPreview_StylesLinksOptions_Button_Hover +'</label><br/>'
                +'<input id="Style_Preview_Button_Hover" type="text" size="150" value="' + Style_Preview_Button_Hover + '"/></li>' 
                +'</ul></form>';
                MENUOPTIONS +='</fieldset>';

/* ******************** STYLES DES POP-UP *************************************************************************** */

                MENUOPTIONS +='<fieldset id="PreviewStylesPop" >'
                +'<legend>' +showPreview_StylesPopOptions + '</legend><form>'
                +'<form id="PreviewStyles"><ul>'
                MENUOPTIONS +='<li><label for"Style_Preview_Content">'+ showPreview_StylesPopOptions_Content +'</label><br/>'
                +'<input id="Style_Preview_Content" type="text" size="150" value="' + Style_Preview_Content + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_LoadingSpan" >'+ showPreview_StylesPopOptions_LoadingSpan +'</label><br/>'
                +'<input id="Style_Preview_LoadingSpan" type="text" size="150" value="' + Style_Preview_LoadingSpan + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_TopBar" >'+ showPreview_StylesPopOptions_TopBar +'</label><br/>'
                +'<input id="Style_Preview_TopBar" type="text" size="150" value="' + Style_Preview_TopBar + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_H1" >'+ showPreview_StylesPopOptions_H1 +'</label><br/>'
                +'<input id="Style_Preview_H1" type="text" size="150" value="' + Style_Preview_H1 + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_OtherpageLink" >'+ showPreview_StylesPopOptions_OtherpageLink  +'</label><br/>'
                +'<input id="Style_Preview_OtherpageLink" type="text" size="150" value="' + Style_Preview_OtherpageLink + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_UserContribLink" >'+ showPreview_StylesPopOptions_UserContribLink+'</label><br/>'
                +'<input id="Style_Preview_UserContribLink" type="text" size="150" value="' + Style_Preview_UserContribLink+ '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_EditLink" >'+ showPreview_StylesPopOptions_EditLink +'</label><br/>' 
                +'<input id="Style_Preview_EditLink" type="text" size="150" value="' + Style_Preview_EditLink + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_HistoryLink" >'+ showPreview_StylesPopOptions_HistoryLink +'</label><br/>'
                +'<input id="Style_Preview_HistoryLink" type="text" size="150" value="' + Style_Preview_HistoryLink + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_MoveLink" >'+showPreview_StylesPopOptions_MoveLink  +'</label><br/>'
                +'<input id="Style_Preview_MoveLink" type="text" size="150" value="' + Style_Preview_MoveLink  + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_DeleteLink" >'+ showPreview_StylesPopOptions_DeleteLink +'</label><br/>'
                +'<input id="Style_Preview_DeleteLink" type="text" size="150" value="' + Style_Preview_DeleteLink + '"/></li>' 
                MENUOPTIONS +='<li><label for"Style_Preview_ProtectLink" />'+ showPreview_StylesPopOptions_ProtectLink +'</label><br/>'
                +'<input id="Style_Preview_ProtectLink" type="text" size="150" value="' + Style_Preview_ProtectLink + '"/></li>'
                MENUOPTIONS +='<li><label for"Style_Preview_WatchLink">'+ showPreview_StylesPopOptions_WatchLink +'</label><br/>'  
                +'<input id="Style_Preview_WatchLink" type="text" size="150" value="' + Style_Preview_WatchLink  + '"/></li>' 
                MENUOPTIONS +='</ul></form></fieldset>';

   

                MENUOPTIONS +='<input type="button" style="display:inline;" title="'+showPreview_OptionsTitleSave+'" value="'+showPreview_OptionsSave+'" onclick="setPreviewOptions();"/>'
                + '<input type="button" style="display:inline;"  title="'+showPreview_OptionsTitleRaz+'" value="'+showPreview_OptionsRaz+'" onclick="razPreviewOptions();"/>'
                + '<input type="button" style="width:70px;display:inline;"  title="'+showPreview_OptionsTitleCancel+'" value="'+showPreview_OptionsCancel+'" onclick="hidePreviewOptions();"/>';

                MENUOPTIONS +='</fieldset>'; 



                var MenuOptionDiv = document.createElement('div');
                MenuOptionDiv.id="PreviewOptions";
                MenuOptionDiv.style.backgroundColor="white";
                MenuOptionDiv.innerHTML =MENUOPTIONS;
                ContentSubTitle.parentNode.insertBefore( MenuOptionDiv, ContentSubTitle);
                hidePreviewOptions();
        }

} 

// ################################################################################################################## GESTION DES OPTIONS

function setPreviewOptions(){
// ********************************************* FONCTION DE MISE A JOUR DES OPTIONS *******************

        var Field = document.getElementById("PreviewOptionsField");
        var Inputs = Field.getElementsByTagName("input");
        var now = new Date();
        var nextYear = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365 );
        for(i=0;i<Inputs.length;i++){

               var Input = Inputs[i];
               var InputType = Input.type;
               if ((InputType == "checkbox") && (Input.checked) ){
                      var Label = Input.id;
                      setPreviewCookie (Label, true, nextYear);
               }else if(InputType == "checkbox"){
                      var Label = Input.id;
                      setPreviewCookie (Label, false, nextYear);
               }else if(InputType=="text"){
                      var Label = Input.id;
                      var Value = Input.value;
                      setPreviewCookie (Label, Value, nextYear);
               }else if((InputType=="radio") && (Input.checked) ){
                      var Label = Input.id;
                      setPreviewCookie (Label, "true", nextYear);
               }else if((InputType=="radio")){
                      var Label = Input.id;
                      setPreviewCookie (Label, "false", nextYear );
               }
        }
        window.location.reload();
} 

function razPreviewOptions(){
// ********************************************* FONCTION DE REMISE A ZERO DES OPTIONS *******************

        var Field = document.getElementById("PreviewOptionsField");
        var Inputs = Field.getElementsByTagName("input");
        var now = new Date();
        var nextYear = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365 );
        for(i=0;i<Inputs.length;i++){
               var Input = Inputs[i];
               var InputType = Input.type;
               if ((InputType == "checkbox") || (InputType=="text") || (InputType=="radio") ){
                      var Label = Input.id;
                      setPreviewCookie (Label, '', nextYear);
               }
        }
        window.location.reload();
} 

// ################################################################################################################## GESTION ONGLETS MENU OPTIONS

function displayPreviewOptions(){ // ----------------------------- Affichage Menu
        var Menu = document.getElementById("PreviewOptions");
        Menu.style.display = "block";
        displayPreviewParams();
        var Link = document.getElementById("PreviewLinkOptions");
        Link.innerHTML = '<a class="Preview_MenuLink"  href=\"javascript:hidePreviewOptions(' 
        + ');\" title=\"'+ showPreview_TitleOptionsOff +'\" >' + showPreview_OptionsOff + '</a>';

}

function hidePreviewOptions(){ // ----------------------------- Masquage Menu 
        var Menu = document.getElementById("PreviewOptions");
        Menu.style.display="none";
        var Link = document.getElementById("PreviewLinkOptions");
        Link.innerHTML = '<a class="Preview_MenuLink"  href=\"javascript:displayPreviewOptions(' 
        + ');\" title=\"'+ showPreview_TitleOptions +'\" >' + showPreview_Options + '</a>';
}

function displayPreviewParams(){ // ----------------------------- Affichage Menu "Options"
        var MenuParams = document.getElementById("PreviewParams");
        MenuParams.style.display = "block";

        var MenuStylesLinks = document.getElementById("PreviewStylesLinks");
        MenuStylesLinks.style.display="none";
        var MenuStylesPop = document.getElementById("PreviewStylesPop");
        MenuStylesPop.style.display="none";
        var MenuSettings = document.getElementById("PreviewSettings");
        MenuSettings.style.display="none";
}

function displayPreviewLinkStyles(){ // ----------------------------- Affichage Menu "Styles liens"
        var MenuStylesLinks = document.getElementById("PreviewStylesLinks");
        MenuStylesLinks.style.display = "block";

        var MenuStylesPop = document.getElementById("PreviewStylesPop");
        MenuStylesPop.style.display="none";
        var MenuParams = document.getElementById("PreviewParams");
        MenuParams.style.display="none";
        var MenuSettings = document.getElementById("PreviewSettings");
        MenuSettings.style.display="none";
}
function displayPreviewPopStyles(){ // ----------------------------- Affichage Menu "Styles pop-up"
        var MenuStylesPop = document.getElementById("PreviewStylesPop");
        MenuStylesPop.style.display = "block";

        var MenuParams = document.getElementById("PreviewParams");
        MenuParams.style.display="none";
        var MenuSettings = document.getElementById("PreviewSettings");
        MenuSettings.style.display="none";
        var MenuStylesLinks = document.getElementById("PreviewStylesLinks");
        MenuStylesLinks.style.display="none";
}

function displayPreviewSettings(){ // ----------------------------- Affichage Menu "Paramètres"
        var MenuSettings = document.getElementById("PreviewSettings");
        MenuSettings.style.display = "block";

        var MenuParams = document.getElementById("PreviewParams");
        MenuParams.style.display="none";
        var MenuStylesPop = document.getElementById("PreviewStylesPop");
        MenuStylesPop.style.display="none";
        var MenuStylesLinks = document.getElementById("PreviewStylesLinks");
        MenuStylesLinks.style.display="none";
}

// #################################################################################################################### CREATION DES LIENS D'ACTIVATION et D'OPTIONS

function makeLinkPreview(TagName, element) { 
// ********************************************* TABLEAU D'OPTIONS ****************************
        if(TagName=='none')var AutresCas = true;

        if((TagName!='ul')&&(TagName!='li')&&(TagName!='td')) TagName = '\'AllPage\'';
        if(!element) element = '';

        var SkinManager = document.getElementById("Skin_Manager_Div");
        if( (PreviewMenuPosition_SkinManager== "true")&&(SkinManager)  ){
                var MenuPreviewLinkContainer = SkinManager.getElementsByTagName("ul")[0];
        }else if(PreviewMenuPosition_Sidebar== "true") {
                var MenuPreviewLinkContainer = document.getElementById("p-tb").getElementsByTagName("ul")[0];
        }else if(PreviewMenuPosition_Cactions=="true"){
                var MenuPreviewLinkContainer = document.getElementById("p-cactions").getElementsByTagName("ul")[0];
        }else if(PreviewMenuPosition_Personal=="true"){
                var MenuPreviewLinkContainer = document.getElementById("p-personal").getElementsByTagName("ul")[0];
        }else{
                var MenuPreviewLinkContainer = document.getElementsByTagName("h1")[0];
        }

        PreviewOnLink = '<li id="PreviewLinkOnOff" ><a class="Preview_MenuLink" href=\"javascript:initPreview(' 
                + TagName + element 
                + ');\" title=\"'+ showPreview_TitleOn +'\" >' + showPreview_On + '</a></li>';

        PreviewOffLink = '<li id="PreviewLinkOnOff" ><a class="Preview_MenuLink"  href=\"javascript:cancelPreview('
                + ');\" title=\"'+ showPreview_TitleOff +'\" >' + showPreview_Off + '</a></li>';

        OptionLink = '<li id="PreviewLinkOptions" ><a class="Preview_MenuLink" href=\"javascript:displayPreviewOptions(' 
                + ');\" title=\"'+ showPreview_TitleOptions +'\" >' + showPreview_Options + '</a></li>';


        if(AutresCas != true){
                TheLink = PreviewOnLink;
        }else{
                TheLink = PreviewOffLink;

        }
        if((PreviewMenuPosition_Personal== "true")||(PreviewMenuPosition_Sidebar== "true")||(PreviewMenuPosition_SkinManager== "true")){
                MenuPreviewLinkContainer.innerHTML = TheLink + OptionLink + MenuPreviewLinkContainer.innerHTML ;
        }else if(PreviewMenuPosition_Cactions=="true"){
                MenuPreviewLinkContainer.innerHTML = MenuPreviewLinkContainer.innerHTML+ TheLink + OptionLink  ;
        }else{
                MenuPreviewLinkContainer.innerHTML = '<ul id="PreviewUl" ><li>' + MenuPreviewLinkContainer.innerHTML + '</li>' + TheLink + OptionLink + '</ul>';
        }
        makeMenuOptionPreview();
}

// #################################################################################################################
function cancelPreview(){
// ********************************************* FONCTION DE DESACTIVATION DE LA PREVISUALISATION ******************

        if(AddPreviewLinks == "true"){

                var Link = document.getElementById("PreviewLinkOnOff");
                Link.innerHTML = '<a class="Preview_MenuLink"  href=\"initNewPreview(' 
                + ');\" title=\"'+ showPreview_TitleOn +'\" >' + showPreview_On + '</a>';

                var PageContent = document.getElementById("content");                       // Monobook, Vector, Chick, Myskin, Simple
                if(!PageContent)PageContent = document.getElementById("article");           // Cologneblue, Nostalgia, Standard
                if(!PageContent)PageContent = document.getElementById("mw_contentholder");  // Modern
                if(!PageContent)PageContent = document.body;                                // Autres
                var Buttons = PageContent .getElementsByTagName("span");
                for(i=0;i<Buttons.length;i++){
                     if($( Buttons[i] ).hasClass("Preview_Button")){
                          Buttons[i].style.display = 'none';
                     }
                }
        }else{
               if((mw.config.get('wgAction')!="edit")&&(mw.config.get('wgAction')!="submit")){
                     window.location.reload;
               }else{
                     var Raz = alert('Cette action nécessite le rechargement de la page.\nVos modifications ne seront pas enregistrées.\Continuer ?');
                     if(Raz==true)window.location.reload;
               } 
        }
} 
// #################################################################################################################
function initNewPreview(){
// ********************************************* FONCTION DE REACTIVATION DE LA PREVISUALISATION *******************

        var Link = document.getElementById("PreviewLinkOnOff");
        Link.innerHTML = '<a class="Preview_MenuLink"  href=\"cancelPreview(' 
        + ');\" title=\"'+ showPreview_TitleOff +'\" >' + showPreview_Off + '</a>';

        var PageContent = document.getElementById("content");                       // Monobook, Vector, Chick, Myskin, Simple
        if(!PageContent)PageContent = document.getElementById("article");           // Cologneblue, Nostalgia, Standard
        if(!PageContent)PageContent = document.getElementById("mw_contentholder");  // Modern
        if(!PageContent)PageContent = document.body;                                // Autres

        var Buttons = PageContent .getElementsByTagName("span");
        for(i=0;i<Buttons.length;i++){
                if($( Buttons[i] ).hasClass("Preview_Button")){
                        Buttons[i].style.display = 'inline';
                }
        }

}

// #################################################################################################################### ACTIVATIONS GLOBALES

// ---------------------------------------------------------------------------------------------- CAS GÉNÉRAL 

function initPreview(TagName, Id_element) {
        if((TagName!='ul')&&(TagName!='li')&&(TagName!='td')) TagName = '\'AllPage\'';
     if(!Id_element) Id_element='';

     var PageContent = document.getElementById("content");                       // Monobook, Vector, Chick, Myskin, Simple
     if(!PageContent)PageContent = document.getElementById("article");           // Cologneblue, Nostalgia, Standard
     if(!PageContent)PageContent = document.getElementById("mw_contentholder");  // Modern
     if(!PageContent)PageContent = document.body;                                // Autres

     var Buttons = PageContent .getElementsByTagName("span");
     for(i=0;i<Buttons.length;i++){
          if($( Buttons[i] ).hasClass("Preview_Button")){
               Buttons[i].className = 'Preview_Button_Plus';
               Buttons[i].style.display = 'none';
          }
     }

     var MenuLink = document.getElementById("PreviewLinkOnOff");  
     MenuLink.innerHTML = '<a class="Preview_MenuLink"  href=\"javascript:cancelPreview(' 
                + ');\" title=\"'+ showPreview_TitleOff +'\" >' + showPreview_Off + '</a>';

     var Input = document.getElementsByTagName("AutoPreview");
     Input.checked = "checked";
     setPreviewCookie ("AutoPreview", "true");

     if(Id_element){
          var element = document.getElementById(Id_element);
          if(element){
               if(PreviewButtonsOnSpecialPages== true) createPreviewButtons( element );
               else createPreviewLinks( element);
          }
     }
     
     if(TagName=='\'AllPage\''){
              if( (AddPreviewLinks == "true")||(mw.config.get('wgAction')=="history") ) createPreviewButtons( PageContent );
              else createPreviewLinks( PageContent );
     }else{
          var elements = PageContent.getElementsByTagName(TagName);
          for(i=0;i<elements.length;i++){
              if( (AddPreviewLinks == "true")||(mw.config.get('wgAction')=="history") ) createPreviewButtons( elements[i] );
              else createPreviewLinks( elements[i] );
          }
     }
} 

// ---------------------------------------------------------------------------------------------- SIDEBAR

function initSidebarPreview(){

        var elements = document.getElementsByTagName("div");
        for(i=0;i<elements.length;i++){
                if( 
                   ( ($(elements[i]).hasClass("portlet")) || ($(elements[i]).hasClass("portal"))  )
                    && 
                   ( (elements[i].id!="p-personal")&&(elements[i].id!="p-cactions")&&(elements[i].id!="p-logo") ) 
                  ){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
}

function initSearchPreview(){

        var OldSearchForm = document.getElementById("searchform");
        //if(!OldSearchForm) return;

        NewForm = '<input type="button" class="searchButton" style="width:135px;display:inline;" title="Cliquer pour prévisualiser" value="Prévisualiser" onclick="previewThisPage();"/>';
        OldSearchForm.innerHTML = OldSearchForm.innerHTML + NewForm;

}

function previewThisPage(){
        var Input = document.getElementById('searchInput');
        //if(!Input) return;
        var Page = Input.value;
        if((Page!=null)&&(Page!='')){
                showPreview(encodeURIComponent(Page).replace(/'/g, "ZAPOSTROPHE"),AdresseSite + encodeURIComponent(Page).replace(/'/g, "ZAPOSTROPHE") + '&action=render',AdresseSite + encodeURIComponent(Page).replace(/'/g, "ZAPOSTROPHE"));
        }
}

// ---------------------------------------------------------------------------------------------- LIENS PERSONNELS

function initPersonalPreview(){
        var elements = document.getElementById("p-personal");
        if(elements){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements );
                        else createPreviewLinks( elements );
        }
}

// ---------------------------------------------------------------------------------------------- ONGLETS

function initCactionsPreview(){
        var elements = document.getElementById("p-cactions");
        if(elements){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements );
                        else createPreviewLinks( elements );
        }
}

// ---------------------------------------------------------------------------------------------- DIFF DEPUIS LA DERNIERE MODIF DE L'UTILISATEUR ( onglet "suivi" )

function makePreviewLastDiff() {

    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       parseHistory('', mw.config.get('wgPageName'))
    }    else if (mw.config.get('wgCanonicalNamespace') != "Special") {
       var Cactions = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
       if(!Cactions) return;
       NewPortletLink = '<li><a class="Preview_Button" href=\"javascript:showPreview(\'' + mw.config.get('wgPageName').replace(/'/g, "ZAPOSTROPHE") + '\', \'' +  mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName').replace(/'/g, "ZAPOSTROPHE") 
        + '&action=history&gotosince=true\' , \'' + mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName').replace(/'/g, "ZAPOSTROPHE") + '\');' + '\" title=\"' +TitleSince + '\" >' + TextSince + '</a></li>';
       Cactions.innerHTML = Cactions.innerHTML + NewPortletLink;
    }
}

// ---------------------------------------------------------------------------------------------- DIFF

function initDiffPreview(){
      var Tables = document.getElementsByTagName('table');
      for(f=0;f<Tables.length;f++){
                if( $(Tables[f]).hasClass("diff") ){
                        if(AddPreviewLinks == "true") createPreviewButtons( Tables[f] );
                        else createPreviewLinks( Tables[f] );
                }
      }
}

// ---------------------------------------------------------------------------------------------- EDITION

function initEditPreview(){
      var Divs = document.getElementsByTagName('div');
      for(f=0;f<Divs.length;f++){
                if( $(Divs[f]).hasClass("templatesUsed") || $(Divs[f]).hasClass("hiddencats") || Divs[f].id == "editpage-copywarn" ){
                        if(AddPreviewLinks == "true") createPreviewButtons( Divs[f] );
                        else createPreviewLinks( Divs[f] );
                }
      }
    //addEditPreviewButton(window.ajaxSubmitButton, 'wpSave', ajaxSaveKey);
    addEditPreviewButton(window.ajaxPreviewButton, 'wpPreview', ajaxPreviewKey);
    addEditPreviewButton(window.ajaxDiffButton, 'wpDiff', ajaxDiffKey);
}

// #################################################################################################################### ACTIVATIONS SELECTIVES


// ---------------------------------------------------------------------------------------------- LIENS DE SECTION [modifier]

function initSectionEditPreview(){
        var elements = document.getElementsByTagName("span");
        for(i=0;i<elements.length;i++){
                if( (elements[i].classList.contains("editsection")) ){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
}





// ---------------------------------------------------------------------------------------------- ONGLETS

function initOngletPreview(){
        var elements = document.getElementsByTagName("td");
        for(i=0;i<elements.length;i++){
                if( (elements[i].classList.contains("onglet")) ){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
}



// </syntaxhighlight><syntaxhighlight lang="javascript">
// ---------------------------------------------------------------------------------------------- ARTICLE PRINCIPAL

function initArticlePrincipalPreview(){
        var elements = document.getElementsByTagName("div");
        for(i=0;i<elements.length;i++){
                if( (elements[i].classList.contains("detail")) || (elements[i].classList.contains("principal")) ){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
}

// ---------------------------------------------------------------------------------------------- INFOBOXES

function initInfoboxPreview(){
        var elements = document.getElementsByTagName("table");
        for(i=0;i<elements.length;i++){
                if(elements[i].classList.contains("infobox")){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
}

initImagePreview
// ---------------------------------------------------------------------------------------------- IMAGES

function initImagePreview(){
        var elements = document.getElementsByTagName("div"); // Boîtes déroulantes
        for(i=0;i<elements.length;i++){
                if(elements[i].classList.contains("magnify")){
                      var Lien = elements[i].getElementsByTagName('a')[0];
                      var Titre = Lien.href.split(mw.config.get('wgServer')).join('').split("/wiki/").join('');
                      var Href = AdresseSite + Titre;
                      var Url = Href + '&action=render' ;
                      elements[i].innerHTML = '<a href="javascript:showPreview(\'' +Titre.replace(/'/g, "ZAPOSTROPHE")+ '\',\'' +Url.replace(/'/g, "ZAPOSTROPHE") +'\',\'' +Href.replace(/'/g, "ZAPOSTROPHE")+ '\');" title="' +showPreview_previewTitle+ ' : ' +Titre+ '" >'
                      +'<img src="'+Style_Preview_Image_Target+'" height="20px" width="20px" alt="' +showPreview_previewTitle+ ' : ' +Titre+ '"/></a>';
                }
        }
}

// ---------------------------------------------------------------------------------------------- BOÎTES DÉROULANTES / PALETTES DE NAVIGATION

function initCollapsibleBoxesPreview(){
        var elements = document.getElementsByTagName("div"); // Boîtes déroulantes
        for(i=0;i<elements.length;i++){
                if(elements[i].classList.contains("NavFrame")){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements[i] );
                        else createPreviewLinks( elements[i] );
                }
        }
        var elementsBis = document.getElementsByTagName("table"); // Palettes de navigation
        for(i=0;i<elementsBis.length;i++){
                if(elementsBis[i].id.indexOf("collapsibleTable")!=-1){
                        if(AddPreviewLinks == "true") createPreviewButtons( elementsBis[i] );
                        else createPreviewLinks( elementsBis[i] );
                }
        }
}

// ---------------------------------------------------------------------------------------------- BARRE DE CATÉGORIES

function initCatPreview(){
        var elements = document.getElementById("catlinks");
        if(elements){
                        if(AddPreviewLinks == "true") createPreviewButtons( elements );
                        else createPreviewLinks( elements );
        }
}

// ################################################################################################################## CREATION DES LIENS

function createPreviewLinks( element ){
// ********************************************* FONCTION DE TRANSFORMATION DES LIENS DE PREVISUALISATION *************
        
        var AllLinks = element.getElementsByTagName("a");
        for(s=0;s<AllLinks.length;s++){
               Link= AllLinks[s];

                Target = Link.href;
                if(
                (Target.indexOf('javascript:')==-1)
                &&
                (Target.indexOf('#')==-1)
                &&
                (!Link.classList.contains("image"))
                &&
                (!Link.classList.contains("mw-file-description"))
                &&
                (!Link.classList.contains("external"))
                &&
                (Link.innerHTML!="")
                &&
                (Link.innerHTML.indexOf("<img")==-1)
                &&
                (Link.id != "mw-hidden-cats-link")
                ){
                        TitleLink = Target.split(mw.config.get('wgServer')).join('');
                        TitleLink = TitleLink.split(mw.config.get('wgScript')).join('');
                        TitleLink = TitleLink.split('?title=').join('');
                        TitleLink = TitleLink.split('/wiki/').join('');
                        if(TitleLink.match(/^\//)) TitleLink = TitleLink.replace(/^\// , '');

                        if( (TitleLink.indexOf('http')==-1) && (TitleLink.indexOf('www')==-1) ){
                                TitleLink = decodeURIComponent(TitleLink).replace(/_/g," ");
                                UrlLink = AdresseSite + TitleLink;                   
                                if( (Target.indexOf('action=')==-1) ){
                                        UrlLink = encodeURIComponent(UrlLink).replace(/'/g, "%27")  + '&action=render';                                
                                }else{
                                        UrlLink = encodeURIComponent(UrlLink.replace(/\?action=/g, "&action=") ).replace(/'/g, "%27")  ;                                
                                }
                                TitleLink = TitleLink.replace(/\?action=.*/ , '');
                                TitleLink = TitleLink.replace(/&action=.*/ , '');
                                TitleLink = TitleLink.replace(/&diff=.*/ , '');
                                TitleLink = TitleLink.replace(/&oldid=.*/ , '');
                                TitleLink = TitleLink.replace(/&curid=.*/ , '');
                                TitleLink = TitleLink.replace(/&rcid=.*/ , '');
                                TitleLink = TitleLink.replace(/&limit=.*/ , '');
                                TitleLink = TitleLink.replace(/&days=.*/ , '');
                                TitleLink = TitleLink.replace(/&hide.*/ , '');
                                TitleLink = TitleLink.replace(/&from=.*/ , '');
                                TitleLink = TitleLink.replace(/&to=.*/ , '');
                                TitleLink = TitleLink.replace(/&until=.*/ , '');
                                TitleLink = TitleLink.replace(/&dir=.*/ , '');
                                TitleLink = TitleLink.replace(/&book.*/ , '');
                                TitleLink = TitleLink.replace(/&printable.*/ , '');
                                TitleLink = TitleLink.replace(/&redirect=.*/ , '');
                                HrefLink = AdresseSite + encodeURIComponent(TitleLink).replace(/'/g, "%27");

                                Link.setAttribute("title", showPreview_previewTitle + " : " + TitleLink ); 
                                Link.href = 'javascript:showPreview(\"' + encodeURIComponent(TitleLink).replace(/'/g, "ZAPOSTROPHE") + '\",\"' + UrlLink.replace(/'/g, "ZAPOSTROPHE") + '\",\"' + HrefLink.replace(/'/g, "ZAPOSTROPHE") + '\")' ;
                                Link.className = 'Preview_Button';
                        }
                }
        }
}

function createPreviewButtons( element ){
// ********************************************* FONCTION DE CRÉATION DES LIENS SUPPLEMENTAIRES ***********************        
        var AllLinks = element.getElementsByTagName("a");
        for(s=0;s<AllLinks.length;s++){
               Link= AllLinks[s];
                Target = Link.href;
                if(
                (Target.indexOf('javascript:')==-1)
                &&
                (Target.indexOf('#')==-1)
                &&
                (!Link.classList.contains("image"))
                &&
                (!Link.classList.contains("mw-file-description"))
                &&
                (!Link.classList.contains("external"))
                &&
                (Link.innerHTML!="")
                &&
                (Link.innerHTML.indexOf("<img")==-1)
                &&
                (Link.id != "mw-hidden-cats-link")
                ){
                        TitleLink = Target.split(mw.config.get('wgServer')).join('');
                        TitleLink = TitleLink.split(mw.config.get('wgScript')).join('');
                        TitleLink = TitleLink.split('?title=').join('');
                        TitleLink = TitleLink.split('/wiki/').join('');
                        if(TitleLink.match(/^\//)) TitleLink = TitleLink.replace(/^\// , '');

                        if( (TitleLink.indexOf('http')==-1) && (TitleLink.indexOf('www')==-1) ){
                                TitleLink = decodeURIComponent(TitleLink).replace(/_/g," ");
                                UrlLink = AdresseSite + TitleLink;                   
                                if( (Target.indexOf('action=')==-1) ){
                                        UrlLink = encodeURIComponent(UrlLink).replace(/'/g, "%27")  + '&action=render';                                
                                }else{
                                        UrlLink = encodeURIComponent(UrlLink.replace(/\?action=/g, "&action=") )  ;                                
                                }
                                TitleLink = TitleLink.replace(/\?action=.*/ , '');
                                TitleLink = TitleLink.replace(/&action=.*/ , '');
                                TitleLink = TitleLink.replace(/&diff=.*/ , '');
                                TitleLink = TitleLink.replace(/&oldid=.*/ , '');
                                TitleLink = TitleLink.replace(/&curid=.*/ , '');
                                TitleLink = TitleLink.replace(/&rcid=.*/ , '');
                                TitleLink = TitleLink.replace(/&limit=.*/ , '');
                                TitleLink = TitleLink.replace(/&days=.*/ , '');
                                TitleLink = TitleLink.replace(/&hide.*/ , '');
                                TitleLink = TitleLink.replace(/&from=.*/ , '');
                                TitleLink = TitleLink.replace(/&to=.*/ , '');
                                TitleLink = TitleLink.replace(/&until=.*/ , '');
                                TitleLink = TitleLink.replace(/&dir=.*/ , '');
                                TitleLink = TitleLink.replace(/&book.*/ , '');
                                TitleLink = TitleLink.replace(/&printable.*/ , '');
                                TitleLink = TitleLink.replace(/&redirect=.*/ , '');
                                HrefLink = AdresseSite + encodeURIComponent(TitleLink).replace(/'/g, "%27");
                                Button = document.createElement("span");
                                Button.className = "Preview_Button";
                                Button.setAttribute("title", showPreview_previewTitle + " : " + TitleLink ); 
                                if(PreviewButtons=="true"){
                                        ButtonImage = document.createElement("img");
                                        ButtonImage.style.height = Style_Preview_Image_Height;
                                        ButtonImage.style.width = Style_Preview_Image_Width;
                                        ButtonImage.alt = "Prévisualiser"; // à adapter en fonction de la langue
                                        ButtonImage.src = Style_Preview_Image_Target ;
                                        Button.appendChild(ButtonImage);
                                }else{
                                        Button.innerHTML = showPreview_LinkContainer_Before_Bis + showPreview_previewText + showPreview_LinkContainer_After_Bis; 
                                }
                                Separator = document.createTextNode(showPreview_Seperator);
                                if(Style_Preview_Image_PositionLeft=="true"){ 
                                        Link.parentNode.insertBefore(Separator,Link);
                                        Link.parentNode.insertBefore(Button,Separator);
                                }else{
                                        $(Separator).insertAfter(Link);
                                        $(Button).insertAfter(Separator);
                                }
                                Button.innerHTML = '<span onclick=\"javascript:showPreview(\''
                                + encodeURIComponent(TitleLink).replace(/'/g, "ZAPOSTROPHE") + '\',\'' + UrlLink.replace(/'/g, "ZAPOSTROPHE") + '\',\'' + HrefLink.replace(/'/g, "ZAPOSTROPHE") + '\')\">' 
                                + Button.innerHTML + '</span>';   
                        }
                }
        }
}

// #################################################################################################################### AFFICHAGE DE LA POP-UP

function showPreview(title, url, titlehref, watchAction, deleteAction, protectAction  ) {
//
// ********************************************* FONCTION D'AFFICHAGE DE LA POP-UP ************************************
//
// PARAMETRES : 
// * title                    = titre de la page cible (obligatoire)
// * url                      = adresse de la page rendue (facultatif, par défaut, utilise le titre pour trouver la page ciblée sur le serveur)
// * titlehref                = adresse de la page ( facultatif, lien du titre )
// * watchAction              = page suivie ou non (facultatif, par défaut, utilise le titre pour trouver la page ciblée sur le serveur)
// * deleteAction             = action "delete" ou "undelete" (facultatif, "delete" par défaut)
// * protectAction            = action "protect" ou "unprotect" (facultatif, "protect" par défaut)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// *********************** Vérification de la présence d'au moins un paramètre de titre

    if(!title){
         alert('Elément non précisé :\n Paramètre \" titre \" manquant dans la fonction showPreview');
         return;
    }

// *********************** Vérification du support ajax 

    var ajaxRequest = new XMLHttpRequest();
    if (!ajaxRequest){
         alert('méthode ajax non supportée : new XMLHttpRequest()');
         return;
    }else{

// *********************** Vérification du nombre de fenêtres de prévisualisation ouvertes

        if(PreviewNumber>=MaxPreviewNumber){
            alert('Nombre maximum de pop-up dépassé.\nFermez des fenêtres pour pouvoir en ouvrir d\'autres,\nou modifiez vos options.');
            return;
        }



// *********************** Recherche des éléments de la page *****

        var PageContent = document.body;    

// *********************** Remise au propre du texte des liens (annulation du  encodeURIComponent() )

        title = decodeURIComponent(title).replace(/%3A/g, ":").replace(/%2F/g, "/").replace(/_/g, " ").replace(/ZAPOSTROPHE/g, "'");
        url = decodeURIComponent(url).replace(/ /g, "_").replace(/%3A/g, ":").replace(/%2F/g, "/").replace(/ZAPOSTROPHE/g, "'");
        titlehref = decodeURIComponent(titlehref).replace(/ /g, "_").replace(/%3A/g, ":").replace(/%2F/g, "/").replace(/ZAPOSTROPHE/g, "'");

// *********************** Vérification de l'absence de fenêtre d'édition déjà ouverte

        if( (url.indexOf("&action=edit")!=-1) ){
            if( (PreviewEdit==true) ){
                alert('Il y a déjà une fenêtre d\'édition ouverte.\nVous devez la fermer pour pouvoir en ouvrir une autre');
                return;
            }else{
                PreviewEdit=true;
            }
        }


// *********************** Définition des caractéristiques du lien vers la page associée

        if( (title.indexOf("Discussion")!=-1) ){
            OtherPageText = showPreview_SubjectText;
            OtherPageTitle = title.replace(/^Discussion:/, "").replace(/^Discussion/, "");
        }else{
            OtherPageText = showPreview_TalkText;
            if( (title.match(/^Utilisateur:/))|| (title.match(/^Wikipédia:/))|| (title.match(/^Fichier:/))|| (title.match(/^MediaWiki:/))|| (title.match(/^Modèle:/))|| (title.match(/^Aide:/))|| (title.match(/^Catégorie:/))|| (title.match(/^Portail:/))|| (title.match(/^Projet:/))|| (title.match(/^Références:/)) ){
                OtherPageTitle = 'Discussion ' + title;
            }else{
                OtherPageTitle = 'Discussion:' + title;
            }
        }

// *********************** Définition du lien vers les contributions de l'utilisateur

        if( (title.match(/^Discussion Utilisateur:/)) || (title.match(/^Discussion utilisateur:/)) || (title.match(/^Utilisateur:/)) ){
            UserPage = true;
            PageTitle = title.split("Discussion Utilisateur:").join("");
            PageTitle = title.split("Discussion utilisateur:").join("");
            PageTitle = PageTitle.split("Utilisateur:").join("");
            if ( PageTitle.indexOf("/") == -1 ) {
                UserName = encodeURIComponent(PageTitle);
            } else {
                UserName = encodeURIComponent(PageTitle.substring(0, PageTitle.indexOf("/")));
            }
        }else{
            UserPage = false;
        }

// *********************** Définition des caractéristiques du lien de suppression / restauration

        if(!deleteAction){
            DeleteLinkText = showPreview_DeleteText;
            deleteLinkhref =  "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=delete\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
        }else{
            DeleteLinkText = showPreview_UndeleteText;
            deleteLinkhref =  "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=undelete\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";      
        }


// *********************** Définition des caractéristiques du lien de protection / déprotection

        if(!protectAction){
            ProtectLinkText = showPreview_ProtectText;
            protectLinkhref =  "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=protect\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
        }else{
            ProtectLinkText = showPreview_Unprotext
            protectLinkhref =  "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=unprotect\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";      
        }

// *********************** Définition des caractéristiques du lien suivre /stop 

        if( (!watchAction)||(watchAction!="unwatch") ){
            WatchLinkText = showPreview_WatchText; 
            WatchLinkhref = "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=watch\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
        }else{
            WatchLinkText = showPreview_UnwatchText; 
            WatchLinkhref =  "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=unwatch\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";     
        }

// *********************** Gestion du décalage des fenêtres de prévisualisation successives ( largeur, hauteur, z-index )

        DecalLeft = (DecalLeft+DecalageLeft);
        DecalTop = (DecalTop+DecalageTop);
        if( (DecalTop >= MaxDecalTop)||(DecalLeft >= MaxDecalLeft)){
             InitialDecalLeft = (InitialDecalLeft+DecalageLeft);
             DecalTop = (0-InitialDecalTop)+(DecalageTop);
             DecalLeft = (0-InitialDecalLeft)+(DecalageLeft);
        }

//    alert(DecalLeft+'  '+DecalTop);


// ####################### Création de la fenêtre de visualisation ########################################

// *********************** Cadre ***************************************


        var previewWindow = document.createElement('div');
        previewWindow.id='preview_Window_'+PreviewNumber;
        previewWindow.className ='Preview_Container';
        previewWindow.style.position='fixed';
        previewWindow.style.zIndex=(DecalZ+1);
        previewWindow.style.padding='5px';
        previewWindow.style.backgroundColor='white';
        previewWindow.style.border='2px solid #aaaaaa';
        previewWindow.style.overflow='hidden'; 
        PageContent.appendChild(previewWindow);
        var MinHeight = ( parseFloat(Style_Preview_TopBarHeight.split("em").join("")) - (parseInt(previewWindow.style.padding)*2)  ) + 'em' ;
        previewWindow.style.width= PreviewWindowWidth;
        previewWindow.style.height= PreviewWindowHeight;
        previewWindow.style.minWidth= '10em';
        previewWindow.style.minHeight= MinHeight;


        if(is_ie){
          PositionGauche = parseInt(screen.width-previewWindow.clientWidth)/2 + DecalLeft;
          PositionHaut = parseInt(screen.height-previewWindow.clientHeight)/2 + DecalTop;
        }else{
          PositionGauche = parseInt(window.innerWidth-previewWindow.clientWidth)/2 + DecalLeft;
          PositionHaut = parseInt(window.innerHeight-previewWindow.clientHeight)/2 + DecalTop;
        }
        if( PositionGauche < 0){
             PositionGauche = 0;
        }
        if( PositionHaut < 0){
             PositionHaut = 0;
        }
        previewWindow.style.left=PositionGauche + 'px';
        previewWindow.style.top=PositionHaut + 'px';

// *********************** Barre de titre ("move") **************************************************

        var PreviewTop = document.createElement('div');
        PreviewTop.className='Preview_TopBar';
        PreviewTop.id='Preview_TopBar_'+PreviewCount;
        PreviewTop.style.position='relative';
        PreviewTop.style.width='100%';
        PreviewTop.style.cursor='move';
        PreviewTop.onmousedown=function(event) {
            CollapsedCount = (CollapsedCount-1);
            monbody = document.body;
            if(is_ie){ 
                if(!event) { event= window.event; }
                positionSouris_X = parseInt( event.clientX + monbody.scrollLeft );
                positionSouris_Y = parseInt( event.clientY + monbody.scrollTop );
            }else{
                positionSouris_X = parseInt( event.clientX );
                positionSouris_Y = parseInt( event.clientY );
            }

            previewWindow.initialX = parseInt( positionSouris_X - previewWindow.offsetLeft);
            previewWindow.initialY = parseInt( positionSouris_Y - previewWindow.offsetTop);

            monbody.onmousemove = function(event) {
                if(is_ie){
                    if(!event) { event= window.event; }
                    positionSouris_X = parseInt( event.clientX + monbody.scrollLeft );
                    positionSouris_Y = parseInt( event.clientY + monbody.scrollTop );
                }else{
                    positionSouris_X = parseInt( event.clientX );
                    positionSouris_Y = parseInt( event.clientY );
                }
                PositionGauche = parseInt( positionSouris_X ) - previewWindow.initialX;
                PositionHaut = parseInt(positionSouris_Y ) - previewWindow.initialY;
                if( PositionGauche < 0){
                    PositionGauche = 0;
                }
                if( PositionHaut < 0){
                     PositionHaut = 0;
                }
                previewWindow.style.left=PositionGauche + 'px';
                previewWindow.style.top=PositionHaut + 'px';
                previewWindow.style.opacity='.8';
            }

            monbody.onmouseup=function(event) {
                previewWindow.style.opacity='';
                monbody.onmousemove=null;
                monbody.onmouseup=null;
            }
        }
        previewWindow.appendChild(PreviewTop);

// *********************** Liens de la barre de titre ***********************************************

        var MainLink = document.createElement('a'); //--------------------------------------------------- Lien vers la page visionnée
        MainLink.id='Preview_H1_'+PreviewCount;
        MainLink.className='Preview_H1';
        MainLink.href = AdresseSite + encodeURIComponent(title) + "#" ;
        MainLink.title =AdresseSite + title.replace(/ /g, "_") ;
        MainLink.appendChild(document.createTextNode(url) );
        PreviewTop.appendChild(MainLink);

//-------------------------------------------- ***********************************************  Liens supplémentaires

        PreviewTop.appendChild(document.createElement("br"));

        var OtherLinks = document.createElement("span");
        OtherLinks.style.display="none";
        PreviewTop.appendChild(OtherLinks);

//--------------------------------------------------- Lien vers la page associée : [page principale] ou [discuter]

        var OtherPageLink = document.createElement('a'); 
        OtherPageLink.id='Preview_OtherpageLink_'+PreviewCount;
        OtherPageLink.className='Preview_OtherpageLink';
        OtherPageLink.href = "javascript:showPreview(\'"
 + encodeURIComponent(OtherPageTitle).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(OtherPageTitle).replace(/'/g, "ZAPOSTROPHE")+ "&action=render\', \'"
 + AdresseSite + encodeURIComponent(OtherPageTitle).replace(/'/g, "ZAPOSTROPHE") + "\');";
        OtherPageLink.setAttribute("title", OtherPageTitle);
        OtherPageLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+OtherPageText+showPreview_LinkContainer_After) );
        OtherLinks.appendChild(OtherPageLink);

//--------------------------------------------------- Lien vers les contributions de l'utilisateur : [contributions]

        if(UserPage==true){
                OtherLinks.appendChild(document.createTextNode(" - "));
                var ContribPageTitle = 'Special:Contributions/' + UserName;
                var UserContribLink = document.createElement('a'); 
                UserContribLink.id='Preview_UserContribLink_'+PreviewCount;
                UserContribLink.className='Preview_UserContribLink';
                UserContribLink.href = "javascript:showPreview(\'"
 + encodeURIComponent(ContribPageTitle).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(ContribPageTitle).replace(/'/g, "ZAPOSTROPHE")+ "&action=render\', \'"
 + AdresseSite + encodeURIComponent(ContribPageTitle).replace(/'/g, "ZAPOSTROPHE") + "\');";
                UserContribLink.setAttribute("title", ContribPageTitle);
                UserContribLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+showPreview_ContribText+showPreview_LinkContainer_After) );
                OtherLinks.appendChild(UserContribLink);
        }

//--------------------------------------------------- Lien [modifier]

        OtherLinks.appendChild(document.createTextNode(" - "));

        var EditLink = document.createElement('a'); 
        EditLink.id='Preview_EditLink_'+PreviewCount;
        EditLink.className='Preview_EditLink';
        EditLink.href = "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=edit\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
        EditLink.setAttribute("title", showPreview_EditText +" : " + title);
        EditLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+showPreview_EditText+showPreview_LinkContainer_After) );
        OtherLinks.appendChild(EditLink);

//--------------------------------------------------- Lien [historique]

        OtherLinks.appendChild(document.createTextNode(" "));

        var HistoryLink = document.createElement('a'); 
        HistoryLink.id='Preview_HistoryLink_'+PreviewCount;
        HistoryLink.className='Preview_HistoryLink';
        HistoryLink.href = "javascript:showPreview(\'"
 + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=history\', \'"
 + AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
        HistoryLink.setAttribute("title", showPreview_HistText +" : " + title);
        HistoryLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+showPreview_HistText+showPreview_LinkContainer_After) );
        OtherLinks.appendChild(HistoryLink);

//--------------------------------------------------- Lien [renommer]
           
        if(mw.config.get('wgUserGroups').indexOf("autoconfirmed") != -1){
                        OtherLinks.appendChild(document.createTextNode(" "));
                        var MoveLink = document.createElement('a'); 
                        MoveLink.id='Preview_MoveLink_'+PreviewCount;
                        MoveLink.className='Preview_MoveLink';
                        MoveLink.href = "javascript:showPreview(\'"
 + 'Special:Movepage/'+ encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "\', \'"
 + AdresseSite + 'Special:Movepage/'+ encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE")+ "&action=render\', \'"
 + AdresseSite + 'Special:Movepage/'+ encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
                        MoveLink.setAttribute("title", showPreview_MoveText +" : " + title);
                        MoveLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+showPreview_MoveText+showPreview_LinkContainer_After) );
                        OtherLinks.appendChild(MoveLink);
        }

//--------------------------------------------------- Lien [supprimer] [restaurer]

        if(mw.config.get('wgUserGroups').indexOf("sysop") != -1){
                        OtherLinks.appendChild(document.createTextNode(" "));
                        var DeleteLink = document.createElement('a'); 
                        DeleteLink.id='Preview_DeleteLink_'+PreviewCount;
                        DeleteLink.className='Preview_DeleteLink';
                        DeleteLink.href = deleteLinkhref;
                        DeleteLink.setAttribute("title", DeleteLinkText +" : " + title);
                        DeleteLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+DeleteLinkText+showPreview_LinkContainer_After) );
                        OtherLinks.appendChild(DeleteLink);

//--------------------------------------------------- Lien [protéger] [déprotéger]

                        OtherLinks.appendChild(document.createTextNode(" "));
                        var ProtectLink = document.createElement('a'); 
                        ProtectLink.id='Preview_ProtectLink_'+PreviewCount;
                        ProtectLink.className='Preview_ProtectLink';
                        ProtectLink.href = protectLinkhref;
                        ProtectLink.setAttribute("title", ProtectLinkText +" : " + title);
                        ProtectLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+ProtectLinkText+showPreview_LinkContainer_After) );
                        OtherLinks.appendChild(ProtectLink);
        }

//--------------------------------------------------- Lien [suivre]

        OtherLinks.appendChild(document.createTextNode(" "));
        var WatchLink = document.createElement('a'); 
        WatchLink.id='Preview_WatchLink_'+PreviewCount;
        WatchLink.className='Preview_WatchLink';
        WatchLink.href = WatchLinkhref ;    
        WatchLink.setAttribute("title", WatchLinkText + " : " + title);
        WatchLink.appendChild(document.createTextNode(showPreview_LinkContainer_Before+WatchLinkText+showPreview_LinkContainer_After) );
        OtherLinks.appendChild(WatchLink);

// *********************** BOUTONS ***********************************************

        var WindowButtons = document.createElement('div'); 
        WindowButtons.style.position='absolute';
        WindowButtons.style.top='5px';
        WindowButtons.style.right='10px';
        previewWindow.appendChild(WindowButtons);

// *********************** Bouton Retrécissement ("collapse") ***********************************************

        var collapseButton = document.createElement('a'); 
        collapseButton.id='Preview_Collapse_'+PreviewCount;
        collapseButton.setAttribute("class", "Preview_Collapse");
        collapseButton.href='#';
        collapseButton.title=showPreview_CollapseButton;
        collapseButton.style.marginRight='5px';

        collapseButton.onclick = function () {

                if(CollapsedCount<0) CollapsedCount=0;
                Intervalle = ( parseInt(PreviewTop.offsetHeight) + (parseInt(previewWindow.style.padding)*5) );

                NouvelleHauteur = (Intervalle*CollapsedCount)
                if(NouvelleHauteur>=(HauteurEcran-Intervalle)){ NouvelleHauteur = 0; CollapsedCount=0;}

                previewWindow.style.left = 0 + 'px';

                previewWindow.style.top = NouvelleHauteur + 'px';

                previewWindow.style.width  = 300 + 'px';
                previewWindow.style.height = ( parseInt(PreviewTop.offsetHeight) + (parseInt(previewWindow.style.padding)*2) ) + 'px';
                previewWindowcontent.style.width  = (300 - (parseInt(previewWindow.style.padding)*2) ) + 'px';
                previewWindowcontent.style.height = 0 + 'px';
                CollapsedCount = (CollapsedCount+1);
        };
        var collapseButtonImage = document.createElement('img');
        collapseButtonImage.setAttribute("class", "Preview_Close_Image");
        collapseButtonImage.src = 'http://upload.wikimedia.org/wikipedia/commons'
        + '/7/76/Crystal_Clear_action_down.png';
        collapseButtonImage.height='25';
        collapseButtonImage.width= '25';
        collapseButtonImage.alt=showPreview_CollapseButton; 
        collapseButton.appendChild(collapseButtonImage);
        WindowButtons.appendChild(collapseButton);

// *********************** Bouton Agrandissement ("magnify") ***********************************************

        var magnifyButton = document.createElement('a'); 
        magnifyButton.id='Preview_Magnify_'+PreviewCount;
        magnifyButton.setAttribute("class", "Preview_Magnify");
        magnifyButton.href='#';
        magnifyButton.title=showPreview_MagnifyButton;
        magnifyButton.style.marginRight='5px';

        magnifyButton.onclick = function () {
                previewWindow.style.left = 5 + 'px';
                previewWindow.style.top = 25 + 'px';

                previewWindow.style.width  = ( LargeurEcran - (parseInt(previewWindow.style.padding)*2) -30) + 'px';
                previewWindow.style.height = ( HauteurEcran - (parseInt(previewWindow.style.padding)*2) -50) + 'px';
                previewWindowcontent.style.width  = ( LargeurEcran - (parseInt(previewWindow.style.padding)*2) -35) + 'px';
                previewWindowcontent.style.height = ( (HauteurEcran-parseInt(PreviewTop.offsetHeight)) - (parseInt(previewWindow.style.padding)*2) -50) + 'px';
                if (previewWindow.style.zIndex < DecalZ ) {
                        previewWindow.style.zIndex=++DecalZ;
                }
        };
        var magnifyButtonImage = document.createElement('img');
        magnifyButtonImage.setAttribute("class", "Preview_Close_Image");
        magnifyButtonImage.src = 'http://upload.wikimedia.org/wikipedia/commons'
        + '/7/7a/Crystal_Clear_action_up.png';
        magnifyButtonImage.height='25';
        magnifyButtonImage.width= '25';
        magnifyButtonImage.alt= showPreview_MagnifyButton;
        magnifyButton.appendChild(magnifyButtonImage);
        WindowButtons.appendChild(magnifyButton);

// *********************** Bouton Fermeture ("close") ***********************************************
 
        var closeButton = document.createElement('a'); 
        closeButton.id='Preview_Close_'+PreviewCount;
        closeButton.setAttribute("class", "Preview_Close");
        closeButton.href='#';
        closeButton.title=showPreview_CloseButton;
        closeButton.onclick = function () {
                previewWindow.parentNode.removeChild(previewWindow);
                PreviewNumber=(PreviewNumber-1); 
                if(url.indexOf("&action=edit")!=-1)PreviewEdit=false;
                return false;
        };
        var closeButtonImage = document.createElement('img');
        closeButtonImage.setAttribute("class", "Preview_Close_Image");
        closeButtonImage.src = 'http://upload.wikimedia.org/wikipedia/commons'
        + '/2/2c/Crystal_Clear_action_stop.png';
        closeButtonImage.height='25';
        closeButtonImage.width= '25';
        closeButtonImage.alt= showPreview_CloseButton;
        closeButton.appendChild(closeButtonImage);
        WindowButtons.appendChild(closeButton);

// *********************** Contenu de la prévisualisation ***********************************************
 
        var previewWindowcontent = document.createElement('div'); 
        previewWindowcontent.id='Preview_Content_'+PreviewCount;
        previewWindowcontent.setAttribute("class", "Preview_Content");
        previewWindowcontent.style.position='relative';
        previewWindowcontent.style.clear='both';
        previewWindowcontent.style.overflow='scroll';
        previewWindowcontent.style.height=parseInt(previewWindow.clientHeight - PreviewTop.offsetHeight - parseInt(previewWindow.style.padding)*2)+'px';
        previewWindow.onmousedown=function(event) {
            if (previewWindow.style.zIndex < DecalZ ) {
                previewWindow.style.zIndex=++DecalZ;
            }
        }
        previewWindow.appendChild(previewWindowcontent);

// ***********************   Bouton de recadrage ("Resize") ***********************************************

        var resizeButton = document.createElement('div');
        resizeButton.id='Preview_Resize_'+PreviewCount;
        resizeButton.setAttribute("class","Preview_Resize");
        resizeButton.title=showPreview_ResizeButton;
        resizeButton.style.position='absolute';
        resizeButton.style.zIndex=(DecalZ+20);
        resizeButton.style.bottom='0px';
        resizeButton.style.right='0px';
        resizeButton.style.height='25px';
        resizeButton.style.width= '25px';
        resizeButton.style.cursor='se-resize';
        var resizeButtonImage = document.createElement('img');
        resizeButton.id = "Preview_Resize_Image_"+PreviewCount;
        resizeButton.className = "Preview_Resize_Image";
        resizeButtonImage.src = 'http://upload.wikimedia.org/wikipedia/commons'
        + '/0/06/Crystal_Clear_app_desktop_enhancements.png';
        resizeButtonImage.height= '25';
        resizeButtonImage.width= '25';
        resizeButtonImage.alt= "showPreview_ResizeButton";
        resizeButton.appendChild(resizeButtonImage);
        resizeButton.onmousedown=function(event) {
            if (previewWindow.style.zIndex < DecalZ ) {
                previewWindow.style.zIndex=++DecalZ;
            }
            monbody = document.body;
            if(is_ie){ 
                if(!event) { event= window.event; }
                positionSouris_X = parseInt( event.clientX + monbody.scrollLeft );
                positionSouris_Y = parseInt( event.clientY + monbody.scrollTop );
            }else{
                positionSouris_X = parseInt( event.clientX );
                positionSouris_Y = parseInt( event.clientY );
            }
            previewWindow.initialWidth = parseInt( positionSouris_X - previewWindow.offsetWidth );
            previewWindow.initialHeight = parseInt( positionSouris_Y - previewWindow.offsetHeight );
            previewWindow.style.opacity='.8';
        
            monbody.onmousemove=function(event) {
                if(is_ie){ 
                    if(!event) { event= window.event; }
                    positionSouris_X = parseInt( event.clientX + monbody.scrollLeft );
                    positionSouris_Y = parseInt( event.clientY + monbody.scrollTop );
                }else{
                    positionSouris_X = parseInt( event.clientX );
                    positionSouris_Y = parseInt( event.clientY );
                }
                previewWindow.style.width  = parseInt( positionSouris_X - previewWindow.initialWidth  - (parseInt(previewWindow.style.padding)*2)-5) + 'px';
                previewWindow.style.height = parseInt( positionSouris_Y - previewWindow.initialHeight  - (parseInt(previewWindow.style.padding)*2)-5) + 'px';
                previewWindowcontent.style.width  = parseInt( positionSouris_X - previewWindow.initialWidth  - (parseInt(previewWindow.style.padding)*2) - 10 ) + 'px';
                previewWindowcontent.style.height = parseInt( positionSouris_Y - previewWindow.initialHeight - PreviewTop.offsetHeight - (parseInt(previewWindow.style.padding)*2) -5) + 'px';

            }
            monbody.onmouseup=function(event) {
                previewWindow.style.opacity = '';
                monbody.onmousemove=null;
                monbody.onmouseup=null;
            }
        }
        previewWindow.appendChild(resizeButton);

// **********************************************************************************************
// *********************** Lancement de la requête ajax *************************************

        ajaxRequest.open("GET", url, true);
        ajaxRequest.send(null);
        while (previewWindowcontent.firstChild) { previewWindowcontent.removeChild(previewWindowcontent.firstChild) };
        var LoadingSpan = document.createElement('div');
        LoadingSpan.id = 'Preview_LoadingSpan_'+PreviewCount;
        LoadingSpan.className = 'Preview_LoadingSpan';
        PreviewTop.appendChild(LoadingSpan);
        $(LoadingSpan).insertAfter(MainLink);
        LoadingSpan.innerHTML = '<b>'+ showPreview_LoadingText_1 +'</b><span style="text-decoration:blink;">...</span> '
        ajaxRequest.onreadystatechange = function() {
            if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
                MainLink.innerHTML = title;
                LoadingSpan.innerHTML = '<s>'+ showPreview_LoadingText_1 +'</s> <b>'+ showPreview_LoadingText_2 +'</b><span style="text-decoration:blink;">...</span>';
                var ajaxResponse;    
                ajaxResponse = ajaxRequest.responseText;
                LoadingSpan.innerHTML = '<s>'+ showPreview_LoadingText_1 +'</s> <s>'+ showPreview_LoadingText_2 +'</s> <b>'+ showPreview_LoadingText_3 +'</b><span style="text-decoration:blink;">...</span>';

                previewWindowcontent.innerHTML = ajaxResponse ;

                LoadingSpan.innerHTML = '<s>'+ showPreview_LoadingText_1 +'</s> <s>'+ showPreview_LoadingText_2 +'</s> <s>'+ showPreview_LoadingText_3 +'</s> <b>'+ showPreview_LoadingText_4 +'</b>';


// *********************** Mise à jour du titre et des liens (cas unique de Special:Randompage)  *************************************

                if( (title.indexOf("Spécial:Page au hasard")!=-1) || (title.indexOf("Special:Randompage")!=-1) ){
                    AncienTitre = previewWindowcontent.getElementsByTagName("h1")[0]; 
                    if(AncienTitre){
                            if( (title.indexOf(AncienTitre.innerHTML)!=-1) ){
                                  AncienTitre.style.display="none";
                            }else{
                                  OtherPageLink.title = OtherPageLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  EditLink.title = EditLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));

                                  HistoryLink.title = HistoryLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(MoveLink)MoveLink.title = MoveLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(DeleteLink)DeleteLink.title = DeleteLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(ProtectLink)ProtectLink.title = ProtectLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  WatchLink.title = WatchLink.title.split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));

                                  OtherPageLink.href = decodeURIComponent(OtherPageLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  EditLink.href = decodeURIComponent(EditLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  HistoryLink.href = decodeURIComponent(HistoryLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(MoveLink)MoveLink.href = decodeURIComponent(MoveLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(DeleteLink)DeleteLink.href = decodeURIComponent(DeleteLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  if(ProtectLink)ProtectLink.href = decodeURIComponent(ProtectLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));
                                  WatchLink.href = decodeURIComponent(WatchLink.href).split(MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE")).join(encodeURIComponent(AncienTitre.innerHTML).replace(/'/g, "ZAPOSTROPHE"));

                                  MainLink.innerHTML = AncienTitre.innerHTML;
                                  MainLink.href = AdresseSite + AncienTitre.innerHTML + '#';
                                  AncienTitre.style.display="none";
                            }

                    }
                }


// ************************************* Gestion du contenu *************************************

// ---------------- Nettoyage, Sommaire, Boîtes déroulantes, Palettes de navigation et Icônes de titre

                cleanPreviewContent(previewWindowcontent);                

                if( (MainLink.innerHTML.indexOf("Special:")==-1)&&(MainLink.innerHTML.indexOf("Spécial:")==-1) ){

// ---------------- Historique amélioré et transformation des liens de la page

                    if( url.indexOf("action=history")!=-1 ){ 
                        if( url.indexOf("&gotosince=true")!=-1 ){ 
                               parseHistory('Preview_Content_'+PreviewCount, MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE") );    
                        }
                        makePreviewCompareLinks( previewWindowcontent, MainLink.innerHTML.replace(/'/g, "ZAPOSTROPHE"));
                        createPreviewButtons( previewWindowcontent); 
                    }else{
                        createPreviewLinks( previewWindowcontent); 
                    }

// ---------------- Edition améliorée 
  
                    if( url.indexOf("action=edit")!=-1 ){
                        addEditPreviewButton(window.ajaxSubmitButton, 'wpSave', ajaxSaveKey, previewWindowcontent);
                        addEditPreviewButton(window.ajaxPreviewButton, 'wpPreview', ajaxPreviewKey, previewWindowcontent);
                        addEditPreviewButton(window.ajaxDiffButton, 'wpDiff', ajaxDiffKey, previewWindowcontent);
                        previewWindowcontent.id=previewWindowcontent.id + 'EditPreviewWindowContent';
                    }

// ---------------- Affichage liens d'actions

                    OtherLinks.style.display="inline";

// ************************************* Pages spéciales *************************************
                }else{

                    var SpecialTitre = previewWindowcontent.getElementsByTagName('h1')[0];
                    SpecialTitre.style.display="none";


// ---------------- Liste de suivi améliorée 

                    if( (MainLink.innerHTML.indexOf("Special:Watchlist")!=-1 ) || (MainLink.innerHTML.indexOf("Spécial:Liste de suivi")!=-1 ) ){                
                        OptimizedPreviewSuivi(previewWindowcontent);
                    }

// ---------------- RC améliorées 

                    if( 
                     (MainLink.innerHTML.indexOf("Special:Recentchanges")!=-1 ) || (MainLink.innerHTML.indexOf("Spécial:Modifications récentes")!=-1 )
                     ||
                     (MainLink.innerHTML.indexOf("Special:Recentchangeslinked")!=-1 ) || (MainLink.innerHTML.indexOf("Spécial:Suivi des liens")!=-1 )
                    ){
                        OptimizedPreviewRC(previewWindowcontent);
                    }

// ---------------- Transformation des liens de la page

                    createPreviewLinks( previewWindowcontent); 
                }



// ************************************* Mise à jour des variables globales  *************************************

                LoadingSpan.style.display = 'none';

                DecalZ = (DecalZ+5);
                PreviewCount = (PreviewCount+1);
                PreviewNumber = (PreviewNumber+1);
            }                      
        }
    }
}
 
// ################################################################################################################## GESTION DU CONTENU 

var Enrouler = '[enrouler]';
var Derouler = '[dérouler]';
var EnroulerBis = '[-]';
var DeroulerBis = '[+]';
var indexSummary = 0;
var indexNavigationBars = 10000;
var indexCollapsibleTables = 10000;

function cleanPreviewContent(element){
        if(!element){
                element = document;
                id ='firstHeading';
        }else{
                id = 'Preview_H1_'+PreviewCount; 
        }
        indexIconeDeTitre = 0;

        var newContentWrapper = element.getElementsByTagName("div");
        var div=0;
        while(div<newContentWrapper.length){
                if( 
                ($(newContentWrapper[div]).hasClass("portlet")) 
                || 
                ($(newContentWrapper[div]).hasClass("printfooter"))
                ){
                        newContentWrapper[div].style.display="none";
                }
                if (
                ($(newContentWrapper[div]).hasClass("icone_de_titre"))  // ************************************* Icônes de titre
                ){ 
                        var h1 = document.getElementById(id); 
                        if(h1){ 
                                indexIconeDeTitre++   
                                newContentWrapper[div].style.display = "block";       
                                newContentWrapper[div].style.margin = "0em";
                                if(indexIconeDeTitre==1){
                                        newContentWrapper[div].style.marginRight = "10em";
                                }else{
                                        newContentWrapper[div].style.marginRight = "1em";
                                }

                                h1.parentNode.insertBefore(newContentWrapper[div], h1);
                        }
                }
                if (
                ($(newContentWrapper[div]).hasClass("NavFrame"))  // ************************************* Boîtes déroulantes
                ){          
                    indexCollapsibleTables++;
                    NavHead =  newContentWrapper[div].firstChild;
                    var NavToggle = document.createElement("a");
                    NavToggle.className = 'NavToggle';
                    NavToggle.id = 'NavToggle' + indexCollapsibleTables;
                    NavToggle.href = 'javascript:toggleCollapsibleTables(' + indexCollapsibleTables + ');'; 
                    NavToggle.innerHTML = Enrouler;
                    newContentWrapper[div].insertBefore( NavToggle, NavHead );  
                    var Content = newContentWrapper[div].getElementsByTagName("div");
                    for( var c=0;c<Content.length; c++ ) {
                        if ($(Content[c]).hasClass("NavContent")) { 
                           Content[c].id = 'NavContent' + indexCollapsibleTables;
                        }
                    }
                    toggleCollapsibleTables(indexCollapsibleTables);
               }

                Div_Id = newContentWrapper[div].id;
                if(Div_Id){
                        if(
                        (Div_Id=="toctitle")     // ************************************* Sommaire
                        ){
                                indexSummary = (indexSummary+1);
                                newContentWrapper[div].id = 'toctitle_'+indexSummary;
                                var TitreSommaire = newContentWrapper[div].getElementsByTagName('h2')[0];
                                TitreSommaire.innerHTML = TitreSommaire.innerHTML + ' <a href="javascript:afficherSommaire(\'toc_'+indexSummary
                                +'\',\'toctitle_'+indexSummary
                                +'\', \''+TitreSommaire.innerHTML
                                +'\');" >'+DeroulerBis+'</a>';
                                var Conteneur = newContentWrapper[div].parentNode;
                                var Sommaire = Conteneur.getElementsByTagName('ul')[0];
                                Sommaire.id = 'toc_'+indexSummary;
                                Sommaire.style.display="none";
                        }
                        if(
                        (Div_Id=="globalWrapper")
                        ||
                        (Div_Id=="column-content")
                        ||
                        (Div_Id=="content")
                        ||
                        (Div_Id=="bodyContent")
                        ||
                        (Div_Id=="article")
                        ||
                        (Div_Id=="mw_main")
                        ||
                        (Div_Id=="mw_contentwrapper")
                        ||
                        (Div_Id=="mmw_content")
                        ||
                        (Div_Id=="mmw_contentholder")
                        ){
                                newContentWrapper[div].id = newContentWrapper[div].id + '_Preview_' + PreviewNumber; 
                        }
                        if(
                        (Div_Id=="siteNotice")
                        ||
                        (Div_Id=="p-personal")
                        ||
                        (Div_Id=="topbar")
                        ||
                        (Div_Id=="quickbar")
                        ||
                        (Div_Id=="column-one")
                        ||
                        (Div_Id=="mw_portlets")
                        ||
                        (Div_Id=="page-base")
                        ||
                        (Div_Id=="head-base")
                        ||
                        (Div_Id=="head")
                        ||
                        (Div_Id=="panel")
                        ||
                        (Div_Id=="footer")
                        ||
                        (Div_Id=="previewnote")
                        ){
                                newContentWrapper[div].style.display= "none";
                        }   
                }
                div++        
        }

        var Tables = element.getElementsByTagName( "table" ); 
        for ( var i = 0; i < Tables.length; i++ ) {
              if( $(Tables[i]).hasClass("collapsible") ){     // ************************************* Palettes de navigation
                     NavigationBar = Tables[i];
                     NavigationBar.id = "collapsibleTable" + indexNavigationBars ;
 
                     var Button     = document.createElement( "span" );
                     var ButtonLink = document.createElement( "a" );
                     var ButtonText = document.createTextNode( Enrouler );
 
                     Button.style.styleFloat = "right";
                     Button.style.cssFloat = "right";
                     Button.style.fontWeight = "normal";
                     Button.style.textAlign = "right";
                     Button.style.width = "6em";
 
                     ButtonLink.id = "collapseButton" + indexNavigationBars ;
                     ButtonLink.href = "javascript:collapseNavigationBar(" + indexNavigationBars + ");" ;
                     ButtonLink.appendChild( ButtonText ); 
                     Button.appendChild( ButtonLink );
 
                     var Header = NavigationBar.getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
                     if (Header) {
                            Header.insertBefore( Button, Header.firstChild );

                     }
                     if ( $( NavigationBar ).hasClass( "collapsed" ) ) collapseNavigationBar( indexNavigationBars );
                     indexNavigationBars++;
               }
        }
}

// ###################################################### FONCTIONS SUBALTERNES A LA GESTION DU CONTENU 

// -------------------------------------------- Sommaire

function afficherSommaire(IDSommaire, IdTitre, TitreInitial){
       var Sommaire = document.getElementById(IDSommaire);
       Sommaire.style.display="block";
       var Titre = document.getElementById(IdTitre).getElementsByTagName('h2')[0];
       Titre.innerHTML = TitreInitial + ' <a href="javascript:masquerSommaire(\''+IDSommaire+'\',\''+IdTitre+'\', \''+TitreInitial+'\');" >'+EnroulerBis+'</a>';
}

function masquerSommaire(IDSommaire, IdTitre, TitreInitial){
       var Sommaire = document.getElementById(IDSommaire);
       Sommaire.style.display="none";
       var Titre = document.getElementById(IdTitre).getElementsByTagName('h2')[0];
       Titre.innerHTML = TitreInitial + ' <a href="javascript:afficherSommaire(\''+IDSommaire+'\',\''+IdTitre+'\', \''+TitreInitial+'\');" >'+DeroulerBis+'</a>';
}

// -------------------------------------------- Palettes de navigation

function collapseNavigationBar( tableIndex ) {
  var Button = document.getElementById( "collapseButton" + tableIndex );
  var Table = document.getElementById( "collapsibleTable" + tableIndex );
  if ( !Table || !Button ) return false;
 
  var Rows = Table.getElementsByTagName( "tr" ); 
 
  if ( Button.firstChild.data == Enrouler ) {
    for ( var i = 1; i < Rows.length; i++ ) {
      Rows[i].style.display = "none";
    }
    Button.firstChild.data = Derouler;
  } else {
    for ( var i = 1; i < Rows.length; i++ ) {
      Rows[i].style.display = Rows[0].style.display;
    }
    Button.firstChild.data = Enrouler ;
  }
}

// -------------------------------------------- Boîtes déroulantes 


function toggleCollapsibleTables(index) {
    var NavToggle = document.getElementById("NavToggle" + index);
    var NavContent = document.getElementById("NavContent" + index);
  
    if( (!NavToggle) || (!NavContent) ) return; 
 
    var Caption = NavToggle.innerHTML;  
    if (Caption == Enrouler) {
        NavContent.style.display = 'none';
        NavToggle.innerHTML = Derouler; 
    } else if (Caption == Derouler) {
        NavContent.style.display = 'block';
        NavToggle.innerHTML = Enrouler;
    }
}

// ################################################################################################################## FONCTIONS SPECIFIQUES

// -------------------- -------------------- Liste de suivi améliorée ( "suivre/stop" + "suivi" )-------------------- 

function OptimizedPreviewSuivi(element){
        if(!element) element = document;
        var admin = (mw.config.get('wgUserGroups').indexOf("sysop") != -1);
        var allDays = element.getElementsByTagName("ul");
 
        for (i=0; i<allDays.length; i++) {
                if (allDays[i].getAttribute("class") == "special") {
 
                        var artList = allDays[i].getElementsByTagName("li");
                        for (j=0; j<artList.length; j++) {
                                var elem = artList[j];
                                var aTag = elem.getElementsByTagName("a");
                                var articleName = aTag[0].getAttribute("title");
                                var ma = articleName.match(/^Special:Log\/(.*)$/);
                                if(ma){
                                        var lien;
                                        if(ma[1] == "newusers") lien = aTag[1];
                                        else if(admin) lien = aTag[5]; // lien supplémentaire (bloquer)
                                        else lien = aTag[4];
 
                                        if(lien.className == "new") articleName = lien.title.replace(/ \(page inexistante\)$/, "");
                                        else articleName = lien.title;
                                }
  
                                var newElement = document.createElement("a");
                                newElement.href = "javascript:showPreview(\'"  
                                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'"  
                                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=unwatch\' , \'"  
                                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\' );";
                                var newText = document.createTextNode(showPreview_UnwatchText);
                                newElement.appendChild(newText);
                                newElement.className='Preview_Button'; 
 
                                var newPar = document.createTextNode(") ("); 
 
                                var Suivi = document.createElement("a");
                                Suivi.className='Preview_Button';
                                Suivi.href = "javascript:showPreview(\'"  
                                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'"    
                                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true\' , \'"   
                                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', 'watch' );";
                                Suivi.innerHTML = TextSince;
                                Suivi.title = TitleSince ;  
                                var newParSuivi = document.createTextNode(") (");  
 
                                        // séparation des cas (nouvel article, ou déjà existant)
                                if (aTag[0].childNodes[0].data == "diff") {
                                        $(newPar).insertAfter(aTag[1]); 
                                } else {
                                        $(newPar).insertAfter(aTag[0]); 
                                } 
                                $(newElement).insertAfter(newPar);
                                $(newParSuivi).insertAfter(newElement); 
                                $(Suivi).insertAfter(newParSuivi);
                        }
                }
        }
}

// -------------------- -------------------- RC améliorées ( "suivre/stop" + "suivi" )-------------------- 

function OptimizedPreviewRC(element){

        if(!element) element = document;

        var NormalLinksLi = new Array();
        var NormalLinksLiCount = 0;
        var WatchedLinksLi = new Array();
        var WatchedLinksLiCount = 0;
        var JournalLinksLi = new Array();
        var JournalLinksLiCount = 0;
   
        var admin = (mw.config.get('wgUserGroups').indexOf("sysop") != -1);
        var allDays = element.getElementsByTagName("ul");
 
// Séparation des modifications de pages et des logs

        for (i=0; i<allDays.length; i++) {
                if (allDays[i].getAttribute("class") == "special"){ 
                        var artList = allDays[i].getElementsByTagName("li");
                        for (j=0; j<artList.length; j++){
                                var HTML_Lien = artList[j].getElementsByTagName("a")[0].innerHTML;
                                if(HTML_Lien){
                                        if( (HTML_Lien == "diff") || (HTML_Lien == "hist") ){
                                                Watched=false;
                                                var WatchedLink = artList[j].getElementsByTagName("strong");
                                                for (w=0; w<WatchedLink.length; w++){
                                                        if($(WatchedLink[w]).hasClass("mw-watched"))Watched=true;
                                                }                                                                                       
                                                if(Watched){
                                                        WatchedLinksLi[WatchedLinksLiCount] = artList[j];
                                                        WatchedLinksLiCount = (WatchedLinksLiCount+1);
                                                }else{
                                                        NormalLinksLi[NormalLinksLiCount] = artList[j];
                                                        NormalLinksLiCount = (NormalLinksLiCount+1);
                                                }

                                        }else{
                                                JournalLinksLi[JournalLinksLiCount] = artList[j];
                                                JournalLinksLiCount = (JournalLinksLiCount+1);
                                        }
                                }
                        }
                }
        }

// Modifs de pages non suivies

        for (j=0; j<NormalLinksLi.length; j++){
                var elem = NormalLinksLi[j];
                var aTag = elem.getElementsByTagName("a");
                var articleName = aTag[0].getAttribute("title");

                                

                var newWatchElement = document.createElement("a");
                newWatchElement.href="javascript:showPreview(\'" 
                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=watch\' , \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\' );";
                newWatchElement.className='Preview_Button';
               
                var newWatchText = document.createTextNode(showPreview_WatchText);
                newWatchElement.appendChild(newWatchText);
                var newParWatch = document.createTextNode(") (");

                var Suivi = document.createElement("a");
                Suivi.className='Preview_Button';
                Suivi.href = "javascript:showPreview(\'" 
                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true\' , \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', 'watch' );";
                Suivi.innerHTML = TextSince;
                Suivi.title = TitleSince ;  
                var newParSuivi = document.createTextNode(") (");

                // séparation des cas (nouvel article, ou déjà existant)
                if(aTag[0].childNodes[0].data == "diff") {
                        $(newParWatch).insertAfter(aTag[1]); 
                } else if(aTag[0].childNodes[0].data == "hist"){
                        $(newParWatch).insertAfter(aTag[0]); 
                }

                if ((aTag[0].childNodes[0].data == "diff")||(aTag[0].childNodes[0].data == "hist")) { 
                        $(newWatchElement).insertAfter(newParWatch); 
                        $(newParSuivi).insertAfter(newWatchElement); 
                        $(Suivi).insertAfter(newParSuivi);
                }
        }

// Modifs de pages suivies

        for (j=0; j<WatchedLinksLi.length; j++){
                var elem = WatchedLinksLi[j];
                var aTag = elem.getElementsByTagName("a");
                var articleName = aTag[0].getAttribute("title");

                var newstopWatchElement = document.createElement("a");
                newstopWatchElement.href="javascript:showPreview(\'" 
                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=unwatch\' , \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\' );";

                newstopWatchElement.className='Preview_Button';
                newstopWatchElement.innerHTML = '<b>' + showPreview_UnwatchText + '</b>';
                var newParUnwatch = document.createTextNode(") (");

                var Suivi = document.createElement("a");
                Suivi.href = "javascript:showPreview(\'" 
                + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true\' , \'" 
                + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(articleName).replace(/'/g, "ZAPOSTROPHE") + "\', 'unwatch' );";
                Suivi.innerHTML = TextSince;
                Suivi.className='Preview_Button';
                Suivi.title = TitleSince ;  
                var newParSuivi = document.createTextNode(") (");

                // séparation des cas (nouvel article, ou déjà existant)
                if(aTag[0].childNodes[0].data == "diff") {
                        $(newParUnwatch).insertAfter(aTag[1]); 
                } else if(aTag[0].childNodes[0].data == "hist"){
                        $(newParUnwatch).insertAfter(aTag[0]); 
                }

                if ((aTag[0].childNodes[0].data == "diff")||(aTag[0].childNodes[0].data == "hist")) { 
                        $(newstopWatchElement).insertAfter(newParUnwatch);
                        $(newParSuivi).insertAfter(newstopWatchElement); 
                        $(Suivi).insertAfter(newParSuivi);
                }
        }
}

// -------------------- -------------------- Edition améliorée ( Boutons "Publier", "Prévisualiser" et "Changements en cours" supplémentaires ) -------------------- 
 
function addEditPreviewButton(name, id, akey, element){  

        if(!element) element = document.body;
        var Inputs = element.getElementsByTagName('input')
        for(i=0;i<Inputs.length;i++){
              IdInput = Inputs[i].id;
              if(IdInput==id){ 
                  var btnOld = Inputs[i];
            }
        }
        if (!btnOld){ 
            //alert('pas trouvé : ' + id );
            return; 
        }

        btn = document.createElement('input'); 
        btn.type = 'button'
        btn.onclick = ajaxPreviewClick;  
        btn.id = id + 'Live';
        if (!name){ //extract last word from standard buttons
            name = btnOld.value.split(' '); 
            name = name[name.length-1]
            name = name.substring(0,1).toUpperCase() + name.substring(1) 
        }
        btn.name = id + 'Live';
        btn.value = name;
        btn.title = btnOld.value + ' (Ajax)'
        btnOld.parentNode.insertBefore(btn, btnOld)
        btn.value = btnOld.value
        btnOld.value = '>'
        if (akey){ //reassign acces key
            if (btnOld.accessKey == akey){ 
                btnOld.accessKey = ''
                btnOld.title = btnOld.title.replace(tooltipAccessKeyRegexp, '')
            }
            btn.accessKey = akey
            btn.title += ' ['+tooltipAccessKeyPrefix+akey+']'
        }
        btn.value2 = btn.value
}

function ajaxPreviewClick(){ajaxPreviewRun(this)}
 
function ajaxPreviewRun(btn){

    function addData(name, value){
        if (!value) value = form[name] ? form[name].value : ''
        data += '--' + boundary + '\nContent-Disposition: form-data; name="'+name+'"\n\n' + value + '\n'
    }

    var form = document.editform
    var ajaxPreview = new XMLHttpRequest()
    if ( !form || !ajaxPreview) return
    var txt = form.wpTextbox1.value, action = form.action
    var el, htm;
    isSave = (btn.id=='wpSaveLive');
    isPreview = (btn.id=='wpPreviewLive');
    isDiff = (btn.id=='wpDiffLive');

    if (el=document.getElementById('wikiDiff')) el.style.display = 'none'
    if (el=document.getElementById('newarticletext')) el.style.display = 'none'
    btn.style.width = Math.max(btn.scrollWidth, btn.offsetWidth) + 'px';  btn.value = '...'
 
    if( isSave||isDiff ){

        var Preview = getElementWithId( document , "div" , "EditPreviewWindowContent" );

        if(!Preview){
            ThisPageName = encodeURIComponent( decodeURIComponent(action).split(mw.config.get('wgServer')).join('').split(mw.config.get('wgScript')).join('').split("?title=").join('').split("&action=submit").join('') );
            showPreview(ThisPageName, AdresseSite +ThisPageName.replace(/'/g, "ZAPOSTROPHE") +'&action=render' , AdresseSite + ThisPageName.replace(/'/g, "ZAPOSTROPHE") );
            Preview = document.getElementById( 'Preview_Content_' + PreviewCount );
        }
    }else{ 
        ThisPageName = encodeURIComponent( decodeURIComponent(action).split(mw.config.get('wgServer')).join('').split(mw.config.get('wgScript')).join('').split("?title=").join('').split("&action=submit").join('') );
        showPreview(ThisPageName.replace(/'/g, "ZAPOSTROPHE"), AdresseSite +ThisPageName.replace(/'/g, "ZAPOSTROPHE") +'&action=render' , AdresseSite + ThisPageName.replace(/'/g, "ZAPOSTROPHE") );
        var Preview = document.getElementById( 'Preview_Content_' + PreviewCount );
    }

    var boundary = '--------123xyz', data = ''
    if (isDiff){
        addData('wpDiff', '');
        addData('wpStarttime');
        addData('wpEdittime')
        addData('wpTextbox1', txt);
        addData('wpSection'); 
        addData('wpSummary');
        if (!window.ajaxPreview_CSS) ajaxPreview_CSS = importStylesheetURI('/skins-1.5/common/diff.css') 
    }else if(isSave){
        addData('wpTextbox1', txt);
        addData('wpSection'); 
        addData('wpSummary');
        addData('wpStarttime');
        addData('wpEdittime');
        addData('wpEditToken');
 
    }else{
        action += '&live'
        if (form.wpSection && form.wpSection.value) txt += '\n<br /><references />'
        addData('wpTextbox1', txt);
        addData('wpSection'); 
        addData('wpSummary');
    } 

    ajaxPreview.open('POST', action, true)
    ajaxPreview.setRequestHeader('Content-Type', 'multipart/form-data; boundary='+boundary)
    ajaxPreview.send(data + '--' + boundary)
    ajaxPreview.onreadystatechange = function(){
        if (ajaxPreview.readyState != 4) return;
        Preview.innerHTML = ajaxPreview.responseText.replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"').replace(/&/g,'&').replace(/'/g,"'");
        //alert('après');
        btn.value = btn.value2
        btn.blur();

        if(isDiff){
            var TableDiff = Preview.getElementsByTagName("div");
            div=0;
            while(div<TableDiff.length){
                if( ($(TableDiff[div]).hasClass("portlet")) || ($(TableDiff[div]).hasClass("printfooter")) ){
                    TableDiff[div].style.display="none";
                }
                Div_Id = TableDiff[div].id;
                if((Div_Id=="catlinks")||(Div_Id=="footer")){
                    TableDiff[div].style.display= "none"; 
                }
                if((Div_Id!="wikiDiff")){
                    TableDiff[div].id = '';                      
                }else{
                    TableDiff[div].id = 'preview_wikiDiff';  
                }
                div++
            }
            if( (mw.config.get('wgAction')=="edit")||(mw.config.get('wgAction')=="submit") ){

                var ThisForm = getElementWithId( Preview , "form" , "editform" );
                if(ThisForm){
                    supprimerAncienElement(ThisForm);
                }
            }else{
                addEditPreviewButton(window.ajaxSubmitButton, 'wpSave', ajaxSaveKey, Preview);
                addEditPreviewButton(window.ajaxPreviewButton, 'wpPreview', ajaxPreviewKey, Preview);
                addEditPreviewButton(window.ajaxDiffButton, 'wpDiff', ajaxDiffKey, Preview);
            }
        }else{
           clearPreviewContent(Preview);
           createPreviewLinks(Preview);

            if(isSave){
                Preview.id=Preview.id.split('EditPreviewWindowContent').join('');
                PreviewEdit = false;
            }
        }
    }
}

// -------------------- -------------------- Historique amélioré ( "comparer les versions sélectionnées" + "suivi" )-------------------- 

var HistoryCount = 0;
function makePreviewCompareLinks(element, title ){
        if(!element) element=document;
        if(!title) title = mw.config.get('wgPageName');
        title = decodeURIComponent(title).replace(/ZAPOSTROPHE/g, "'");

        var ThisForm = getElementWithId( element , "form" , "mw-history-compare" );
        if(ThisForm){
                ThisForm.id = 'mw-history-compare' + HistoryCount;
                HistoryCount = (HistoryCount+1);
                var Buttons = ThisForm.getElementsByTagName('div');
                for(a=0;a<Buttons.length;a++){
                        ButtonTitle = Buttons[a].firstChild.title;
                        ButtonHTML = Buttons[a].firstChild.value;
                        Buttons[a].innerHTML= '<b><a class="Preview_Button" href="javascript:doCompare(\'' + ThisForm.id + '\',\''+ encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") +'\');" title="'+ButtonTitle+'" >'+ButtonHTML+'</a></b>';

                        Buttons[a].innerHTML += ' - ';

                        Buttons[a].innerHTML += '<b><a class="Preview_Button" href=\"'
                                             +  'javascript:parseHistory(\'' + ThisForm.id + '\', \'' + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + '\')'
                                             +  '\" title=\"' + TitleSince +'\" >' +  TextSince + '</a></b>'; 

                }
        }
}

function doCompare(id, title ){
        title = decodeURIComponent(title).replace(/ZAPOSTROPHE/g, "'");
        var Diff = '';
        var Oldid = '';
        var history=document.getElementById(id);
        var Buttons = history.getElementsByTagName('input');
        for(i=0;i<Buttons.length;i++){
                var ButtonType = Buttons[i].type;
                if( (ButtonType=="radio")&&(Buttons[i].checked) ){
                        var ButtonValue = Buttons[i].value; 
                        var ButtonName = Buttons[i].name; 
                        if(ButtonName=="diff"){
                                Diff = ButtonValue;
                        }else if(ButtonName=="oldid"){
                                Oldid = ButtonValue;
                        }
                }
        }
        var Href = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + '&diff=' + Diff + '&oldid=' + Oldid;
        var Url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + '&diff=' + Diff + '&oldid=' + Oldid + '&action=render';
        showPreview(title.replace(/'/g, "ZAPOSTROPHE"), Url, Href);
}

function parseHistory( id , title){
       
       title = decodeURIComponent(title).replace(/ZAPOSTROPHE/g, "'");

       var Page = document.getElementById(id);

       var PageHistory = getElementWithId( Page , "ul" , "pagehistory" );
       if(PageHistory){
              msg = PageHistory.firstChild;
              if(msg.id!="ParseMessages" + id) {
                     msg=document.createElement("p");
                     msg.id = "ParseMessages" + id;

                     var RestartLink = document.createElement('a');
                     RestartLink.href = "javascript:parseHistory(\'" + id + "\', \'" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
                     RestartLink.title = TitleAgain;             
                     RestartLink.innerHTML = TextAgain;              
                     var Separator = document.createElement('br');    
                     var msgWait = document.createElement('span');          
                     msgWait.className="error";
                     msgWait.appendChild(document.createTextNode(HistoryWait));
                     msg.appendChild(msgWait); 
                     msg.appendChild(Separator); 
                     msg.appendChild(RestartLink);  
                     PageHistory.insertBefore(msg, PageHistory.firstChild);
              }

              var hists=PageHistory.getElementsByTagName('li');
              for (n=0;n<hists.length;n++) {
                     var histLinks = hists[n].getElementsByTagName('a');
                     for(l=0;l<histLinks.length;l++){
                            if( $(histLinks[l]).hasClass("mw-userlink") ){
                                   var UserName = histLinks[l].innerHTML;   
                                   if (UserName==mw.config.get('wgUserName')) {                                          
                                          var  DiffHref = hists[n].getElementsByTagName('a')[0].href;
                                          showPreview(encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE"), encodeURIComponent(DiffHref).replace(/'/g, "ZAPOSTROPHE") + '&action=render', AdresseSite + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE"));
                                          return;
                                   }
                            }
                     }
              }
              msg.innerHTML='<span class="error" >'+TitleMore+'</span><br/>';
              msg.appendChild(document.createTextNode( TextLimits));
              msg.appendChild(document.createTextNode(" ("));
              var lookharder1000 = document.createElement("a");
              lookharder1000.href = "javascript:showPreview(\'" 
              + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
              +  mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true&limit=1000\' , \'" 
              + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
              lookharder1000.innerHTML = '1.000';
              msg.appendChild(lookharder1000);

              msg.appendChild(document.createTextNode(") ("));
 
              lookharder2500 = document.createElement("a");
              lookharder2500.href = "javascript:showPreview(\'" 
              + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
              +  mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true&limit=2500\' , \'" 
              + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
              lookharder2500.innerHTML = '2.500';
              msg.appendChild(lookharder2500);

              msg.appendChild(document.createTextNode(") ("));

              lookharder5000 = document.createElement("a");
              lookharder5000.href = "javascript:showPreview(\'" 
              + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
              +  mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true&limit=5000\' , \'" 
              + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
              lookharder5000.innerHTML = '5.000';
              msg.appendChild(lookharder5000);

              msg.appendChild(document.createTextNode(") ("));
       
              lookharder10000 = document.createElement("a");
              lookharder10000.href = "javascript:showPreview(\'" 
              + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\', \'" 
              +  mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "&action=history&gotosince=true&limit=10000\' , \'" 
              + mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + encodeURIComponent(title).replace(/'/g, "ZAPOSTROPHE") + "\');";
              lookharder10000.innerHTML = '10.000';
              msg.appendChild(lookharder10000);
              msg.appendChild(document.createTextNode(")"));
       }   
}



//</nowiki></syntaxhighlight>
// {{Boîte déroulante fin}}