میڈیاویکی:Gadget-LiveRC.js

/*
 ------------------------------------------------------------------------------
 -----LLLL---------III--------------------------RRRRRRRRRR--------CCCCC--------
 -----LLLL---------III--------------------------RRRRRRRRRRRR----CCCCCCCCC------
 -----LLLL--------------------------------------RRR------RRR---CCC-----CCC-----
 -----LLLL---------III--VV-----VV--EEEEEEEEE----RRR------RRR--CCC--------------
 -----LLLL---------III---VV---VV---EEE----------RRRRRRRRRRR---CCC--------------
 -----LLLL---------III---VV---VV---EEEEEE-------RRRRRRRRRR----CCC--------------
 -----LLLL---------III----VV-VV----EEEEEE-------RRR-----RRR----CCC-----CCC-----
 -----LLLLLLLLLLL--III----VVVVV----EEE----------RRR------RRR----CCCCCCCCC------
 -----LLLLLLLLLLL--III-----VVV-----EEEEEEEEE----RRR-------RRR-----CCCCC--------
 ------------------------------------------------------------------------------

 Licence : ...?
 Documentation : :fr:Wikipédia:LiveRC/Documentation
 Auteur : :fr:User:EDUCA33E
 Développement et maintenance :
 :fr:User:TiChou,
 :pl:User:Leafnode,
 :it:User:Jalo,
 :fr:User:Nakor,
 :fr:User:Arkanosis,
 :pl:User:Nux,
 :fr:User:Argos42,
 :fr:User:Orlodrim,
 :fr:User:Dr Brains

 Code source 

 Variables globales 

 */

if(typeof(LiveRC_PageTitle)=="undefined") LiveRC_PageTitle = "منصوبہ:LiveRC";
if(typeof(LiveRC_MessagesPage)=="undefined")  LiveRC_MessagesPage = "MediaWiki:Gadget-LiveRCMessages.js";

var LiveRC_Version = "0.5.0";

if (wgPageName == LiveRC_PageTitle && (wgAction=="view"||wgAction=="purge")) {

/* 

 Variables d'état (pour test sur rc.state) 

 */

  // Comments test table (regexp format);
  // ////////////////////////////////////
  var commenttests = [
    { state: "BLANKING"  , regex: /صفحه را خالی کرد/ },
    { state: "REPLACED"  , regex: /افزودن فضای خالی زیاد/ },
    { state: "COPYRIGHT" , regex: '/مطالب زیاد ویکی‌سازی نشده وارده‌شده است./' },
    { state: "REVERT" , regex: /(LiveRC : )?انجام داده بود واگردانده شد|انجام داده بود واگردانده شد|خنثی‌سازی ویرایش/ }
  ];

  // Categories test table (regexp format);
  var categoriestests = [
    { state: "LOCK"      , regex: 'صفحه‌های نیمه حفاظت‌شده' },
    { state: "FULLLOCK"  , regex: 'محافظت‌شده' },
    { state: "ADQ"       , regex: 'مقاله‌های برگزیده $' },
    { state: "BA"        , regex: 'مقاله‌های خوب $' },
    { state: "APDQ"      , regex: 'Article potentiellement (bon|de qualité)' },
    { state: "STUB"      , regex: 'مقاله‌های خرد' },
    { state: "COPYRIGHT" , regex: 'مقاله‌های با حق تکثیر مشکوک' },
    { state: "PAS"       , regex: 'مقاله‌های نامزد حذف سریع' }
  ];

/* 

 Paramètres 

 */

  var lrcParams = {
    "PreviewHeight"       : '250px', // ارتفاع پیش فرض پنجره پیش نمایش است ؛
    "HistoryHeight"       : '250px', // ارتفاع به طور پیش فرض  تاریخچه پیش نمایش.
    "GoogleHeight"        : '250px', // ارتفاع پیش فرض پنجره جستجوی گوگل.
    "TchatHeight"         : '150px', // ارتفاع پیش فرض پنجره های چت.
    "TZ"                  : '+03:30',      // منطقه زمانی (+02:00, 02:00, -0200, -05:45, ...)
    "RCLimit"             : 50,      // بیشترین تعداد ردیف جدول تغییرات زنده؛
    "Refresh"             : 10,      // زمان رفرش
    "ReloadList"          : 600,     // تاخیر در به روز کردن گروه کاربری و اتولاگین‌ها
    "GoogleSearchLimit"   : 100,     // تعداد نتایج جستجو گوگل
    "ArticleLengthLimit"  : 0,       // محدودیت تعداد کلمات نمایشی مقالات پیش‌نمایش
    "UserLengthLimit"     : 0,       // محدودیت نمایش  حروف اسم کاربری 
    "AutoCloseDiff"       : false,   // حذف ردیف بعد از مشاهده تغییرات
    "WLAllChanges"        : true,    // نمایش تغییرات انجام شده در فهرست پیگیری
    "BoldComments"        : false,   // توضیحات با فونت بولد
    "RvMinorEdit"         : false,   // مشخص کردن واگردانی تغییرات جزئی
    "LoadWatchlist"       : true,    // بارگیری فهرستی از کاربرها و آیتم‌ها در ابتدا (برای شروع زمان‌بر هست)
    "LoadIPCat"           : true,    // بارگیری رده کاربرها و اتولاگ‌ها (برای شروع زمان‌بر هست)
    "LoadCatAndTemplates" : true,    // بارگیری رده و نوع مقالات  (برای شروع زمان‌بر هست)
    "BypassWatchdefault"  : true,    // عدم نمایش تغییرات فهرست پیگیری
    "AddExtensionCustom"  : false,   // اجازه نصب افزونه ‌های دیگر
    "InvertUpdate"        : false,   // تغییر جهیت نمایش تغییرات زنده
    "KeepAllLines"        : false,   // نگهداری همه خطوط تغییرات زنده
    "DisplayDebug"        : false,   // نماش صفحه رفع اشکال
    "PreloadLines"        : true     // بارگیری صفحه بعد با استفاده از دکمه بعدی
  }

  // Valeurs par défaut du menu d'option

  var lrcOptionMenuValues = {
    "Tchat"   : false,        // Case "Tchat"
    "Preview" : false,        // Case "Prévisualiser"
    "Lists"   : false,        // Case "Listes" cochée
    "Stop"    : false,        // Case "Pause" cochée
    "Diff"    : false,        // Case "Diff réduit" cochée
    "RC"      : true,         // Case "RC" cochée
    "Log"     : false,        // Case "Journaux" cochée :
    "Filter"  : false,        // Case "Filtres"
    "RCType"  : "IPNEW",      // Sélecteur "Utilisateurs" : "RESTMODE", "IPONLY", "IPNEW", "ALLUSERS" ou "ALLNBOTS"
    "RCns"    : 999           // Sélecteur "Espaces" : false ou espace de noms
  }

/* 

 Textes 

 */

  // Wiki specific translation;
  // /////////////////////
  var lang_category       = 'زمرہ:';
  var lang_main_namespace = 'اصل';
  var lang_sandbox        = "منصوبہ:ریتخانہ";

  // Menu translation;
  // /////////////////
  var lang_menu = {
    PAUSE    : "توقف",
    PREVIEW  : "نمائش",
    LISTS    : "فہارست",
    LOWDIFF  : "جزوی تبدیلیاں",
    RCLABEL  : "حالیہ تبدیلیاں",
    NOBOTS   : "ممنوع روبہ جات",
    RESTMODE : "صارف در فہرست زیر نظر",
    IPONLY   : "فقط دستور شبکی",
    IPNEW    : "دستور شبکی + جدید صارف",
    ALLUSERS : "جملہ",
    ALLNBOTS : "جملہ+روبہ جات",
    NAMESP   : "فضائے نام",
    XTIMES   : "وقت",
    UNDORC   : "منسوخ",
    REVERT   : "استرجع",
    REASON   : "وجہ",
    USERMSG  : "پیغام برائے صارف",
    EMPTY    : "اطلاع برائے صارف",
    TAG      : "برچسب به بالای مقاله",
    LOGSHOW  : "نمائش خودکار نوشتہ",
    ABSHOW   : "Abuse filter",
    NEXTDIFF : "اگلی تبدیلیاں",
    TCHAT    : "گپ"
  };

  var lang_tooltips = {
    // main menu
    HIDE_ALL:             "خالی‌کردن فهرست",
    HIDE_REVIEWED:        "مخفی‌کردن بازبینی شده‌ها",
    HIDE_REVERTS:         "مخفی‌کردن واگردانی",
    HIDE_NEW:             "مخفی‌کردن صفحه‌های نو",
    HIDE_BLANKING:        "مخفی‌کردن خالی‌سازی",
    HIDE_THIS:            "مخفی‌",
    // links in rows
    DIFF_TIP:             "تبدیلیاں",
    DIFF_SHORT:           "تب",
    HIST_TIP:             "تاریخچہ",
    HIST_SHORT:           "تا",
    EDIT_TIP:             "ترمیم",
    EDIT_SHORT:           "م",
    MOVE_TIP:             "منتقلی",
    MOVE_SHORT:           "من",
    DEL_TIP:              "حذف شدگی",
    DEL_SHORT:            "ح",
    PROTECT_TIP:          "محفوظ شدگی",
    PROTECT_SHORT:        "مح",
    SUBJECT_TIP:          "صفحہ",
    SUBJECT_SHORT:        "ص",
    TALK_TIP:             "تبادلۂ خیال",
    TALK_SHORT:           "ت",
    CONTRIB_TIP:          "شراکتیں",
    CONTRIB_SHORT:        "ش",
    BLOCK_TIP:            "پابندی",
    BLOCK_SHORT:          "پ",
    USER_HIDE_TIP:        "چھپائیں",
    USER_HIDE_SHORT:      "چھ",
    NEWSECTION_TIP:       "نیا موضوع",
    NEWSECTION_SHORT:     "+",
    DELETEDCONTRIB_TIP:   "حذف شدہ شراکت",
    DELETEDCONTRIB_SHORT: "+",
    REVISIONDELETE_TIP:   "اخفاء ترمیم",
    REVISIONDELETE_SHORT: "اخفاء",
    WHATLINKSHERE_TIP:    "رابطہ از",
    WHATLINKSHERE_SHORT:  "↩",
    WATCH_TIP:            "زیرنظر",
    WATCH_SHORT:          "زیرنظر",
    UNWATCH_TIP:          "زیرنظر منسوخ",
    UNWATCH_SHORT:        "
م۔زیر
",
    ASKSYSOP_SHORT:       "سوال از منتظم",
    ASKSYSOP_TIP:         "سوال از منتظمین",
    // other
    WORKING:              "جاری۔۔۔",
    GOOGLE_TIP:           "تلاش در گوگل",
    GOOGLE_SHORT:         "گوگل",
    GOOGLE_CLOSE_TIP:     "گوگل بند",
    GOOGLE_CLOSE_SHORT:   "بند"
  }

  var lang_messages = {
    NEW_VERSION      : ' <span class="error"></span>',
    ALREADY_RUNNING  : ' <span class="error">راست حالیہ تبدیلیاں جاری ہیں۔</span>',
    SAME_EDITOR      : 'یکساں تدوین کار',
    WARNING          : 'پیغام',
    ON_ARTICLE       : 'بر مضمون',
    SANDBOX          : 'یہ صفحہ مشق وتمرین کے لیے مخصوص ہے',
    NOEXIST          : '<center><span class="error">ایہ صفحہ موجود نہیں ہے</span> $1 بن گیا؟ $2</center>',
    FILTER           : 'نام تصفیہ',
    WATCHLISTON      :'اضافہ در زیرنظر',
    WATCHLISTOFF     :'حذف از زیرنظر',
    REVISIONDELETEOK : "حذف شدگی",
    SPEEDDELETION    : 'سرعتی حذف شدگی',
    BLOCKED          : 'ممنوع',
    RESUMESTART      : '[[منصوبہ:LiveRC]] : ',
    BLOCKAVERTO      : 'اطلاع پابندی',
    BLOCKTEMPLATE    : 'پابندی',
    UPDATEMESSAGES   : 'تجدید پیغامات',
    CLOCKTITLE       : 'توقف/شروع مجدد l\'ساعت',
    SHOWLiveRC       : 'راست تبدیلیاں دکھائیں',
    HIDELiveRC       : 'راست تبدیلیاں چھپائیں'
  };

/* 

 خالی‌کردن، هشدار، بازگردانی 

 */
  // Avertissement
  var lstAvert = [
    { template: "امتحان"           , string: "امتحان"      , hasPage: true  },
    { template: "خرابکاری"             , string: "آشکاری"        , hasPage: true  },
    { template: "خرابکاری۱"     , string: "چرندیات"      , hasPage: true  },
    { template: "خرابکاری۲"            , string: "خالی کردن"   , hasPage: true }
  ];

  // Blanchiment
  var lstBlank = [
    {tooltip: "copyvio"      , resume: "[[WP:COPY|copie de site web sans autorisation explicite]]" },
    {tooltip: "CAA"          , resume: "[[WP:CAA|critères d\'admissibilité non atteints]]"         },
    {tooltip: "non encyclo"  , resume: "[[WP:P|non encyclopédique en l\'état]]"                    },
    {tooltip: "BaS"          , resume: "bac à sable"                                               },
    {tooltip: "vandalisme"   , resume: "تخریب کاری"                                                }
  ];

  // Révocation
  var lrcRevertMessages = [
    { resume: "[[وپ:تمرین]]" , text: "صفحهٔ تمرین" },
    { resume: "[[وپ:خرابکاری]]"   , text: "خرابکاری"  },
    { resume: "بازگردانی مطالب بدون منبع"    , text: "بدون منبع"  },
    { resume: "ترجمه ماشینی"                , text: "ترجمه ماشینی"   }
  ];

  // برچسب
  var lstTag = [
    { template: "میان‌ویکی-نیاز" , string: "میان‌ویکی-نیاز" , withDate: false },
    { template: "رده-نیاز"         , string: "رده-نیاز"       , withDate: false },
    { template: "مختصات-نیاز"                , string: "مختصات-نیاز"     , withDate: false },
    { template: "ادغامت"               , string: "ادغامت"    , withDate: false },
    { template: "تمیزکاری"             , string: "تمیزکاری"  , withDate: false },
    { template: "لحن"           , string: "لحن"            , withDate: false }
  ];

/* 

 مدیران 

 */

    var lstAskForSysop = [
        {  userright:"delete",
           text:"تام",
           page:"ویکی‌پدیا:تابلوی اعلانات مدیران",
           template:"ویکی‌پدیا:LiveRC/الگو/هشدار حذف",
           parampage:true,
           paramuser:false,
           reasonsdropdownname:"deletereason-dropdown"
        },
        {  userright:"block",
           text:"Blocage",
           page:"Wikipédia:Vandalisme en cours",
           template:"Wikipédia:LiveRC/Modèles/Demande de blocage",
           parampage:false,
           paramuser:true,
           reasonsdropdownname:"ipbreason-dropdown"
        }
    ];

/* 

 رده‌ها 

 */

  // user categories for highlighting
  var watchCategories = [
    { category: "رده:آی‌پی مدرسه", image: "ScolarIP" }
  ];

/* 

 آیکون‌ها 

 */

  // Default icons
  var lrcIcon = new Array();
  lrcIcon["Nocat"] = '<sup style="color:crimson">(بدون زمرہ)</sup>';
  lrcIcon["Noportal"] = '<sup style="color:LightBlue">(بدون باب؟)</sup>';
  lrcIcon["NbRevoc"] = '<sup style="color:red">($1 واگردانی <a href="javascript:;" onClick="حذف واگردانی ($2)" title="صفر کردن شماره واگردانی">-</a>)</sup>';
  lrcIcon["Tag"] = '<br /><span style="color: red; font-weight: bold;">چسپاں : $1$2</span>';
  lrcIcon["Recent"] = '<img '
                    + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/1/19/Ambox_currentevent.svg/16px-Ambox_currentevent.svg.png" '
                    + 'width="16px" title="حالیہ تبدیلیاں" alt="حالیہ" />';
  lrcIcon["Homon"] = '<img '
                   + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/7/72/Disambig.svg/16px-Disambig.svg.png" '
                   + 'width="16px" title="ضد ابہام" alt="ضد ابہام" />';
  lrcIcon["Stub"] = '<img '
                   + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Construction_cone.png/12px-Construction_cone.png" '
                   + 'width="12px" title="نامکمل" alt="نامکمل" />';
  lrcIcon["FullLock"] = '<img '
                      + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/4/48/Padlock-red.svg/16px-Padlock-red.svg.png" '
                      + 'width="16px" title="محفوظ" alt="محفوظ"/>';
  lrcIcon["Lock"] = '<img '
                  + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Padlock-gold.svg/16px-Padlock-gold.svg.png" '
                  + 'width="16px" title="نیم محفوظ" alt="نیم محفوظ"/>';
  lrcIcon["Copyright"] = '<img '
                       + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Copyright.svg/16px-Copyright.svg.png" '
                       + 'width="16px" title="مشکوک بوجہ حقوق نسخہ کی خلاف ورزی" alt="حقوق نسخہ" />';
  lrcIcon["PaS"] = '<img '
                 + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cestino_pieno_architetto_01.svg/11px-Cestino_pieno_architetto_01.svg.png" '
                 + 'height="11px" title="پیشنهاد حذف" alt="پیشنهاد حذف" />';
  lrcIcon["AdQ"] = '<sup><img '
                 + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Fairytale_bookmark_gold.png/10px-Fairytale_bookmark_gold.png" '
                 + 'width="10px" title="مقاله برگزیده" alt="مقاله برگزیده" /></sup>';
  lrcIcon["BA"] = '<sup><img '
                + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Fairytale_bookmark_silver_light.png/10px-Fairytale_bookmark_silver_light.png" '
                + 'width="10px" title="مقاله خوب" alt="مقاله خوب" /></sup>';
  lrcIcon["APDQ"] = '<sup><img '
                  + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Fairytale_bookmark_light.png/10px-Fairytale_bookmark_light.png" '
                  + 'width="10px" title="مقاله بسیار خوب" alt="مقاله بسیار خوب" />';
  lrcIcon["Move"] = '<img '
                  + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/0/0e/Forward.png/16px-Forward.png" '
                  + 'width="16px" title="انتقال" alt="انتقال" />';
  lrcIcon["Redirect"] = '<img '
                      + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Redirectltr.png/20px-Redirectltr.png" '
                      + 'width="20px" title="تغییرمسیر" alt="تغییرمسیر" />';
  lrcIcon["Upload"] = '<img '
                    + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/4/47/Gartoon-Gnome-dev-floppy.png/16px-Gartoon-Gnome-dev-floppy.png" '
                    + 'width="16px" title="بارگذاری" alt="بارگذاری" />';
  lrcIcon["NewUser"] = '<img '
                     + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Crystal_personal.png/16px-Crystal_personal.png" '
                     + 'width="16px" title="کاربر جدید" alt="کاربر جدید" />';
  lrcIcon["Block"] = '<img '
                   + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/6/64/Crystal_Clear_action_lock3.png/16px-Crystal_Clear_action_lock3.png" '
                   + 'width="16px" title="بستن" alt="بستن" />';
  lrcIcon["Delete"] = '<img '
                    + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Editcut.png/16px-Editcut.png" '
                    + 'width="16px" title="حذف" alt="حذف" />';
  lrcIcon["Protect"] = '<img '
                     + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/7/72/Crystal_Clear_app_agent.png/16px-Crystal_Clear_app_agent.png" '
                     + 'width="16px" title="محافظت" alt="محافظت" />';
  lrcIcon["Bot"] = '<img '
                 + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Nuvola_apps_kservices.png/16px-Nuvola_apps_kservices.png" '
                 + 'width="16px" title="ربات" alt="ربات" />';
  lrcIcon["Sysop"] = '<img '
                   + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Broom_icon.svg/16px-Broom_icon.svg.png" '
                   + 'width="16px" title="منتظم" alt="منتظم" />';
  lrcIcon["Revert"] = '<img '
                    + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Redo.png/16px-Redo.png" '
                    + 'width="16px" title="واگردانی" alt="واگردانی" />';
  lrcIcon["TOR"] = '<img '
                 + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Dialog-warning.svg/16px-Dialog-warning.svg.png" '
                 + 'width="16px" title="پروکسی‌باز" alt="پروکسی‌باز" />';
  lrcIcon["Blocked"] = '<img '
                     + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b8/Modern_clock_chris_kemps_01_with_Octagon-warning.svg/16px-Modern_clock_chris_kemps_01_with_Octagon-warning.svg.png"'
                     + ' title="کاربر تازه بسته شده" width="16px" alt="بسته‌شده" />';
  lrcIcon["Replaced"] = '<img '
                      + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/9/95/Categorie_III.svg/10px-Categorie_III.svg.png" '
                      + 'width="10px" title="اطلاع" alt="اطلاع"/>';
  lrcIcon["SharedIP"] = '<img '
                      + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b7/WLM_logo.svg/16px-WLM_logo.svg.png" '
                      + 'width="16px" title="آی‌پی مشترک" alt="آی‌پی مشترک"/>';
  lrcIcon["ScolarIP"] = '<img '
                      + 'src=//upload.wikimedia.org/wikipedia/commons/thumb/9/98/Crystal_kdmconfig.png/16px-Crystal_kdmconfig.png '
                      + 'width="16px" title="آی‌پی مدرسه" alt="آی‌پی مدرسه"/>';
  lrcIcon["CopyrightUser"] = '<img '
                           + 'src="//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Copyright.svg/16px-Copyright.svg.png" '
                           + 'width="16px" title="کاربر ناقض حق تکثیر" alt="کاربر ناقض حق تکثیر"/>';

/* 

 تنظیمات مدیریت ابزار

 */

  // متن‌ها
  var lrcManageParamsText = {
    "ButtonText": '<img src="//upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Icon_tools.svg/20px-Icon_tools.svg.png" width="20" height="20" alt="ترتیبات" />',
    "ButtonTitle": "تغییر تنظیمات",
    "LegendTitle": 'تغییر تنظیمات <sup><a href="//ur.wikipedia.org/wiki/منصوبہ:LiveRC/Documentation#Configuration" target="_blank" title="کمک">?</a></sup>',
    "VariableLegend": "متغییرها",
    "ExtensionLegend": "افزونه‌ها",
    "MessagesLegend" : "پیام‌های سیستمی",
    "OK": "تایید",
    "Cancel": "لغو",
    "RAZ": "پیش‌فرض",
    "Continue": "ادامه؟",
    "Comment": "سفارشی‌سازی تغییرات زنده",
    "EditRunning": "ویرایش صفحه <b>$1</b> در حال انجام<span style=\"text-decoration:blink;\">…</span>",
    "SaveRunning": "ذخیره صفحه <b>$1</b> در حال انجام<span style=\"text-decoration:blink;\">…</span>",
    "SaveDone": "ذخیره صفحه <b>$1</b> انجام شد.",
    "SaveRefresh": '<span class="error">کاشه مرورگر خود را خالی نمایید</span>'
  }
  var LiveRC_ParamComment = "//END PARAMS\n";
  var LiveRC_ExtensionSetupComment = "//EXTENSIONS SETUP : ";
  var LiveRC_Params = new Array();
    // Définitions
  var lrcManageParams_Desc = {
// منو پارامترها
 'DesclrcParams': new Array('پارامترها', 'پارامترها'),
 'DesclrcOptionMenuValues': new Array('جزئیات منو دستور', 'جزئیات'),
 'DesclstBlank': new Array('خلاصه خالی کردن صفحه', 'خالی کردن صفحه'),
 'DesclrcRevertMessages': new Array('خلاصه خنثی سازی', 'خنثی سازی'),
 'DesclstAvert': new Array('الگوی هشدار', 'هشدار'),
 'DesclstTag': new Array('الگوی نوارها', 'نوارها'),
 'DesclstAskForSysop': new Array('الگوی درخواست از مدیران', 'درخواست مدیریتی'),
 'DesclrcIcon': new Array('آیکون', 'آیکون'),
 'Desclang_menu': new Array('متن فهرست دستور', 'متن ۱'),
 'Desclang_tooltips': new Array('متن پیوندها', 'متن ۲'),
 'Desclang_messages': new Array('متن پیام‌های متفاوت', 'متن ۳'),
 'DesclrcManageParamsText': new Array('متن فهرست مدیریت گزینه ها', 'متن ۴'),
 'DesclrcManageParams_Desc': new Array('توضیح متغیرها', 'متن ۵'),
 'DescContactListLegend': new Array('فهرست افراد در تماس', 'افراد در تماس'),
 'DescExtensionsLegend': new Array('نصب افزونه‌ها', 'افزونه‌ها'),
// پارامترها
 'DescPreviewHeight': new Array('بلندی پنجره پیش‌نمایش', 'پنجره پیش‌نمایش'),
 'DescHistoryHeight': new Array('ارتفاع\'تاریخچه پی نمایش', 'پنجره تاریخچه'),
 'DescGoogleHeight': new Array('ارتفاع پنجره گوگل', 'پنجره گوگل'),
 'DescTchatHeight': new Array('بلندی پنجره گفتگو', 'پنجره گفتگو'),
 'DescTZ': new Array('منطقه زمانی', 'منطقه زمانی'),
 'DescRCLimit': new Array('مرز خطوط تغییرات اخیر', 'مرز خطوط تغییرات اخیر'),
 'DescRefresh': new Array('زمان تازه‌سازی تغییرات اخیر', 'زمان تازه‌سازی تغییرات اخیر'),
 'DescReloadList': new Array('دیرکرد در رفرش فهرست پی‌گیری‌ها', 'دیرکرد در رفرش فهرست پی‌گیری‌ها'),
 'ReloadList': new Array('به روز کردن فهرست پی‌گیری‌ها، بسته شدن‌ها و رده ها', 'به روز کردن فهرست پی‌گیری‌ها، بسته‌شدن‌ها و رده‌ها'),
 'DescGoogleSearchLimit': new Array('محدود کردن نتایج گوگل', 'محدود کردن نتایج گوگل'),
 'DescArticleLengthLimit': new Array('محدود کردن طول نام صفحه', 'محدود کردن طول نام صفحه'),
 'DescUserLengthLimit': new Array('محدود کردن طول نام کاربر', 'محدود کردن طول نام کاربر'),
 'DescAutoCloseDiff': new Array('حذف یک خط پس از نمایش تفاوت', 'حذف خط نمایش داده شده'),
 'DescWLAllChanges': new Array('نمایش تغییرات رخ داده در فهرست پی‌گیری‌ها', ' فهرست پی‌گیری‌ها'),
 'DescBoldComments': new Array('توضیح درباره بازداری ویرایش', 'توضیح درباره بازداری ویرایش'),
 'DescRvMinorEdit': new Array('خنثی سازی‌ها را کوچکتر نمایش بده', 'خنثی سازی‌ها را کوچکتر نمایش بده'),
 'DescLoadWatchlist': new Array('بارگذاری فهرست مقاله‌ها و پی‌گیری‌های کاربران (نخست مهم‌ترها)', 'بارگذاری فهرست مقاله‌ها و پی‌گیری‌های کاربران (نخست مهم‌ترها)'),
 'DescLoadIPCat': new Array('فهرست رده‌های کاربران و بسته‌شدن‌های روزانه (نخست مهم‌ترها)', 'فهرست رده‌های کاربران و بسته‌شدن‌های روزانه (نخست مهم‌ترها)'),
 'DescLoadCatAndTemplates': new Array('بارگذاری رده‌ها و الگوی مقاله‌ها (بسیار مهم‌ها)', 'بارگذاری رده‌ها و الگوی مقاله‌ها (بسیار مهم‌ها)'),
 'DescBypassWatchdefault': new Array('به صورت خودکار صفحه‌های ویرایش شده را در فهرست پی‌گیری‌ها قرار نده', 'به صورت خودکار صفحه‌های ویرایش شده را در فهرست پی‌گیری‌ها قرار نده'),
 'DescAddExtensionCustom': new Array('امکان شخصی‌یازی منو افرونه ها', 'امکان شخصی‌یازی منو افرونه ها'),
 'DescInvertUpdate': new Array('تغییر جهت صفحه', 'تغییر جهت صفحه'),
 'DescKeepAllLines': new Array('نگهداری همه خطوط', 'نگهداری همه خطوط'),
 'DescDisplayDebug': new Array('نمایش تابلوی اشکال‌یابی', 'اشکال نرم‌افزاری'),
 'DescPreloadLines': new Array('پیش‌نمایش تغییرات', 'پیش‌نمایش تغییرات'),
// تنظیمات
 'DescStop': new Array('حالت "توقف"', 'حالت "توقف"'),
 'DescDiff': new Array('حالت "تغییرات"', 'حالت "تغییرات"'),
 'DescPreview': new Array('حالت "پیش‌نمایش"', 'حالت "پیش‌نمایش"'),
 'DescTchat': new Array('حالت "گفتگو"', 'حالت "گفتگو"'),
 'DescLists': new Array('حالت "فهرست‌ها"', 'حالت "فهرست‌ها""'),
 'DescRC': new Array('حالت "تغییرات اخیر"', 'حالت "تغییرات اخیر"'),
 'DescLog': new Array('حالت "منابع"', 'حالت "منابع"'),
 'DescFilter': new Array('حالت "پالایه‌ها"', 'حالت "پالایه‌ها"'),
 'DescRCType': new Array('انتخاب‌کننده"کاربران"', 'انتخاب‌کننده"کاربران"'),
 'DescRCns': new Array('انتخاب‌کننده"فضاها"', 'انتخاب‌کننده"فضاها"'),
// آیکن‌ها
 "DescNocat": new Array("صفحه رده‌بندی نشده","فاقد رده"),
 "DescNoportal": new Array("بدون نوار درگاه","بدون درگاه"),
 "DescNbRevoc": new Array("شمار خنثی‌سازی‌ها","شمار خنثی‌سازی‌ها"),
 "DescTag": new Array("راه‌انداختن پالایه","پالایه"),
 "DescStub": new Array("برخط","برخط"),
 "DescRecent": new Array("رویدادهای اخیر","رویدادهای اخیر"),
 "DescHomon": new Array("ابهام‌زدایی", "ابهام زدایی"),
 "DescFullLock": new Array("مقاله محافظت شده","مقاله محافظت شده"),
 "DescLock": new Array("مقاله نیمه محافظت شده","مقاله نیمه محافظت شده"),
 "DescCopyright": new Array("مقاله مشکوک به نقض حق تکثیر","حق تکثیر"),
 "DescPaS": new Array("پیشنهاد حذف", "حذف سریع"),
 "DescAdQ": new Array("مقاله برگزیده", "نوشتار برگزیده"),
 "DescBA": new Array("مقاله خوب","مقاله خوب"),
 "DescAPDQ": new Array("مقاله دارای قابلیت خوب","مقاله دارای قابلیت خوب"),
 "DescMove": new Array("تغییر نام","تغییر نام"),
 "DescRedirect": new Array("تغییر مسیر دادن","تغییر مسیر"),
 "DescUpload": new Array("بارگذاری", "بارگذاری"),
 "DescNewUser": new Array("کاربر جدید","کاربر جدید"),
 "DescBlock": new Array("بستن","بستن"),
 "DescProtect": new Array("محافظت","محافظت"),
 "DescBot": new Array("ربات","ربات"),
 "DescSysop": new Array("مدیر","مدیر"),
 "DescRevert": new Array("واگردانی","واگردانی"),
 "DescTOR": new Array("TOR","TOR"),
 "DescBlocked": new Array("کاربری که اخیرا بسته شده","بسته شده"),
 "DescReplaced": new Array("اخطار","اخطار"),
 "DescSharedIP": new Array("آی‌پی مشترک","آی‌پی مشترک"),
 "DescScolarIP": new Array("آی‌پی مدرسه","آی‌پی مدرسه"),
 "DescCopyrightUser": new Array("کاربر ناقض یک حق مالکیت","ناقض حق مالکیت"),
// افزونه‌ها
 "DesclrcExtensions": new Array("منو افزونه‌ها", "افزونه‌ها"),
// Textes 1
 "DescPAUSE": new Array("توقف","توقف"),
 "DescPREVIEW": new Array("پیش‌نمایش","پیش‌نمایش"),
 "DescLISTS": new Array("فهرست‌ها","فهرست‌ها"),
 "DescLOWDIFF": new Array("تفاوت کاهش یافته","تفاوت کاهش یافته"),
 "DescRCLABEL": new Array("تغییرات اخیر","تغییرات اخیر"),
 "DescNOBOTS": new Array("بدون ربات‌ها","بدون ربات‌ها"),
 "DescRESTMODE": new Array("پیگیری شده","پیگیری شده"),
 "DescIPONLY": new Array("فقط آی‌پی","فقط آی‌پی"),
 "DescIPNEW": new Array("آی‌پی‌ها+کاربران جدید","آی‌پی‌ها+کاربران جدید"),
 "DescALLUSERS": new Array("همه","همه"),
 "DescALLNBOTS": new Array("همه+ربات‌ها","همه+ربات‌ها"),
 "DescNAMESP": new Array("فضا","فضا"),
 "DescXTIMES": new Array("زمان","زمان"),
 "DescUNDORC": new Array("خنثی‌سازی","خنثی‌سازی"),
 "DescREVERT": new Array("بازگردانی","بازگردانی"),
 "DescREASON": new Array("الگو","الگو"),
 "DescUSERMSG": new Array("هشدار","هشدار"),
 "DescEMPTY": new Array("خالی کردن صفحه","خالی‌سازی"),
 "DescTAG": new Array("بالا","بالا"),
 "DescLOGSHOW": new Array("روزنامه", "روزنامه"),
 "DescABSHOW": new Array("فیلتر الکترونیکی", "فیلتر الکترونیکی"),
 "DescNEXTDIFF": new Array("بعدی","بعدی"),
 "DescTCHAT": new Array("پیام‌رسان فوری", "پیام‌رسان فوری"),
// Textes 2
 "DescHIDE_ALL":new Array("راهنما: پیوند برای حذف تمام خط ها","راهنما: پیوند برای حذف تمام خط ها"),
 "DescHIDE_REVIEWED":new Array("راهنما: پیوند برای حذف تمام خط‌های ویرایش‌های به نمایش درآمده","راهنما: پیوند برای حذف تمام خط‌های ویرایش‌های به نمایش درآمده"),
 "DescHIDE_REVERTS":new Array("راهنما: پیوند به لغو یک ردیف","راهنما: پیوند به لغو یک ردیف"),
 "DescHIDE_NEW":new Array("راهنما: پیوند برای حذف خط‌های ایجاد صفحه","راهنما: پیوند برای حذف خط‌های ایجاد صفحه"),
 "DescHIDE_BLANKING":new Array("راهنما: پیوند برای حذف خط‌های خالی کردن صفحه","راهنما: پیوند برای حذف خط‌های خالی کردن صفحه"),
 "DescHIDE_THIS":new Array("راهنما: پیوند برای حذف این خط","راهنما: پیوند برای حذف این خط"),
 "DescDIFF_TIP":new Array("راهنما: پیوند به تفاوت ها","راهنما: پیوند به تفاوت ها"),
 "DescDIFF_SHORT":new Array("متن پیوند به تفاوت ها","متن پیوند به تفاوت‌ها"),
 "DescHIST_TIP":new Array("راهنما: پیوند به تاریخچه","راهنما: پیوند به تاریخچه"),
 "DescHIST_SHORT":new Array("متن پیوند به تاریخچه","متن پیوند به تاریخچه"),
 "DescEDIT_TIP":new Array("راهنما: پیوند برای ویرایش","راهنما: پیوند برای ویرایش"),
 "DescEDIT_SHORT":new Array("متن پیوند برای ویرایش","متن پیوند برای ویرایش"),
 "DescMOVE_TIP":new Array("راهنما: پیوند برای تغییر نام","راهنما: پیوند برای تغییر نام"),
 "DescMOVE_SHORT":new Array("متن پیوند برای تغییر نام","متن پیوند برای تغییر نام"),
 "DescDEL_TIP":new Array("راهنما: پیوند برای حذف","راهنما: پیوند برای حذف"),
 "DescDEL_SHORT":new Array("متن پیوند برای حذف","متن پیوند برای حذف"),
 "DescPROTECT_TIP":new Array("راهنما: پیوند برای حفاظت","راهنما: پیوند برای حفاظت"),
 "DescPROTECT_SHORT":new Array("متن پیوند برای حفاظت","متن پیوند برای حفاظت"),
 "DescSUBJECT_TIP":new Array("راهنما: پیوند به مقاله","راهنما: پیوند به مقاله"),
 "DescSUBJECT_SHORT":new Array("متن پیوند به مقاله","متن پیوند به مقاله"),
 "DescTALK_TIP":new Array("راهنما: پیوند به صفحه بحث","راهنما: پیوند به صفحه بحث"),
 "DescTALK_SHORT":new Array("متن پیوند به صفحه بحث","متن پیوند به صفحه بحث"),
 "DescCONTRIB_TIP":new Array("راهنما: پیوند به مشارکت‌ها","راهنما: پیوند به مشارکت‌ها"),
 "DescCONTRIB_SHORT":new Array("متن پیوند به مشارکت‌ها","متن پیوند به مشارکت‌ها"),
 "DescBLOCK_TIP":new Array("راهنما: پیوند برای بسته شدن ها","راهنما: پیوند برای بسته شدن ها"),
 "DescBLOCK_SHORT":new Array("متن پیوند برای بسته شدن ها","متن پیوند برای بسته شدن‌ها"),
 "DescUSER_HIDE_TIP":new Array("راهنما: پیوند برای نادیده گرفتن یک کاربر","راهنما: پیوند برای نادیده گرفتن یک کاربر"),
 "DescUSER_HIDE_SHORT":new Array("متن پیوند برای نادیده گرفتن یک کاربر","متن پیوند برای نادیده گرفتن یک کاربر"),
 "DescNEWSECTION_TIP":new Array("راهنما: پیوند برای ویرایش یک بخش جدید","راهنما: پیوند برای ویرایش یک بخش جدید"),
 "DescNEWSECTION_SHORT":new Array("متن پیوند برای ویرایش یک بخش جدید","متن پیوند برای ویرایش یک بخش جدید"),
 "DescDELETEDCONTRIB_TIP":new Array("راهنما: پیوند به مشارکت‌های حذف شده","راهنما: پیوند به مشارکت‌های حذف شده"),
 "DescDELETEDCONTRIB_SHORT":new Array("متن پیوند به مشارکت‌های حذف شده","متن پیوند به مشارکت‌های حذف شده"),
 "DescREVISIONDELETE_TIP":new Array("راهنما: پیوند به برچسب بازبینی","راهنما: پیوند به برچسب بازبینی"),
 "DescREVISIONDELETE_SHORT":new Array("پیوند به متن بازبینی","پیوند به متن بازبینی"),
 "DescWHATLINKSHERE_TIP":new Array("راهنما: پیوند به صفحه‌های مرتبط","صفحه‌های مرتبط راهنما:"),
 "DescWHATLINKSHERE_SHORT":new Array("متن پیوند به صفحه‌های مرتبط","متن صفحه‌های مرتبط"),
 "DescASKSYSOP_TIP":new Array("راهنما: پیوند برای درخواست مدیریتی","درخواست مدیریتی راهنما:"),
 "DescASKSYSOP_SHORT":new Array("متن پیوند برای درخواست مدیریتی","درخواست مدیریتی"),
 "DescWORKING":new Array("Message \"فرایند در حال انجام\"","Message \"فرایند در حال انجام... \""),
 "DescLAST_SITUATION":new Array("Message \"آخرین وضعیت\"","Message \"آخرین وضعیت\""),
 "DescGOOGLE_TIP":new Array("راهنما: پیوند به گوگل","راهنما: پیوند به گوگل"),
 "DescGOOGLE_SHORT":new Array("متن پیوند به گوگل","متن پیوند به گوگل"),
 "DescGOOGLE_CLOSE_TIP":new Array("راهنما: پیوند برای بستن گوگل","راهنما: پیوند برای بستن گوگل"),
 "DescGOOGLE_CLOSE_SHORT":new Array("متن پیوند برای بستن گوگل","متن پیوند برای بستن گوگل"),
// Textes 3
 "DescNEW_VERSION":new Array("نسخه تازه‌تر موجود است","نسخه تازه‌تر موجود است"),
 "DescSAME_EDITOR":new Array("Message \"ویرایشگر پیشین یکسان است\"","Message \"ویرایشگر پیشین یکسان است\""),
 "DescWARNING":new Array("خلاصه ویرایش","خلاصه ویرایش"),
 "DescON_ARTICLE":new Array("Mot \"sur\"", "Mot \"sur\""),
 "DescSANDBOX":new Array("پیام در وپ:تمرین","پیام در وپ:تمرین"),
 "DescNOEXIST":new Array("متنی جایگزینی برای صفحه‌های ناموجود","متنی جایگزینی برای صفحه‌های ناموجود"),
 "DescFILTER":new Array("پیام اجرای یک سیاهه","پیام اجرای یک سیاهه"),
 "DescWATCHLISTON":new Array("Message \"به فهرست پی‌گیری‌ها افزوده شود\"","Message \"به فهرست پی‌گیری‌ها افزوده شود\""),
 "DescWATCHLISTOFF":new Array("Message \"خارج کردن از فهرست بازبینی\"", "Message \"خارج کردن از فهرست بازبینی\""),
 "DescREVISIONDELETEOK":new Array("پیام پنهان‌سازی موفقیت آمیز","پیام پنهان‌سازی موفقیت آمیز"),
 "DescSPEEDDELETION":new Array("فعال‌سازی ویرایش خلاصه","فعال‌سازی ویرایش خلاصه"),
 "DescBLOCKED":new Array("Mot \"bloqué\"", "Mot \"bloqué\""),
 "DescRESUMESTART":new Array("شروع ویرایش خلاصه","شروع ویرایش خلاصه"),
 "DescBLOCKAVERTO":new Array("خلاصه بستن ویرایش","خلاصه بستن ویرایش"),
 "DescBLOCKTEMPLATE":new Array("الگوی آگاهی از بسته شدن","الگوی آگاهی از بسته شدن"),
 "DescUPDATEMESSAGES":new Array("بروز رسانی خلاصه ویرایش","بروز رسانی خلاصه ویرایش"),
// Textes 4
 "DescButtonText":new Array("دکمه باز کردن فهرست","دکمه باز کردن فهرست"),
 "DescButtonTitle":new Array("راهنما: دکمه باز کردن فهرست","راهنما: دکمه باز کردن فهرست"),
 "DescLegendTitle":new Array("عنوان منو","عنوان منو"),
 "DescVariableLegend":new Array("Commentaire \"Variables\" dans le js","Commentaire \"Variables\" dans le js"),
 "DescExtensionLegend":new Array("Commentaire \"Extensions\" dans le js","Commentaire \"Extensions\" dans le js"),
 "DescMessagesLegend":new Array("Commentaire \"Messages système\" dans le js","Commentaire \"Messages système\" dans le js"),
 "DescOK":new Array("دکمه تایید","دکمه تایید"),
 "DescCancel":new Array("دکمه لغو","دکمه لغو"),
 "DescRAZ":new Array("دکمه بازیابی","دکمه بازیابی"),
 "DescContinue":new Array("پنجره تائید","پنجره تائید"),
 "DescComment":new Array("خلاصه ویرایش","خلاصه ویرایش"),
 "DescEditRunning":new Array("Phrase \"در حال ویرایش\"","Phrase \"در حال ویرایش\""),
 "DescSaveRunning":new Array("Phrase \"در حال ذخیره سازی\"","Phrase \"در حال ذخیره سازی\""),
 "DescSaveDone":new Array("Phrase \"ذخیره شد\"","Phrase \"ذخیره شد\""),
 "DescSaveRefresh":new Array("Phrase \"Rafraichir le cache\"", "Phrase \"Rafraichir le cache\"")
};

/* 

 Autres variables personnalisables 

 */

  var lrcRecentTemplates = new Array( "Événement à venir",
                                      "Événement en cours",
                                      "Évènement récent",
                                      "Futur aéroport",
                                      "Affaire judiciaire en cours",
                                      "Album à venir",
                                      "Avion à venir",
                                      "Bâtiment à venir",
                                      "Compétition sportive à venir",
                                      "Compétition sportive en cours",
                                      "Compétition sportive récente",
                                      "Course en direct",
                                      "Scrutin à venir",
                                      "Élection récente",
                                      "Évènements récents",
                                      "Film futur",
                                      "Jeu vidéo futur",
                                      "Match en direct",
                                      "Mort récente",
                                      "Pont en cours de construction",
                                      "Saison en cours de diffusion",
                                      "Show catch à venir",
                                      "Sport en cours",
                                      "Sport à venir",
                                      "Série télévisée en production",
                                      "Projet de transport",
                                      "Projet de transport en Île-de-France",
                                      "Projet ferroviaire",
                                      "Volcan en éruption"
                                    );

    // Preview title-bar template
  var PreviewBarTemplate = '<table width="100%" ><tr>'
                         + '<td align="right" style="vertical-align:middle">$1</td>'
                         + '<td align="left" style="vertical-align:middle">$2</td>'
                         + '</tr><tr>'
                         + '<td align="right" style="vertical-align:middle"><small>$3</small></td>'
                         + '<td align="left" style="vertical-align:middle">$4</td>'
                         + '</tr></table>';

    // Tchat
  var lrcTchatChannel = "#wikipedia-fa";

    // Extensions
  var lrcExtensions = [
    {
      "name":"UserWarningsExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/UserWarningsExtension.js",
      "desc":"افزودن آیکون به کاربرهایی که هشدار گرفتند.نمایش می‌دهد که آیا کاربر بحث دارد یا نه"
    },
    {
      "name":"MostModifiedPagesExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/MostModifiedPagesExtension.js",
      "desc":"افزودن آیکون به صفحه‌هایی که به وسیله حداقل <code>X</code> کاربر ویرایش شده‌ایند یا در مدت زمان مشخصی ویرایش شده‌اند (<code>X</code> پیش‌فرض زمان پنج دقیقه است)."
    },
    {
      "name":"LinkOnIconExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/LinkOnIconExtension.js",
      "desc":"افزودن آیکون مقاله خرد، مقاله خوب ومقاله برگزیده"
    },
    {
      "name":"EditCharactersExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/EditCharactersExtension.js",
      "desc":"بهبود صفحه ویرایشی."
    },
    {
      "name":"RunCommonJS",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/RunCommonJS.js",
      "desc":"بهبود پی‌شنمایش به کمک common.js)"

    },
    {
      "name":"HotCatsMulti",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/HotCatsMulti.js",
      "desc":"افزودن یا ویرایش یا حذف رده‌ها در هنگاه نماییش ابزار رده‌ساز"
    },
    {
      "name":"BandeauPortail",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/BandeauPortail.js",
      "desc":"افزودن برچسب درگاه با مشاهده پیش‌نمایش آنها"
    },
    {
      "name":"OnlyWatchlist",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/Watchlist.js",
      "desc":"فقط فهرست پیگیری‌های خود را مشاهده کنید "
    },
    {
      "name":"CategoryRC",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/CategoryRCExtension.js",
      "desc":"اجازه مشاهده تغییرات فقط محتویات یک تعداد رده خاص (در صورت فعال شدن این گزینه تغییرات دیگر دیده نمی‌شوند!)"
    },
    {
      "name":"OnlyNewPagesExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/OnlyNewPagesExtension.js",
      "desc":"مشاهده فقط صفحه های ساخته شده (در صورت فعال شدن این گزینه تغییرات دیگر دیده نمی‌شوند!)"
    },
    {
      "name":"PreviewAllLinksExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/PreviewAllLinksExtension.js",
      "desc":"اجازه مشاهده پیش‌نمایش پیوندهای داخلی یک صفحه"
    },
    {
      "name":"PreviewThisPageExtension",
      "url":"//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/PreviewThisPageExtension.js",
      "desc":"مشاهده صفحه هایی که شما انتخاب کرده‌اید (در صورت فعال شدن این گزینه تغییرات دیگر دیده نمی‌شوند!)"
    }
  ];

    // Messages systèmes utilisés
  var lrcNeededMessages = new Array("abusefilter-log-name",
                                    "abusefilter-action-block",
                                    "abusefilter-action-blockautopromote",
                                    "abusefilter-action-degroup",
                                    "abusefilter-action-disallow",
                                    "abusefilter-action-rangeblock",
                                    "abusefilter-action-tag",
                                    "abusefilter-action-throttle",
                                    "abusefilter-action-warn",
                                    "blocklogpage",
                                    "centralauth-log-name",
                                    "centralauth-rightslog-name",
                                    "deletereason-dropdown",
                                    "dellogpage",
                                    "disambiguationspage",
                                    "globalblocking-logpage",
                                    "hide",
                                    "importlogpage",
                                    "ipbreason-dropdown",
                                    "log",
                                    "mergelog",
                                    "movelogpage",
                                    "mycontris",
                                    "newuserlogpage",
                                    "protect-dropdown",
                                    "protect-unchain-permissions",
                                    "protectlogpage",
                                    "red-link-title",
                                    "renameuserlogpage",
                                    "revertpage",
                                    "review-logpage",
                                    "rightslog",
                                    "uploadlogpage",
                                    "whatlinkshere-filters",
                                    "whatlinkshere-hideimages",
                                    "whatlinkshere-hidelinks",
                                    "whatlinkshere-hideredirs",
                                    "whatlinkshere-hidetrans"
                                   );

/* 

 Variables non personnalisables 

 */

  var lstSysop = new Array();                           // Liste des administrateurs;
  var lstContact = new Array();                         // Liste des contacts;
  var lstRevoc = new Array();                           // Liste des utilisateurs révoqués;
  var lstHidden = new Array();                          // Liste des utilisateurs masqués;
  var lstBlocks = new Array();                          // Liste des utilisateurs récemment bloqués
  var lstUserCat = new Array();                         // Liste des catégories d'utilisateurs
  var lstSuivi = new Array();                           // Liste de suivi
  var lrcMediawikiMessages = new Array();               // Liste des messages système Mediawiki
  var lrcHomonTemplates = new Array();                  // فهرست ابهام‌زدایی
  var lrcUserRights = new Array();                      // Liste des droits de l'utilisateur
  var lrcAPIlimit = 499;                                // Limite de requête API
  var lrcAdmin = (wgUserGroups.indexOf("sysop") != -1); // Utilisateur administrateur;
  var lrcTimeout = new Array();                         // Liste des timeout
  var LiveRC_RequestError = 0;                          // Nombre de requêtes RC consécutives échoués
  var lrcClockTime = new Array();                       // Horloge de LiveRC ("H","M","S")

  var nextFreeID = 0, nextDiffNum = 0;

// Timestamps d'initialisation des RC, Log et Filtres
  var lastrcid=0,        lastlogid=0,        lastfilterid=0;
  var lastrctimestamp=1, lastletimestamp=1,  lastfiltertimestamp=1;

  // Préchargement de la prévisualisation
  var lrcLines = new Object(), lrcAllLinesSeen = true;

    //تاریخچه پیش‌نمایش‌ها
  var lrcHistory = {"Type":new Array(), "Params":new Array(), "URL":new Array(), "Text":new Array() };
  var lrcHistoryIndex = -1;
  var lrcHistoryIsOld = false;

    // Hooks;
  var lrcHooks = {
                  "AfterOptions" : new Array(),
                  "AfterPreviewDiff" : new Array(),
                  "AfterPreviewArticle" : new Array(),
                  "AfterPreviewHistory" : new Array(),
                  "AfterPreviewContribs" : new Array(),
                  "AfterPreviewDeletedContribs" : new Array(),
                  "AfterPreviewLog" : new Array(),
                  "AfterPreviewFilter" : new Array(),
                  "AfterPreviewEdit" : new Array(),
                  "AfterPreviewMove" : new Array(),
                  "AfterPreviewProtect" : new Array(),
                  "AfterPreviewDelete" : new Array(),
                  "AfterPreviewBlock" : new Array(),
                  "AfterPreviewRevisiondelete" : new Array(),
                  "AfterPreviewWhatlinkshere" : new Array(),
                  "AfterFillParamPanel" : new Array(),
                  "AfterCreateParamPanel" : new Array(),
                  "BeforeRC" : new Array(),
                  "AfterRC" : new Array()
                 };

    // Styles globaux
  mw.loader.load('//ur.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.css&action=raw&ctype=text/css', 'text/css');

    // JavaScript globaux
  mw.loader.load('//pl.wikipedia.org/w/skins/common/diff.js?90&action=raw&ctype=text/javascript');
  mw.loader.load('/w/skins/common/edit.js?283-19&action=raw&ctype=text/javascript');

    // Messages système sauvegardés
  importScript(LiveRC_MessagesPage);

    // Styles et Javascript utilisateur
  importScript('User:'+wgUserName+'/LiveRCparam.js');
  importStylesheet('User:'+wgUserName+'/LiveRCparam.css');

    // Variables obsolètes, conservées pour compatibilité avec anciennes personnalisations
  var lang_log = new Array();
  var lrcManageParamsDesc = new Array()
  var lrcManageParamsDesc = new Array()
  var lrcHotCatsVariables = new Array()
  var lrcHotCatsText = new Array()
}

/* 

 Fonctions utilitaires 

 Ajax 

 */
var wpajax = {
  initReq: function() {
    var xmlhttp;
    try {
      xmlhttp = new XMLHttpRequest();
    } catch(e) {
      try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          xmlhttp = false
        }
      }
    }
    return xmlhttp;
  },
  /* preloadReq.state
     0 : no request
     1 : pending request
     2 : pending request, the result will be used with preloadReq.bundle
         (preloadReq is locked until the request is complete)
     3 : completed request
  */
  preloadReq: {url: null, xmlhttp: null, bundle: null, state: 0},
  preload: function(url) {
    if (!lrcParams["PreloadLines"]) return;
    var plr = wpajax.preloadReq;
    if (plr.state == 2) return 0;
    var xmlhttp = wpajax.initReq();
    if (!xmlhttp) return 0;
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState != 4
          || !((plr.state == 1 || plr.state == 2) && plr.url == url)) return;
      var oldState = plr.state;
      plr.xmlhttp = xmlhttp;
      plr.state = 3;
      if (oldState == 2)
        wpajax.httpComplete(xmlhttp, plr.bundle);
    };
    plr.state = 1;
    plr.url = url;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
    return 1;
  },
  // mandatory: bundle.url
  // optional:  bundle.async
  // optional:  bundle.method
  // optional:  bundle.headers
  // optional:  bundle.data
  // optional:  bundle.onSuccess (xmlhttprequest, bundle)
  // optional:  bundle.onFailure (xmlhttprequest, bundle)
  // optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure
  http: function(bundle) {
    var plr = wpajax.preloadReq;
    if (!(bundle.method || bundle.headers || bundle.async == false || bundle.data)
        && (plr.state == 1 || plr.state == 3) && plr.url == bundle.url) {
      if (plr.state == 1) {
        plr.state = 2;
        plr.bundle = bundle;
      } else {
        wpajax.httpComplete(plr.xmlhttp, bundle);
      }
      return 2;
    }
    var xmlhttp = wpajax.initReq();
    if (!xmlhttp) return 0;
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4)
        wpajax.httpComplete(xmlhttp, bundle);
    };
    xmlhttp.open(bundle.method ? bundle.method : "GET", bundle.url, bundle.async == false ? false : true);
    if (bundle.headers) {
      for (var field in bundle.headers)
        try {
          xmlhttp.setRequestHeader(field, bundle.headers[field]);
        } catch(err) {
          //Argos42 : pour rendre LiveRC fonctionnel sur chrome
        }
    }
    xmlhttp.send(bundle.data ? bundle.data : null);
    return 1;
  },
  httpComplete: function(xmlhttp, bundle) {
    if (xmlhttp.status == 200 || xmlhttp.status == 302) {
      if (bundle.onSuccess)
        bundle.onSuccess(xmlhttp, bundle);
    } else if (bundle.onFailure) {
      bundle.onFailure(xmlhttp, bundle);
    }
  }
};

/* 

 Hook functions 

 */

// Ajout d'une fonction à un hook

function LiveRC_AddHook(Type, func){
      if(typeof(func)==="function" && lrcHooks[Type]) lrcHooks[Type].push(func);
}

// Exécution des fonctions

function LiveRC_RunHooks(Type, Params){
  var HookResult = true;
  if(typeof(lrcHooks[Type])!='undefined'){
    for(var a=0,l=lrcHooks[Type].length;a<l;a++){
      var ThisHookResult = lrcHooks[Type][a](Params);
      if(ThisHookResult===false) HookResult = false;
    }
  }
  return HookResult;
}

/* 

 Fonctions d'état 

 */

function lrcHasState(state, thisState){
    if(!state) return false;
    return (state.indexOf(thisState)!=-1);
}

function lrcAddState(state, thisState){
    if(!state) state = new Array();
    if(!lrcHasState(state, thisState)) state[(state.length)] = thisState;
    return state;
}

/* 

 Fonctions de suivi 

 */

// Ajout du bouton de suivi d'utilisateur

function LiveWatchInitButton(Req, data) {
    var Li = document.getElementById('n-liveRC');
    if(!Li) return;
    lstContact = new Array();
    var api = Req.responseXML.getElementsByTagName('api')[0];
    if (api.firstChild.nodeName == "error") return;
    var watched = false;
    var rcs = api.getElementsByTagName('watchlistraw')[0].getElementsByTagName('wr');
    watched = (rcs.length > 0 && rcs[0].getAttribute('title') == 'LiveRCWatch:' + wgTitle);
    lstContact[wgTitle] = watched;
    var Links = '<span class="watchedLink" ' + (watched ? '' : 'style="display:none;"') + '> - <a '
              + ' href="javascript:;" '
              + ' onclick="addWatch('+lrcEscapeStrHTML(wgTitle)+', false); lrcToggleWatchLink(this); return false;"'
              + ' title="Ne plus suivre ce contributeur dans LiveRC">منسوخ</a></span>'
              + '<span class="watchedLink" ' + (watched ? 'style="display:none;"' : '' ) + '> - <a '
              + ' href="javascript:;" '
              + ' onclick="addWatch('+lrcEscapeStrHTML(wgTitle)+', true); lrcToggleWatchLink(this); return false;"'
              + ' title="Suivre ce contributeur dans LiveRC">زیرنظر</a></span>';
    Li.innerHTML += Links;
}

// Basculement du bouton de suivi d'utilisateur

function lrcToggleWatchLink(WatchLink){
     var Li = WatchLink.parentNode.parentNode;
     var Spans = getElementsByClass("watchedLink", Li, "span");
     for(var a=0,l=Spans.length;a<l;a++){
          if(Spans[a].style.display == "none"){
               Spans[a].style.display = "";
          }else{
               Spans[a].style.display = "none";
          }
     }
}

// Ajout/Retrait d'un utilisateur du suivi

function addWatch(uname, add, td2id) {
  var WLitem = lstContact[uname];
  var page = 'LiveRCWatch:' + uname;
  if (!WLitem && add) {
    lstContact[uname] = {ts: 0, fromjs: false};
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=watch&title=' + encodeURIComponent(page) });
  } else if (WLitem && !add) {
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=watch&unwatch=1&title=' + encodeURIComponent(page) });
    delete lstContact[uname];
  }
  if (td2id == null) return;
  var td2 = document.getElementById(td2id);
  if (add && td2) {
    addClass(td2, "RcWatched");
  } else if(td2){
    removeClass(td2, "RcWatched");
  }
}

// Ajout du bouton de suivi de page

function LiveWatchArticle(Link, LinkType, page){
  var LinkText, LinkTitle, Action = "watch";
  if(Link.innerHTML == lang_tooltips.WATCH_TIP || Link.innerHTML == lang_tooltips.WATCH_SHORT) {
    Action = "unwatch";
    if(!lstSuivi[page]) lstSuivi[page] = "--:--";
    LinkText = (LinkType ? lang_tooltips.UNWATCH_TIP : lang_tooltips.UNWATCH_SHORT);
    LinkTitle = lang_tooltips.UNWATCH_TIP +" « "+page+" »";
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=watch&title=' + encodeURIComponent(page) });
  } else {
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=watch&unwatch=1&title=' + encodeURIComponent(page) });
    LinkText = (LinkType ? lang_tooltips.WATCH_TIP : lang_tooltips.WATCH_SHORT);
    LinkTitle = lang_tooltips.WATCH_TIP +" « "+page+" »";
    if(lstSuivi[page]) delete lstSuivi[page];
  }
  Link.title = LinkTitle;
  Link.innerHTML = LinkText;
  Link.href = Link.href.replace(/&action=.*/, "&action="+Action);
}

/* 

 Horloge 

 */

function lrcSetClocks(){
  var ClockSpanTitle = document.getElementById('ClockSpanTitle');
  if(ClockSpanTitle){
    ClockSpanTitle.className="RunningClock";
    var Link = ClockSpanTitle.parentNode;
    if(Link){
      Link.href= "javascript:lrcToggleClockState('ClockSpanTitle');";
      Link.title= lang_messages.CLOCKTITLE;
      lrcClockTimer("ClockSpanTitle");
    }
  }
}

function lrcClockTimer(ID){
  var ClockSpan = document.getElementById(ID);
  if(!ClockSpan) return;
    var Now = new Date();
    var Heures = Now.getHours();
    var Minutes = Now.getMinutes();
    var Secondes = Now.getSeconds();
    lrcClockTime["H"] = Heures;
    lrcClockTime["M"] = Minutes;
    lrcClockTime["S"] = Secondes;
  if(hasClass(ClockSpan, "RunningClock")){
    ClockSpan.innerHTML =  (Heures < 10 ? '0' : '') + Heures + ':' + (Minutes < 10 ? '0' : '') + Minutes + ':' + (Secondes<10 ? '0' : '') + Secondes;
  }
  if(lrcTimeout[("Clock_"+ID)]) clearTimeout(lrcTimeout[("Clock_"+ID)]);
  lrcTimeout[("Clock_"+ID)] = setTimeout("lrcClockTimer('"+ID+"')", 1000);
}

function lrcToggleClockState(ID){
  var ClockSpan = document.getElementById(ID);
  if(!ClockSpan) return;
  if(hasClass(ClockSpan, "RunningClock")){
    removeClass(ClockSpan, "RunningClock");
    addClass(ClockSpan, "FrozenClock");
  }else{
    removeClass(ClockSpan, "FrozenClock");
    addClass(ClockSpan, "RunningClock");
  }
}

/* 

 Positionnement 

 */

// Extraction de l'interface LiveRC

function lrcFixPosition(){
    var LiveRCContainer = document.getElementById("LiveRCContainer");
    if(!LiveRCContainer) return;
    LiveRCContainer.parentNode.removeChild(LiveRCContainer);
    document.body.insertBefore(LiveRCContainer, document.body.firstChild);

    var Next = LiveRCContainer.nextSibling;
    var OtherContainer = document.createElement('div');
    OtherContainer.id = "OtherContainer";
    while(Next){
        Next.parentNode.removeChild(Next);
        OtherContainer.appendChild(Next)
        Next = LiveRCContainer.nextSibling
    }
    document.body.appendChild(OtherContainer);
    updatePreviewWindowAttributes();
    LiveRCContainer.style.display = "";
    lrcToggleLiveRC();
}

// Mise à jour de la hauteur de la table RC

function lrcInitTableHeight(){
  var TabDiv = document.getElementById('liveRC_RCList');
  if(!TabDiv) return;
  var HauteurEcran = LiveRC_GetScreenHeight();
  var TitleTable = document.getElementById("TitleTable");
  var RCOptions = document.getElementById("livePreviewFoot");
  var Table = document.getElementById('tabRC');
  var body = document.body;
  if(hasClass(body, "LiveRCConfigDisplayed")){
    var BottomFixedElement = document.getElementById("OutFixedBottomPanel");
  }else{
    var BottomFixedElement = document.getElementById("FixedBottomPanel");
  }
  if(TitleTable && RCOptions && BottomFixedElement){
    var NewHeight = parseInt( HauteurEcran - (BottomFixedElement.offsetHeight+TitleTable.offsetHeight+RCOptions.offsetHeight+10) );
    TabDiv.style.height = (NewHeight ? NewHeight : 1 ) + "px";
    if(Table){
      var TableInnerHeight = Table.offsetHeight;
      if(TableInnerHeight>NewHeight){
        if(LiveRC_NavIsIE()){
          TabDiv.style.overflowX = "hidden";
          TabDiv.style.paddingRight = "20px";
        }
        TabDiv.style.overflowY = "scroll";
      }else{
        if(LiveRC_NavIsIE()){
          TabDiv.style.overflowX = "";
          TabDiv.style.paddingRight = "0";
        }
        TabDiv.style.overflowY = "";
      }
    }
  }
  if(lrcTimeout["InitTableHeight"]) clearTimeout(lrcTimeout["InitTableHeight"]);
  lrcTimeout["InitTableHeight"] = setTimeout("lrcInitTableHeight()",200);
}

/* 

 Zones de déplacement et redimensionnement 

 */

// Mise en place des zones

function LiveRC_setResizeZones(){
     LiveRC_SetVerticalResizeZone(document.getElementById("livePreviewTitle"),
                          new Array(document.getElementById("livePreview")),
                          document.getElementById("LiveRC_Preview")
                         );
     LiveRC_SetVerticalResizeZone(document.getElementById("FollowAnchor"),
                          new Array(document.getElementById("liveRevoc"),
                                    document.getElementById("liveContact"),
                                    document.getElementById("liveHidden"),
                                    document.getElementById("liveSuivi")
                          ),
                          document.getElementById("liveFollow")
                         );
     LiveRC_SetVerticalResizeZone(document.getElementById("LiveRCFooter_Anchor"),
                          new Array(document.getElementById("IconList")),
                          document.getElementById("LiveRCFooter")
                         );
}

// Détermination du type de navigateur

function LiveRC_NavIsIE(){
     var agt=navigator.userAgent.toLowerCase();
     var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
     return is_ie;
}

// Détermination de la hauteur de l'écran

function LiveRC_GetScreenHeight(){
     var ScreenHeight = 0;
     if( typeof( window.innerHeight ) == 'number' ) {
          ScreenHeight = parseInt(window.innerHeight);
     }else if( document.documentElement && document.documentElement.clientHeight ){
          ScreenHeight = parseInt(document.documentElement.clientHeight);
     }else if( document.body && document.body.clientHeight ){
          ScreenHeight = parseInt(document.body.clientHeight);
     }
     return ScreenHeight;
}

// Détermination de la largeur de l'écran

function LiveRC_GetScreenWidth(){
     var ScreenWidth = 0;
     if( typeof( window.innerWidth ) == 'number' ) {
          ScreenWidth = parseInt(window.innerWidth);
     }else if( document.documentElement && document.documentElement.clientWidth ){
          ScreenWidth = parseInt(document.documentElement.clientWidth);
     }else if( document.body && document.body.clientWidth ){
          ScreenWidth = parseInt(document.body.clientWidth);
     }
     return ScreenWidth;
}

// Détermination du positionnement de la souris

function LiveRC_GetMousePosition(event){
     if(LiveRC_NavIsIE()){
          var Mouse_X = parseInt( event.clientX + document.getElementsByTagName('body')[0].scrollLeft );
          var Mouse_Y = parseInt( event.clientY + document.getElementsByTagName('body')[0].scrollTop );
     }else{
          var Mouse_X = parseInt( event.clientX );
          var Mouse_Y = parseInt( event.clientY );
     }
     return {"X": Mouse_X, "Y": Mouse_Y};
}

// Mise en place d'une zone de déplacement

function LiveRC_SetMoveZone(anchorNode, elementsToMove){
     if((!anchorNode)||(!elementsToMove)) return;
     anchorNode.onmousedown=function(event) {
          if(!event) { event = window.event; }
          var PositionSouris = LiveRC_GetMousePosition(event);
          var PositionSouris_X = PositionSouris["X"];
          var PositionSouris_Y = PositionSouris["Y"];
          for(var a=0;a<elementsToMove.length;a++){
               elementsToMove[a].initialX = parseInt( PositionSouris_X - elementsToMove[a].offsetLeft);
               elementsToMove[a].initialY = parseInt( PositionSouris_Y - elementsToMove[a].offsetTop);
          }
          document.getElementsByTagName('body')[0].onmousemove = function(event) {
               if(!event) { event = window.event; }
               PositionSouris = LiveRC_GetMousePosition(event);
               PositionSouris_X = PositionSouris["X"];
               PositionSouris_Y = PositionSouris["Y"];
               for(var a=0;a<elementsToMove.length;a++){
                    var Element = elementsToMove[a];
                    if(!Element) continue;
                    var PositionGauche = parseInt( PositionSouris_X ) - Element.initialX;
                    var PositionHaut = parseInt(PositionSouris_Y ) - Element.initialY;
                    Element.style.right= PositionGauche + 'px';
                    Element.style.top = PositionHaut + 'px';
                    Element.style.left= '';
                    Element.style.bottom = '';
               }
          }
          document.getElementsByTagName('body')[0].onmouseup=function(event){
               document.getElementsByTagName('body')[0].onmousemove = null;
               document.getElementsByTagName('body')[0].onmouseup = null;
          }
     }
     anchorNode.style.cursor = "move";
}

// Mise en place d'une zone de redimensionnement vertical

function LiveRC_SetVerticalResizeZone(anchorNode, ToResizeNodes, containerNode){
     if((!anchorNode)||(!ToResizeNodes)) return;
     anchorNode.onmousedown = function(event){
          if(!event) { event = window.event; }
          var positionSouris_Y = LiveRC_GetMousePosition(event)["Y"];
          var MaxHeight = LiveRC_GetScreenHeight();
          for(var a=0;a<ToResizeNodes.length;a++){
               ToResizeNodes[a].initialHeight = parseInt( (MaxHeight-positionSouris_Y) - ToResizeNodes[a].offsetHeight );
          }
          document.getElementsByTagName('body')[0].onmousemove=function(event) {
               if(!event) { event = window.event; }
               var positionSouris_Y = LiveRC_GetMousePosition(event)["Y"];
               var MaxHeight = LiveRC_GetScreenHeight();
               var HeightLimit = false;
               for(var a=0;a<ToResizeNodes.length;a++){
                    var NewHeight = parseInt( (MaxHeight-positionSouris_Y) - ToResizeNodes[a].initialHeight );
                    if(NewHeight>MaxHeight) HeightLimit = true;
               }
               if(HeightLimit) return;
               for(var a=0;a<ToResizeNodes.length;a++){
                    var Element = ToResizeNodes[a];
                    if(!Element) continue;
                    var NewHeight = parseInt( (MaxHeight-positionSouris_Y) - Element.initialHeight );
                    NewHeight = (NewHeight>0 ? NewHeight : 1);
                    if(Element.tagName && (Element.tagName.toLowerCase()=="iframe" || Element.tagName.toLowerCase()=="img")){
                         Element.height = NewHeight;
                    }else{
                         Element.style.height = NewHeight + 'px';
                    }
               }
               lrcInitTableHeight();

          }
          document.getElementsByTagName('body')[0].onmouseup=function(event) {
               document.getElementsByTagName('body')[0].onmousemove = null;
               document.getElementsByTagName('body')[0].onmouseup = null;
          }
     }
     addClass(anchorNode, "LiveRC_MenuAnchor");
     addClass(containerNode, "LiveRC_MenuContainer");
     anchorNode.style.cursor = "n-resize";
}

// Mise en place d'une zone de redimensionnement total

function LiveRC_SetTotalResizeZone(anchorNode, elementsToResize, Container){
     if((!anchorNode)||(!elementsToResize)) return;
     anchorNode.onmousedown = function(event){
          if(!event) { event = window.event; }
          var PositionSouris = LiveRC_GetMousePosition(event);
          var PositionSouris_X = PositionSouris["X"];
          var PositionSouris_Y = PositionSouris["Y"];
          for(var a=0;a<elementsToResize.length;a++){
               elementsToResize[a].initialWidth = parseInt( PositionSouris_X - elementsToResize[a].offsetWidth );
               elementsToResize[a].initialHeight = parseInt( PositionSouris_Y - elementsToResize[a].offsetHeight );
          }
          document.getElementsByTagName('body')[0].onmousemove=function(event) {
               if(!event) { event = window.event; }
               if(Container){
                    Container.style.top = Container.offsetTop + 'px';
                    Container.style.right= Container.offsetLeft + 'px';
                    Container.style.left= '';
                    Container.style.bottom = '';
               }
               var PositionSouris = LiveRC_GetMousePosition(event);
               var PositionSouris_X = PositionSouris["X"];
               var PositionSouris_Y = PositionSouris["Y"];
               for(var a=0;a<elementsToResize.length;a++){
                    var Element = elementsToResize[a];
                    if(!Element) continue;
                    var NewWidth = parseInt( PositionSouris_X - Element.initialWidth  );
                    var NewHeight = parseInt( PositionSouris_Y - Element.initialHeight );
                    NewHeight = (NewHeight>0 ? NewHeight : 1);
                    NewWidth = (NewWidth>0 ? NewWidth : 1);
                    if(Element.tagName && (Element.tagName.toLowerCase()=="iframe" || Element.tagName.toLowerCase()=="img")){
                         Element.width  = NewWidth + 'px';
                         Element.height = NewHeight + 'px';
                    }else{
                         Element.style.width  = NewWidth + 'px';
                         Element.style.height = NewHeight + 'px';
                    }
               }
           }
          document.getElementsByTagName('body')[0].onmouseup=function(event) {
               document.getElementsByTagName('body')[0].onmousemove = null;
               document.getElementsByTagName('body')[0].onmouseup = null;
          }
     }
     anchorNode.style.cursor = "se-resize";
}

/* 

 Boutons 

 */

// Mise en place des liens

function lrcMakeButtons(){
    lrcUpdateButton("LiveRCButtonOn", false, function(){ lrcToggleLiveRC(); return false; });
    lrcUpdateButton("LiveRCButtonOff", false, function(){ lrcToggleLiveRC(); return false; });
    lrcUpdateButton("LiveRCFollowButtonOn", false, function(){ lrcToggleLiveRCButton("LiveRCLiveFollowDisplayed"); return false; });
    lrcUpdateButton("LiveRCFollowButtonOff", false, function(){ lrcToggleLiveRCButton("LiveRCLiveFollowDisplayed"); return false; });
    lrcUpdateButton("LiveRCPreviewButtonOn", false, function(){ lrcToggleLiveRCButton("LiveRCPreviewDisplayed"); return false; });
    lrcUpdateButton("LiveRCPreviewButtonOff", false, function(){ lrcToggleLiveRCButton("LiveRCPreviewDisplayed"); return false; });
    lrcUpdateButton("LiveRCFooterButtonOff", false, function(){ lrcToggleLiveRCButton("LiveRCFooterDisplayed"); return false; });
    lrcUpdateButton("LiveRCFooterButtonOn", false, function(){ lrcToggleLiveRCButton("LiveRCFooterDisplayed"); return false; })

    lrcUpdateButton("LiveRCRCTableButtonOff", false, function(){ lrcToggleLiveRCButton("LiveRCRCTableDisplayed", true); return false; });
    lrcUpdateButton("LiveRCRCTableButtonOn", false, function(){ lrcToggleLiveRCButton("LiveRCRCTableDisplayed", true); return false; })

    lrcUpdateButton("LiveRCTchatButtonOn", false, function(){ buildTchatWindow(); return false; });
    lrcUpdateButton("LiveRCTchatButtonOff", false, function(){ buildTchatWindow(); return false; });

    lrcUpdateButton("LiveRCConfigButtonOff", false, function(){ LiveRC_ManageParams_OpenMenu(); return false; });
    lrcUpdateButton("LiveRCConfigButtonOn", false, function(){ LiveRC_ManageParams_OpenMenu(); return false; });

    lrcUpdateButton("LiveRCHistoryButtonOn", false, function(){ lrcGetAllHistory(); return false; });
    lrcUpdateButton("LiveRCHistoryButtonOff", false, function(){ lrcGetAllHistory(); return false; });

    var Buttons = document.getElementById("LiveRCButtons");
    if(Buttons) Buttons.style.display = "";
    lrcToggleLiveRCButton("LiveRCRCTableDisplayed");
}

// Mise en place d'un lien

function lrcUpdateButton(ID, HREF, ONCLICK){
    var Button = document.getElementById(ID);
    if(!Button) return;
    var Link = Button.getElementsByTagName('a')[0];
    if(!Link) return;
    Link.href = (HREF ? HREF : "javascript:;");
    if(ONCLICK) Link.onclick = ONCLICK;
}

//////// Basculements de fenêtres //////

// Mode LiveRC/Normal

function lrcToggleLiveRC(){
  var IDs = new Array("liveRC_ON", "livePreviewFoot", "livePreviewFoot", "liveRC_RCList", "FixedBottomPanel");
  if(hasClass(document.body, "FixedLiveRCContainer")){
    removeClass(document.body, "FixedLiveRCContainer");
    for(var a=0,l=IDs.length;a<l;a++){
        var ThisNode = document.getElementById(IDs[a]);
        if(ThisNode) ThisNode.style.display = "none";
    }
  }else{
    addClass(document.body, "FixedLiveRCContainer");
    for(var a=0,l=IDs.length;a<l;a++){
        var ThisNode = document.getElementById(IDs[a]);
        if(ThisNode) ThisNode.style.display = "";
    }
    lrcInitTableHeight();
  }
}

// Ouverture fenêtre du bas ( prévisualisation / Listes / Footer / Historique )

function lrcToggleLiveRCButton(ClassName, nocloseall){
  if(hasClass(document.body, ClassName)){
    removeClass(document.body, ClassName);
  }else{
    if(!nocloseall) lrcCloseAll();
    addClass(document.body, ClassName);
  }
  lrcInitTableHeight();
}

// Fermeture de toutes les fenêtres (sauf Tchat)

function lrcCloseAll(){
  var ClassN = new Array("LiveRCLiveFollowDisplayed", "LiveRCFooterDisplayed", "LiveRCPreviewDisplayed", "LiveRCHistoryDisplayed");
  for(var a=0,l=ClassN.length;a<l;a++){
    removeClass(document.body, ClassN[a]);
  }
  lrcCloseHistory();
  LiveRC_ManageParams_CloseMenu();
  lrcInitTableHeight();
}

/* 

 Fenêtre de recherche Google 

 */

// Ouverture

function liveGoogleSearch(PageName){
  var OldGoogle = document.getElementById("lrcGoogleDiv");
  if(OldGoogle) return;
  var PreviewWindow = document.getElementById("livePreviewTitle");
  if(!PreviewWindow) return;
  var DivGoogle = document.createElement('div');
  DivGoogle.id = "lrcGoogleDiv";
  DivGoogle.setAttribute("style", "width:99.4%;");
  PreviewWindow.parentNode.insertBefore(DivGoogle, PreviewWindow);
  var Titlebar = document.createElement('div');
  addClass(Titlebar, "LiveRC_MenuAnchor");
  Titlebar.innerHTML = '<b>' + lang_tooltips.GOOGLE_TIP + ' : « ' + PageName + ' »'
                     + '  '
                     + '<small>'
                     + '<a href="javascript:;" title="'+lang_tooltips.GOOGLE_CLOSE_TIP+'" '
                     + 'onClick="closeGoogleSearch()">['
                     + lang_tooltips.GOOGLE_CLOSE_SHORT+']</a>'
                     + '</small></b>';
  DivGoogle.appendChild(Titlebar);
  var DivGoogleContent = document.createElement('div');
  addClass(DivGoogleContent, "LiveRC_MenuContent");
  var Iframe = document.createElement('iframe');
  Iframe.src = 'http://www.google.com/search?q=%22'+PageName.replace(/ /g, "+")+'%22&num='+lrcParams["GoogleSearchLimit"];
  Iframe.width = "99.8%";
  Iframe.height = lrcParams["GoogleHeight"];
  Iframe.setAttribute("style", "margin-right:3px");
  DivGoogleContent.appendChild(Iframe);
  DivGoogleContent.LiveRC_MenuContent.setAttribute("style", "text-align:right;");
  DivGoogle.appendChild(DivGoogleContent);
  LiveRC_SetVerticalResizeZone(Titlebar, new Array(DivGoogle, Iframe), DivGoogle);
}

// Fermeture

function closeGoogleSearch(){
  var GoogleDiv = document.getElementById("lrcGoogleDiv");
  if(GoogleDiv) GoogleDiv.parentNode.removeChild(GoogleDiv);
  lrcInitTableHeight();
}

/* 

 Fenêtre de tchat 

 */

// Création

function  buildTchatWindow(){
  var OldTchat = document.getElementById("liveTchat");
  if(OldTchat){
    toggleTchatWindow();
    return;
  }
  var TargetDiv = document.getElementById("LiveRCContainer");
  if(!TargetDiv) return;
  var DivTchat = document.createElement('div');
  DivTchat.id = "liveTchat";
  TargetDiv.appendChild(DivTchat);
  var TchatMoveAnchor = document.createElement('div');
  TchatMoveAnchor.id = "liveTchatMoveAnchor";
  addClass(TchatMoveAnchor, "LiveRC_MenuAnchor");
  TchatMoveAnchor.innerHTML = lang_menu.TCHAT;
  var TchatContent = document.createElement('div');
  TchatContent.id = "liveTchatContent";
  addClass(TchatContent, "LiveRC_MenuContent");
  var Iframe = document.createElement('iframe');
  Iframe.id = "liveTchatFrame";
  Iframe.src = "//webchat.freenode.net/?channels="+lrcTchatChannel+"&nick="+encodeURIComponent(wgUserName.replace(/ /, "_"));
  Iframe.width = "99.8%";
  Iframe.height = lrcParams["TchatHeight"];
  Iframe.setAttribute("style", "margin-left:3px");
  TchatContent.appendChild(Iframe);
  var TchatResizeAnchor = document.createElement('div');
  TchatResizeAnchor.id = "liveTchatResizeAnchor";
  addClass(TchatResizeAnchor, "LiveRC_MenuAnchor");
  DivTchat.appendChild(TchatMoveAnchor);
  DivTchat.appendChild(TchatContent);
  DivTchat.appendChild(TchatResizeAnchor);
  lrcCloseAll();
  addClass(document.body, "LiveRCTchatDisplayed");
  LiveRC_SetMoveZone(TchatMoveAnchor, new Array(DivTchat));
  LiveRC_SetTotalResizeZone(TchatResizeAnchor, new Array(DivTchat, Iframe), DivTchat);
  var HauteurEcran = LiveRC_GetScreenHeight();
  DivTchat.style.bottom = "0px";
}

// Affichage / Masquage

function toggleTchatWindow(){
    if(hasClass(document.body, "LiveRCTchatDisplayed")){
      removeClass(document.body, "LiveRCTchatDisplayed");
    }else{
      addClass(document.body, "LiveRCTchatDisplayed");
    }
}

/* 

 Fenêtre de l'historique de prévisualisation 

 */

// Création de l'historique de prévisualisation

function lrcGetAllHistory(){
  var HistoryDiv = document.getElementById("LiveRC_History");
  if(HistoryDiv){
    lrcCloseHistory();
    return;
  }
  var TargetDiv = document.getElementById("FixedBottomPanel");
  if(!TargetDiv) return;
  lrcCloseAll();
  addClass(document.body, "LiveRCHistoryDisplayed");
  var HistoryArray = new Array();
  for(var a=0,l=lrcHistory["Type"].length;a<l;a++){
    var Type = lrcHistory["Type"][a];
    var Params = lrcHistory["Params"][a];
    var URL = lrcHistory["URL"][a];
    var Text = lrcHistory["Text"][a];
    var Onclick = "lrcGetHistory("+a+"); lrcCloseHistory(); return false;";
    var Link = '<li>'+Type+' : <a href="'+URL+'" onClick="'+Onclick+'">'+Text+'</a></li>';
    if(HistoryArray.indexOf(Link)==-1) HistoryArray.push(Link);
  }
  var DivContainer = document.createElement('div');
  DivContainer.id = "LiveRC_History";
  var DivAnchor = document.createElement('div');
  DivAnchor.id = "LiveRC_HistoryAnchor";
  DivAnchor.innerHTML = "تاریخچه پیش‌نمایش‌ها";
  var DivContent = document.createElement('div');
  DivContent.id = "LiveRC_HistoryContent";
  DivContent.setAttribute("style", "height:"+lrcParams["HistoryHeight"]+";overflow-y:auto;");
  var Ol = document.createElement('ol');
  Ol.setAttribute("style", "-moz-column-count:3;-webkit-column-count:3;column-count:3");
  Ol.innerHTML = HistoryArray.join("");
  DivContent.appendChild(Ol);
  DivContainer.appendChild(DivAnchor);
  DivContainer.appendChild(DivContent);
  TargetDiv.appendChild(DivContainer);
  addClass(DivContent, "LiveRC_MenuContent");
  DivContent.LiveRC_MenuContent.setAttribute("style", "text-align:right;");
  LiveRC_SetVerticalResizeZone(document.getElementById("LiveRC_HistoryAnchor"),
                       new Array(document.getElementById("LiveRC_HistoryContent")),
                       document.getElementById("LiveRC_History")
                      );
  lrcInitTableHeight();
}

// Fermeture de l'historique de prévisualisation

function lrcCloseHistory(){
  var HistoryDiv = document.getElementById("LiveRC_History");
  if(HistoryDiv) HistoryDiv.parentNode.removeChild(HistoryDiv);
  removeClass(document.body, "LiveRCHistoryDisplayed");
  lrcInitTableHeight();
}

// Ajout d'une entrée à l'historique de prévisualisation

function lrcAddToHistory(Type, Params, URL, Text){
  lrcCloseHistory();
  lrcHistory["Type"].push(Type);
  lrcHistory["Params"].push(Params);
  lrcHistory["URL"].push(URL);
  lrcHistory["Text"].push(Text);
}

// Rechargement d'une entrée de l'historique de prévisualisation

function lrcGetHistory(index){
  lrcHistoryIsOld = true;
  var Type = lrcHistory["Type"][index];
  var Params = lrcHistory["Params"][index];
  var FuntionToEval = Type + "(" + Params.join(", ") + ");";
  //alert(FuntionToEval);
  eval(FuntionToEval);
  lrcHistory["Type"].pop();
  lrcHistory["Params"].pop();
  lrcHistory["URL"].pop();
  lrcHistory["Text"].pop();
  lrcHistoryIndex = index;
}

// Mise à jour des boutons de l'historique de prévisualisation

function buildHistoryPanel(){
  if(!lrcHistoryIsOld) lrcHistoryIndex = (lrcHistory["Type"].length-1);
  var PreviousDisabled = ((lrcHistoryIndex>0) ? '' : ' disabled="disabled" ' );
  var NextDisabled = ((lrcHistoryIndex<(lrcHistory["Type"].length-1)) ? '' : ' disabled="disabled" ' );
  var PreviousLink = '<input style="padding:0" type="button" value="⇨" ' + PreviousDisabled
                   + 'onclick="lrcGetHistory('+(lrcHistoryIndex-1)+');" onselect="lrcGetHistory(-1);" />';
  var ShowHistoryLink = '<input style="padding:0" type="button" value="?" '
                      + 'onclick="lrcGetAllHistory();" onselect="lrcGetAllHistory();" />';
  var NextLink = '<input style="padding:0" type="button" value="⇦" '+NextDisabled
               + ' onclick="lrcGetHistory('+(lrcHistoryIndex+1)+');" onselect="lrcGetHistory(1);" />';
  lrcHistoryIsOld = false;
  var historyPanel = document.getElementById("historyPanel");
  if(historyPanel) historyPanel.innerHTML = PreviousLink + ShowHistoryLink + NextLink ;
}

/* 

 Fenêtre de prévisualisation 

 */

// Mise à jour de la hauteur et du déroulé de la fenêtre de prévisualisation

function updatePreviewWindowAttributes(){
  var LP = document.getElementById( 'livePreview' );
  if(LP) LP.scrollTop = 0;
  lrcInitTableHeight();
}

// Création barre de commandes standard

function buildBlanckPreviewBar(Text, History, TextHD, TextBG, TextBD){
    var Template = PreviewBarTemplate;
    Template = Template.split('$1').join(Text);
    Template = Template.split('$2').join((TextHD ? TextHD : " "));
    Template = Template.split('$3').join((TextBG ? TextBG : " "));
    Template = Template.split('$4').join((TextBD ? TextBD : " "));
    var TabContainer = document.getElementById("livePreviewTitle");
    if(TabContainer) TabContainer.innerHTML = Template;
}

// Création barre de commandes avec liens

function buildPreviewBar(Args){
    var Mode = Args["Mode"];
    var URL  = Args["Url"];
    var Page = Args["Page"];
    var User1 = Args["User1"];
    var User2 = Args["User2"];
    var oldid = Args["Oldid"];
    var Previous = Args["Previous"];
    var Next = Args["Next"];

// $1 : case haut-gauche
    var TabsHautGauche = '<b><a href="'+URL+'" target="_new">'+Page+'</a></b>'
    if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Delete"||Mode=="Protect"||Mode=="Edit"||Mode=="Revisiondelete"){
        TabsHautGauche += '  •  '
                        + '<small><a href="'+lrcGetUglyPageURL('Special:Whatlinkshere/'+Page) + '" '
                        + 'onClick="liveWhatlinkshere('+lrcEscapeStr(Page)+'); return false;" '
                        + 'title="'+lang_tooltips.WHATLINKSHERE_TIP+' « '+Page+' »" '
                        + '>'+lang_tooltips.WHATLINKSHERE_SHORT+'</a></small>';
        TabsHautGauche += '  •  '
                        + '<small><a href="http://www.google.com/search?q=%22'+Page.replace(/ /g, "+")+'%22" '
                        + 'onClick="liveGoogleSearch('+lrcEscapeStr(Page)+'); return false;" '
                        + 'title="'+lang_tooltips.GOOGLE_TIP+'">['+lang_tooltips.GOOGLE_SHORT+']</a></small>';
    }

   if(Mode=="Revisiondelete" && Args["RevisiondeleteOK"]){
      TabsHautGauche += ' <small>'+lang_messages.REVISIONDELETEOK+'</small>';
   }

// $2 : case haut-droite
    var TabsHautDroite = "";
    if(Mode=="Diff" && lrcUserHasRight("deleterevision")){
        TabsHautDroite = buildRevisiondeleteBar(Page);
    }
    if(Mode=="Diff" && Previous){
        TabsHautDroite += '<small><a id="previousDiffLink" href="'+Previous["url"]+'" '
                        + 'onClick="liveDiff('+lrcEscapeStr(Page)+',\'prev\',\''+Previous["oldid"]+'\'); return false;" '
                        + 'title="'+Previous["title"]+'">'+Previous["text"]+'</a></small>';
    }
    if(Mode=="Diff" && Next){
        if(Previous) TabsHautDroite += '<small> | </small>';
        TabsHautDroite += '<small><a id="nextDiffLink" href="'+Next["url"]+'" '
                        + 'onClick="liveDiff('+lrcEscapeStr(Page)+',\'next\',\''+Next["oldid"]+'\'); return false;" '
                        + 'title="'+Next["title"]+'">'+Next["text"]+'</a></small>';
    }

// $3 : case bas-gauche
    var TabsBasGauche = buildPreviewNormalTabs(Args);

// $4 : case bas-droite
    var TabsBasDroite = buildPreviewSpecialTabs(Args);

// Affichage
    var Template = PreviewBarTemplate;
    Template = Template.split('$1').join(TabsHautGauche);
    Template = Template.split('$2').join(TabsHautDroite);
    Template = Template.split('$3').join(TabsBasGauche);
    Template = Template.split('$4').join(TabsBasDroite);
    var TabContainer = document.getElementById("livePreviewTitle");
    if(TabContainer) TabContainer.innerHTML = Template;
    buildHistoryPanel();
    LiveRC_RevertMessagesExtension_Init();
}

// Liens en bas à gauche

function buildPreviewNormalTabs(Args){
    var Mode = Args["Mode"];
    var URL  = Args["Url"];
    var Page = Args["Page"];
    var User1 = Args["User1"];
    var User2 = Args["User2"];
    var oldid = Args["Oldid"];
    var Next = Args["Next"];

    var ParamOldid = (Next && oldid ? "&oldid="+oldid : "");

    var PageNamespaceNumber = getNamespaceInfoFromPage(Page);
    var PageName = getNamespaceInfoFromPage(Page, "PageName");
    var escTitle = lrcEscapeStr(Page);
    var escUser = false;
    var User = User2;
    if(!User) User = User1;
    if(!User){
        if(PageNamespaceNumber==2 ||PageNamespaceNumber==3){
            User = PageName.replace(/\/.*/g, "");
        }
    }
    if(User) escUser = lrcEscapeStr(User);
    var Tabs = new Array();
// Other Page /////////////////////////////////
    if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Move"||Mode=="Delete"||Mode=="Protect"||Mode=="Edit"||Mode=="Revisiondelete"){
        if(PageNamespaceNumber%2==0){
            var OtherPageText = lang_tooltips.TALK_TIP;
            var OtherPageNamespaceNumber = (PageNamespaceNumber+1);
        }else{
            var OtherPageText = lang_tooltips.SUBJECT_TIP;
            var OtherPageNamespaceNumber = (PageNamespaceNumber-1);
        }
        var OtherPageName = (OtherPageNamespaceNumber == 0 ? PageName : wgFormattedNamespaces[OtherPageNamespaceNumber]+":"+PageName);
        Tabs["OtherPage"] = '<a href="'+lrcGetPageURL(OtherPageName)+'" '
                          + 'onClick="liveArticle('+lrcEscapeStr(OtherPageName)+'); return false;" '
                          + 'title="'+OtherPageName+'" '
                          + '>'+OtherPageText+'</a>';
    }else if(Mode=="Contrib"||Mode=="DeletedContrib"||Mode=="Block"){
        var OtherPageName = wgFormattedNamespaces[3]+":"+User;
        Tabs["OtherPage"] = '<a href="'+lrcGetPageURL(OtherPageName)+'" '
                          + 'onClick="liveArticle('+lrcEscapeStr(OtherPageName)+'); return false;" '
                          + 'title="'+OtherPageName+'" '
                          + '>'+lang_tooltips.TALK_TIP+'</a>';
    }
// Edit /////////////////////////////////
    if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Move"||Mode=="Delete"||Mode=="Protect"||Mode=="Revisiondelete"){
        Tabs["Edit"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=edit'+ParamOldid) + '" '
                     + 'onClick="liveEdit('+escTitle+', \''+ParamOldid+'\'); return false;" '
                     + 'title="'+lang_tooltips.EDIT_TIP+' « '+Page+' »" '
                     + '>'+lang_tooltips.EDIT_TIP+'</a>';

    }
// New Section /////////////////////////////////
    if(PageNamespaceNumber%2!=0){
        if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Move"||Mode=="Delete"||Mode=="Protect"||Mode=="Edit"||Mode=="Revisiondelete"){
            Tabs["NewSection"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=edit&section=new') + '" '
                               + 'onClick="liveEdit('+escTitle+',\'&section=new\'); return false;" '
                               + 'title="'+lang_tooltips.NEWSECTION_TIP+'" '
                               + '>'+lang_tooltips.NEWSECTION_TIP+'</a>';
        }
    }
// Hist /////////////////////////////////
    if(Mode=="Article"||Mode=="Diff"||Mode=="Edit"||Mode=="Move"||Mode=="Delete"||Mode=="Protect"||Mode=="Revisiondelete"){
        Tabs["Hist"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=history') + '" '
                     + 'onClick="liveHist('+escTitle+'); return false;" '
                     + 'title="'+lang_tooltips.HIST_TIP+'" '
                     + '>'+lang_tooltips.HIST_TIP+'</a>';

    }
// Move /////////////////////////////////
    if(lrcUserHasRight("move")){
        if(Mode=="Article"||Mode=="Diff"||Mode=="Edit"||Mode=="Hist"||Mode=="Delete"||Mode=="Protect"||Mode=="Revisiondelete"){
            Tabs["Move"] = '<a href="'+lrcGetPageURL('Special:Movepage/'+Page) + '" '
                         + 'onClick="liveMove('+escTitle+'); return false;" '
                         + 'title="'+lang_tooltips.MOVE_TIP+' « '+Page+' »" '
                         + '>'+lang_tooltips.MOVE_TIP+'</a>';
        }
    }
// Contrib /////////////////////////////////
    if(escUser){
        if(Mode=="Block"||Mode=="DeletedContrib"){
            Tabs["Contrib"] = '<a href="'+lrcGetPageURL('Special:Contributions/' + User)+'" '
                            + 'onClick="liveContrib('+escUser+'); return false;" '
                            + 'title="'+lang_tooltips.CONTRIB_TIP+'" '
                            + '>'+lang_tooltips.CONTRIB_TIP+'</a>';
        }
    }
// DeletedContrib /////////////////////////////////
    if(lrcUserHasRight("deletedhistory") && escUser){
        if(Mode=="Block"||Mode=="Contrib"){
            Tabs["DeletedContrib"] = '<a href="'+lrcGetPageURL('Special:DeletedContributions/'+User)+'" '
                                   + 'onClick="liveDeletedContrib('+escUser+'); return false;" '
                                   + 'title="'+lang_tooltips.DELETEDCONTRIB_TIP+'" '
                                   + '>'+lang_tooltips.DELETEDCONTRIB_TIP+'</a>';
        }
    }
// Delete /////////////////////////////////
    if(lrcUserHasRight("delete")){
        if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Move"||Mode=="Protect"||Mode=="Edit"||Mode=="Revisiondelete"){
            Tabs["Delete"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=delete') + '" '
                           + 'onClick="liveDelete('+escTitle+'); return false;" '
                           + 'title="'+lang_tooltips.DEL_TIP+' « '+Page+' »" '
                           + '>'+lang_tooltips.DEL_TIP+'</a>';
        }
    }
// Protect /////////////////////////////////
    if(lrcUserHasRight("protect")){
        if(Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Move"||Mode=="Delete"||Mode=="Edit"||Mode=="Revisiondelete"){
            Tabs["Protect"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=protect') + '" '
                            + 'onClick="liveProtect('+escTitle+'); return false;" '
                            + 'title="'+lang_tooltips.PROTECT_TIP+' « '+Page+' »" '
                            + '>' +lang_tooltips.PROTECT_TIP+'</a>';
        }
    }
// Block /////////////////////////////////
    if(lrcUserHasRight("block") && escUser){
        if(Mode=="Contrib"||Mode=="DeletedContrib"){
            Tabs["Block"] = '<a href="'+lrcGetPageURL('Special:Blockip/'+User)+'" '
                          + 'onClick="liveBlock('+escUser+'); return false;" '
                          + 'title="'+lang_tooltips.BLOCK_TIP+' « '+User+' »" '
                          + '>'+lang_tooltips.BLOCK_TIP+'</a>';
        }else if(Mode=="Article" && (PageNamespaceNumber==2 ||PageNamespaceNumber==3)){
            var ThisUser = PageName.replace(/\/.*/g, "");
            Tabs["Block"] = '<a href="'+lrcGetPageURL('Special:Blockip/'+ThisUser)+'" '
                          + 'onClick="liveBlock('+lrcEscapeStr(ThisUser)+'); return false;" '
                          + 'title="'+lang_tooltips.BLOCK_TIP+' « '+ThisUser+' »" '
                          + '>'+lang_tooltips.BLOCK_TIP+'</a>';
        }
    }
// (Un)Watch /////////////////////////////////
    if(PageNamespaceNumber>-1 && (Mode=="Article"||Mode=="Diff"||Mode=="Hist"||Mode=="Edit"||Mode=="Move"||Mode=="Delete"||Mode=="Protect"||Mode=="Revisiondelete")){
        if(lstSuivi[Page]){
            Tabs["Watch"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=unwatch') + '" '
                          + 'onClick="LiveWatchArticle(this, 1, '+escTitle+'); return false;" '
                          + 'title="'+lang_tooltips.UNWATCH_TIP+' « '+Page+' »" '
                          + '>'+lang_tooltips.UNWATCH_TIP+'</a>';

        }else{
            Tabs["Watch"] = '<a href="'+lrcGetUglyPageURL(Page,'&action=watch') + '" '
                          + 'onClick="LiveWatchArticle(this, 1, '+escTitle+'); return false;" '
                          + 'title="'+lang_tooltips.WATCH_TIP+' « '+Page+' »" '
                          + '>'+lang_tooltips.WATCH_TIP+'</a>';
        }
    }
// Ask for sysop /////////////////////////////////
    if(lrcUserHasRight("autopatrol")) Tabs["AskForSyop"] = buildAskForSysop(Page, User);

    var AllTabs = new Array();
    for(var Tab in Tabs){
        if(typeof(Tabs[Tab])=="string" && Tabs[Tab] !="") AllTabs.push(Tabs[Tab]);
    }
    AllTabs = '<ul ><li>'+AllTabs.join("</li><li>") + '</li></ul>';
    if(AllTabs=="") AllTabs = " ";
    return AllTabs;
}

// Commandes en bas à droite

function buildPreviewSpecialTabs(Args){
    if(!lrcUserHasRight("autopatrol")) return " ";
    var Mode = Args["Mode"];
    var Page = Args["Page"];
    var User1 = Args["User1"];
    var User2 = Args["User2"];
    var oldid = Args["Oldid"];
    var patrolledDiff = Args["patrolledDiff"];
    var Next = Args["Next"];
    var SpecialTabs = "";
    if(Mode=="Diff") {
        if(!Next){
            SpecialTabs += buildLiveUndo(Page, oldid, User1, User2);
        }
        SpecialTabs += (SpecialTabs==="" ? "" : ' • ') + buildLiveAverto(Page, User2, true);
    }else if(Mode=="Article"){
        SpecialTabs += buildLiveTag(Page) + ' • ' + buildLiveBlank(Page);
        var User = Args["User1"];
        var HasPageParam = true;
        var PageNamespaceNumber = getNamespaceInfoFromPage(Page);
        var PageName = getNamespaceInfoFromPage(Page, "PageName");
        if(PageNamespaceNumber==2||PageNamespaceNumber==3){
            User = PageName.replace(/\/.*/g,"");
            HasPageParam = false;
        }
        if(User) SpecialTabs += ' • ' + buildLiveAverto(Page, User, HasPageParam);
    }else if(Mode=="Contrib"||Mode=="DeletedContrib"){
        if(lrcUserHasRight("autopatrol")) SpecialTabs += buildLiveAverto(Page, User1, false);
    }
    if(SpecialTabs==="") SpecialTabs = " ";
    return SpecialTabs;
}

// Récupération du contenu de la page prévisualisée

function getPageContent(Req, ID){
  var OldTemp = document.getElementById("TempDiv");
  if(OldTemp) OldTemp.parentNode.removeChild(OldTemp);
  var Temp = document.createElement('div');
  Temp.id = "TempDiv";
  Temp.style.display = "none";
  document.body.appendChild(Temp);
  Temp.innerHTML = Req.responseText;
  var bC;
  if(ID){
    bC  = getElementWithId(ID, '*', Temp);
  }else{
    bC  = getElementWithId('bodyContent', 'div', Temp);
    if (bC ==  null) bC  = getElementWithId('article', 'div', Temp);
    if (bC ==  null) bC  = getElementWithId('mw_contentholder', 'div', Temp);
  }
  return bC;
}

// Recherche de form à partir d'un bouton

function getFormFromThisInput(Input){
     //if(!Input) return null;
     var Element = Input.parentNode;
     while(Element){
          if(Element.tagName && Element.tagName.toLowerCase() == 'form') return Element;
          Element = Element.parentNode;
     }
     return null
}

// Récupération de paramètres depuis une form

function getFormParams(Form){
     var Params = new Array();
     var Tags = new Array("textarea", "select", "input");
     for(var a=0,l=Tags.length;a<l;a++){
          var Elements = Form.getElementsByTagName(Tags[a]);
          for(var b=0,m=Elements.length;b<m;b++){
               var Element = Elements[b];
               var ElName = Element.name;
               if(!ElName) continue;
               var ElValue = Element.value;
               var ElType = Element.type;
               if(Tags[a].toLowerCase()=='input' && (ElType == "checkbox" || ElType == "radio") && Element.checked){
                    Params[ElName] = ElValue;
               }else if(Tags[a].toLowerCase()=='input' && (ElType == "text" || ElType == "hidden") ){
                    Params[ElName] = ElValue;
               }else if(Tags[a].toLowerCase()!='input'){
                    Params[ElName] = ElValue;
               }
          }
     }
     return Params;
}

/* 

 Fonctions automatiques 

 Blanchiment 

 */

// Création de la commande de blanchiment

function buildLiveBlank(Page){
    if(!Page) return "";
    var optBlank = "";
    var optl = lstBlank.length;
    for (j=0; j<optl; j++) {
        optBlank += '<option value="' + lstBlank[j].resume + '" title="' + lstBlank[j].resume + '">' + lstBlank[j].tooltip + '</option>';
    }
    var BlankBar = '<form id="LiveBlankForm">'
                 + '<input id="LiveBlankLink" type="button" title="'+lang_menu.EMPTY+' « '+Page+' »" '
                 + 'onclick="getLiveBlank('+lrcEscapeStr(Page)+'); return false;" '
                 + 'onselect="getLiveBlank('+lrcEscapeStr(Page)+'); return false;" '
                 + 'value="'+lang_menu.EMPTY+'" />'
                 + '<select id="LiveBlankReason">' + optBlank + '</select>'
                 + '</form>';
    return BlankBar;
}

// Récupération des informations et requête de page

function getLiveBlank(page){
    var BlankSelect = document.getElementById("LiveBlankReason");
    var BlankButton = document.getElementById("LiveBlankLink");
    if(!BlankSelect || !BlankButton) return;
    BlankSelect.disabled = "disabled";
    BlankButton.disabled = "disabled";
    var message = BlankSelect.value;
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+encodeURIComponent(page),
                  onSuccess: postBlankPage,
                  page: page,
                  message: message
                });
    return false;
}

// Traitement de la requête de blanchiment

function postBlankPage(xmlreq, data){
  var page=data.page;
  var message=data.message;
  var EditParam = new Array();
  var ObjetXML = xmlreq.responseXML;
  var Isprotected = false;
  var PR = ObjetXML.getElementsByTagName("pr");
  for(var a=0,l=PR.length;a<l;a++){
    var Type = PR[a].getAttribute("type");
    var Level = PR[a].getAttribute("level");
    if(Type=="edit" && wgUserGroups.indexOf(Level)==-1) Isprotected = true;
  }
  if(Isprotected){
    alert('Page protégée');
    return;
  }
  var Page = ObjetXML.getElementsByTagName("page")[0];
  EditParam["token"] = encodeURIComponent(Page.getAttribute("edittoken"));
  EditParam["text"] = "";
  EditParam["summary"] = encodeURIComponent(lang_messages.RESUMESTART+lang_messages.SPEEDDELETION+' ; ' + message);
  EditParam["title"] = encodeURIComponent(page);
  EditParam["watchlist"] = "preferences";
  if(lrcParams["BypassWatchdefault"]) EditParam["watchlist"] = "nochange";
  var Params = new Array();
  for(var Param in EditParam){
    Params.push(Param+"="+EditParam[Param]);
  }
  Params = Params.join("&");
  var headers = new Array();
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=edit',
                method: "POST", headers: headers,
                data: Params});
}

/* 

 Bandeaux 

 */

// Création de la commande d'ajout de bandeau

function buildLiveTag(Page){
    if(!Page) return "";
    var optTag = "";
    var optl = lstTag.length;
    for (j=0; j<optl; j++) {
        optTag += '<option value="' + lstTag[j].template + '" '
               + 'title="{{' + lstTag[j].template + '}}" '
               + '>' + lstTag[j].string + '</option>';
    }
    var TagBar = '<form id="LiveTagForm">'
               + '<input id="LiveTagLink" type="button" title="'+lang_menu.TAG+'" '
               + 'onclick="getLiveTag('+lrcEscapeStr(Page)+'); return false;" '
               + 'onselect="getLiveTag('+lrcEscapeStr(Page)+'); return false;" '
               + 'value="'+lang_menu.TAG+'" />'
               + '<select id="LiveTagReason">' + optTag + '</select>'
               + '</form>';
    return TagBar;
}

// Récupération des information et requête de page

function getLiveTag(page){
    var TagSelect = document.getElementById("LiveTagReason");
    var TagButton = document.getElementById("LiveTagLink");
    if(!TagSelect || !TagButton) return;
    var message = TagSelect.value;
    lrcDisableLink("LiveTagReason");
    lrcDisableLink("LiveTagLink");
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml'
                     + '&action=query&prop=info&intoken=edit'
                     + '&inprop=protection'
                     + '&titles=' + encodeURIComponent(page),
                onSuccess: postTagPage,
                page: page,
                message: message});
  return false;
}

// Traitement ajout de bandeau

function postTagPage(xmlreq, data){
  var page = data.page;
  var message = data.message;

  var EditParam = new Array();
  var ObjetXML = xmlreq.responseXML;
  var Isprotected = false;
  var PR = ObjetXML.getElementsByTagName("pr");
  for(var a=0,l=PR.length;a<l;a++){
    var Type = PR[a].getAttribute("type");
    var Level = PR[a].getAttribute("level");
    if(Type=="edit" && wgUserGroups.indexOf(Level)==-1) Isprotected = true;
  }
  if(Isprotected){
    alert('Page protégée');
    return;
  }
  var ThisDate = "";
  for(var Tag in lstTag){
    if(lstTag[Tag].template == message && lstTag[Tag].withDate){
      var entofa = new Array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹");
      var Months = new Array("ژانویه", "فوریه", "مارس", "آوریل", "می", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر");
      var Now = new Date();
      var Year = Now.getYear();
      if(Year < 2000) Year = Year + 1900;
      var Month = Months[(Now.getMonth())];
      ThisDate = "|تاریخ="+Month+" "+Year;
      for (var i = 0; i < 10; i++) {
      ThisDate = ThisDate.replace(new RegExp([i], 'g'), entofa[i]);
    }
    }
  }

  var Page = ObjetXML.getElementsByTagName("page")[0];
  EditParam["token"] = encodeURIComponent(Page.getAttribute("edittoken"));
  EditParam["prependtext"] = encodeURIComponent("{{"+message+ThisDate+"}}\n");
  EditParam["summary"] = encodeURIComponent(lang_messages.RESUMESTART + lang_messages.WARNING + ' ' + message);
  EditParam["title"] = encodeURIComponent(page);
  EditParam["watchlist"] = "preferences";
  EditParam["nocreate"] = "1";
  if(lrcParams["BypassWatchdefault"]) EditParam["watchlist"] = "nochange";

  var Params = new Array();
  for(var Param in EditParam){
    Params.push(Param+"="+EditParam[Param]);
  }
  Params = Params.join("&");
  var headers = new Array();
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=edit',
                method: "POST", headers: headers,
                data: Params});
}

/* 

 Révocation 

 */

// Création de la commande de révocation

function buildLiveUndo(Page, oldid, User1, User2){
    if(!Page || !oldid || !User1 || !User2 ) return "";
    var specialNotice = "";
    var rollbackButton = "";
    if (User1 == User2) {
        specialNotice = "<small><b style='color:red'>[" + lang_messages.SAME_EDITOR + "]</b></small> ";
        rollbackButton = '<input id="LiveRollbackLink" '
                       + 'type="button" title="'+lang_menu.REVERT+' « '+User2+' » ('+Page+')" '
                       + 'onclick="lrcUndo(' + lrcEscapeStr(Page) + ',' + lrcEscapeStr(User2) +'); return false;" '
                       + 'onselect="lrcUndo(' + lrcEscapeStr(Page) + ',' + lrcEscapeStr(User2) +'); return false;" '
                       + 'value="' + lang_menu.REVERT + '" />'
    }
    if (Page == lang_sandbox) {
        specialNotice = "<small><b style='color:red'>[" + lang_messages.SANDBOX + "]</small></b> ";
    }
    var UndoBar = '<form id="LiveUndoForm">'
                + specialNotice + rollbackButton
                + '<input id="LiveUndoLink" type="button" title="'+lang_menu.UNDORC+' « '+User2+' » ('+Page+')" '
                + 'onclick="lrcUndo(' + lrcEscapeStr(Page) + ',' + lrcEscapeStr(User2) +',' + oldid + '); return false;" '
                + 'onselect="lrcUndo(' + lrcEscapeStr(Page) + ',' + lrcEscapeStr(User2) +',' + oldid + '); return false;" '
                + 'value="' + lang_menu.UNDORC + '" />'
                + '<input id="LiveRevertMessage" value="" />'
                + '</form>';
    return UndoBar;
}

// Mise en place des suggestions de résumé de révocation

function LiveRC_RevertMessagesExtension_Init(){
    var RevertInput = document.getElementById("LiveRevertMessage");
    if(!RevertInput) return;
    var Opt = '<option selected="selected" onClick="LiveRC_RevertMessagesExtension_Update()" value=""> </option>';
    for(var a=0,l=lrcRevertMessages.length;a<l;a++){
      Opt += '<option value="'+lrcRevertMessages[a].resume+'" '
            + 'title="'+lrcRevertMessages[a].resume+'" '
            + 'onClick="LiveRC_RevertMessagesExtension_Update()" '
            + 'name="'+a+'">'+lrcRevertMessages[a].text+'</option>';
    }
    var Select = document.createElement('select');
    Select.id = "LiveRevertMessage_List";
    Select.innerHTML = Opt;
    Select.style.display = "none";
    Select.style.position = "relative" ;
    Select.style.width = RevertInput.offsetWidth + "px" ;
    Select.style.top = parseInt(RevertInput.offsetHeight) + "px";
    Select.style.marginBottom = "-" + (20 + parseInt(RevertInput.offsetHeight)) + "px" ;
    Select.style.marginRight = "-"+RevertInput.offsetWidth+"px" ;
    RevertInput.parentNode.insertBefore(Select, RevertInput.nextSibling);
    Select.onkeyup = LiveRC_RevertMessagesExtension_KeyPress;
    Select.onchange = LiveRC_RevertMessagesExtension_Update;

    RevertInput.onmouseover = LiveRC_RevertMessagesExtension_Toggle;
    RevertInput.onfocus = LiveRC_RevertMessagesExtension_Toggle;
}

// Affichage / Masquage des suggestions de résumé de révocation

function LiveRC_RevertMessagesExtension_Toggle(){
    var RevertSelect = document.getElementById("LiveRevertMessage_List");
    if(!RevertSelect) return;
    if(RevertSelect.style.display == "none"){
        RevertSelect.style.display = "inline";
    }else{
        RevertSelect.style.display = "none";
    }
}

// Sélection d'une suggestion de résumé de révocation (clavier + souris)

function LiveRC_RevertMessagesExtension_KeyPress(e){
    if (!e) var e = window.event;
    if (e.keyCode != 13) return;
    LiveRC_RevertMessagesExtension_Update();
}

function LiveRC_RevertMessagesExtension_Update(){
    var RevertInput = document.getElementById("LiveRevertMessage");
    var RevertSelect = document.getElementById("LiveRevertMessage_List");
    if(!RevertInput || !RevertSelect) return;
    var InputValue = RevertInput.value;
    if(InputValue!="") RevertInput.value += " ; ";
    var Options = RevertSelect.getElementsByTagName('option');
    for(var a=0,l=Options.length;a<l;a++){
        if(!Options[a].selected) continue;
        RevertInput.value = Options[a].value;
        RevertInput.focus();
        return;
    }
}

// Récupération des informations et requête de page

function lrcUndo(title, user, oldid) {
  var RollbackButton = document.getElementById('LiveRollbackLink');
  var UndoButton = document.getElementById('LiveUndoLink');
  var UndoMessage = document.getElementById('LiveRevertMessage');
  var UndoMessageList = document.getElementById('LiveRevertMessage_List');
  if(!UndoMessage) return;
  if(RollbackButton) RollbackButton.disabled = "disabled";
  if(UndoButton) UndoButton.disabled = "disabled";
  UndoMessage.disabled = "disabled";
  if(UndoMessageList) UndoMessageList.disabled = "disabled";
  var summary = UndoMessage.value;
  var requestHistory = wgServer + wgScriptPath + '/api.php?format=xml'
          + '&action=query&prop=revisions|info&rvlimit=10'
          + '&rvprop=user|ids&intoken=edit&titles=' + encodeURIComponent(title);
  wpajax.http({url: requestHistory, onSuccess: lrcUndoCB, title: title,
               user: user, oldid: oldid, summary: summary});
  return false;
}

// Traitement de la requête de révocation

function lrcUndoCB(xmlreq, data) {
  var page = xmlreq.responseXML.getElementsByTagName('page')[0];
  var token = page.getAttribute('edittoken');
  var lst = xmlreq.responseXML.getElementsByTagName('revisions')[0].childNodes;
  var user = data.user ? data.user : lst[0].getAttribute('user');
  var curid = lst[0].getAttribute('revid');
  var i;
  for (i = 0; i < lst.length && lst[i].getAttribute('user') == user
          && lst[i].getAttribute('revid') != data.oldid; i++) {}
  if (i == 0 || i == lst.length) return;
  var oldUser = lst[i].getAttribute('user');
  var oldid = lst[i].getAttribute('revid');
  var summary = lang_messages.RESUMESTART+lrcMediawikiMessages["revertpage"];
  summary = summary.split("$1").join(oldUser);
  summary = summary.split("$2").join(user);
  if (data.summary) summary += ' ; ' + data.summary;
  var minorEdit = lrcParams["RvMinorEdit"] ? '&minor=1' : '';
  var watchParam = lrcParams["BypassWatchdefault"] ? '&watchlist=nochange' : '&watchlist=preferences';
  var requestEditData = 'title=' + encodeURIComponent(data.title)
          + '&token=' + encodeURIComponent(token)
          + '&summary=' + encodeURIComponent(summary)
          + '&undo=' + curid + '&undoafter=' + oldid + watchParam + minorEdit
  var headers = new Array();
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
  wpajax.http({url: wgServer + wgScriptPath + '/api.php?action=edit',
               method: "POST", headers: headers, data: requestEditData});
}

/* 

 Avertissement 

 */

// Création de la commande de message utilisateur

function buildLiveAverto(Page, User, WithPage){
    if(!Page || !User) return "";
    var optAvert = "";
    var optl = lstAvert.length;
    for (j=0; j<optl; j++) {
        var Value = lstAvert[j].template;
        if(lstAvert[j].hasPage && WithPage) Value += '|1='+Page.replace(/\"/g, "");
        optAvert += '<option value="'+Value+'" ';
        optAvert += 'title="{{'+Value+'}}" '
        optAvert += '>'+lstAvert[j].string+'</option>';
    }
    var AvertoBar = '<form id="LiveAvertoForm">'
                  + '<input id="LiveAvertoLink" type="button" title="'+lang_menu.USERMSG+' « '+User+' »" '
                  + 'onclick="getLiveAverto('+lrcEscapeStr(User)+'); return false;" '
                  + 'onselect="getLiveAverto('+lrcEscapeStr(User)+'); return false;" '
                  + 'value="'+lang_menu.USERMSG+'" />'
                  + '<select id="averto">' + optAvert + '</select>'
                  + '</form>';
     return AvertoBar;
}

// Récupération des informations et requête de page

function getLiveAverto(user) {
  lrcDisableLink('LiveAvertoLink');
  lrcDisableLink('averto');
  var message = document.getElementById('averto').value;
  var summary = message.split("|1=").join("|");
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+wgFormattedNamespaces[3]+":"+user.replace(/&/g, "%26"),
                onSuccess: postLiveAverto,
                user: user, message: message, summary:summary });
  return false;
}

// Traitement de la requête de message utilisateur

function postLiveAverto(xmlreq, data) {
  var user = data.user;
  var message = data.message;
  var Summary = data.summary;
  var EditParam = new Array();
  var ObjetXML = xmlreq.responseXML;
  var Isprotected = false;
  var PR = ObjetXML.getElementsByTagName("pr");
  for(var a=0,l=PR.length;a<l;a++){
    var Type = PR[a].getAttribute("type");
    var Level = PR[a].getAttribute("level");
    if(Type=="edit" && wgUserGroups.indexOf(Level)==-1) Isprotected = true;
  }
  if(Isprotected){
    alert('Page protégée');
    return;
  }
  var Page = ObjetXML.getElementsByTagName("page")[0];
  EditParam["token"] = encodeURIComponent(Page.getAttribute("edittoken"));
  EditParam["appendtext"] = encodeURIComponent('\n\n{{subst:' + message + '}} ~~~~\n');
  EditParam["summary"] = encodeURIComponent(lang_messages.RESUMESTART + lang_messages.WARNING + ' ' + Summary.replace(new RegExp(/\|(.*)/),
    ' ' + lang_messages.ON_ARTICLE + ' [[$1]]') + ' !');
  //EditParam["recreate"] = 1;
  EditParam["title"] = wgFormattedNamespaces[3]+":"+encodeURIComponent(user);
  EditParam["watchlist"] = "preferences";
  if(lrcParams["BypassWatchdefault"]) EditParam["watchlist"] = "nochange";

  var Params = new Array();
  for(var Param in EditParam){
    Params.push(Param+"="+EditParam[Param]);
  }
  Params = Params.join("&");
  var headers = new Array();
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=edit',
                method: "POST", headers: headers,
                data: Params});
}
/* 

 Demande aux administrateurs 

 */

// Récupération des motifs standards de demande administrative

function buildAskForSysopCreateReasons(){
     for(var Ask in lstAskForSysop){
          var ThisAsk = lstAskForSysop[Ask];
          var Type = ThisAsk.userright;
          var DropType = ThisAsk.userright;
          ThisAsk.reasons = new Array();
          var Drop = lrcMediawikiMessages[ThisAsk.reasonsdropdownname];
          if(!Drop) continue;
          var Drop = Drop.split("**");
          for(var a=0,l=Drop.length;a<l;a++){
               var ThisReason = Drop[a];
               if(ThisReason.indexOf("*")!=-1) continue;
               ThisAsk.reasons.push(ThisReason);
          }
     }
}

// Création du lien de demande administrative

function buildAskForSysop(Page, User){
    var optAskSysop = new Array('<option id="null" value="" title=""></option>');
    var optl = lstAskForSysop.length;
    for (j=0; j<optl; j++) {
        if((lstAskForSysop[j].parampage && Page) || (lstAskForSysop[j].paramuser && User)){
            if(lrcUserHasRight(lstAskForSysop[j].userright)) continue;
            var NewValue = lstAskForSysop[j].template;
            if(lstAskForSysop[j].parampage && Page) NewValue += '|page='+Page.replace(/\"/g, '\\"');
            if(lstAskForSysop[j].paramuser && User) NewValue += '|user='+User.replace(/\"/g, '\\"');
            var NewOption = '<option id="'+lstAskForSysop[j].userright+'" value="'+NewValue+'" title="{{'+NewValue+'}}" '
                          + '>'+lstAskForSysop[j].text+'</option>';
            optAskSysop.push(NewOption);
        }
    }
    if(optAskSysop.length===1) return "";
    var AskForSysopBar = '<form id="AskForSysopForm">'
                       + '<a id="LiveAskForSysop" href="javascript:;" '
                       + 'title="' + lang_tooltips.ASKSYSOP_TIP + ' " '
                       + 'onClick="liveAskForSysop('+lrcEscapeStr(User)+');">'+lang_tooltips.ASKSYSOP_SHORT+'</a> : '
                       + '<select id="AskForSysop" onchange="buildAskForSysopGetReason()">' + optAskSysop.join("") + '</select>'
                       + '</form>';
     return AskForSysopBar;
}

// Création du menu de demande administrative

function buildAskForSysopGetReason(){
     var OldDropDown = document.getElementById("AskForSysopReasons");
     if(OldDropDown) OldDropDown.parentNode.removeChild(OldDropDown);
     var Select = document.getElementById("AskForSysop");
     if(!Select) return;
     var Options = Select.getElementsByTagName('option');
     for(var a=0,l=Options.length;a<l;a++){
          if(!Options[a].selected) continue;
          var ID = Options[a].id;
          if(!ID || ID==="null") continue;
          for(var Ask in lstAskForSysop){
               var Type = lstAskForSysop[Ask].userright;
               if(Type!=ID) continue;
               var Reasons = lstAskForSysop[Ask].reasons;
               if(!Reasons || Reasons.length===0) continue;
               var NewSelect = document.createElement('select');
               NewSelect.id = "AskForSysopReasons";
               NewSelect.setAttribute("style", "width:100px");
               var Opt = document.createElement('option');
               Opt.value = "";
               Opt.innerHTML = "";
               NewSelect.appendChild(Opt);
               for(var b=0,m=Reasons.length;b<m;b++){
                    var Opt = document.createElement('option');
                    Opt.value = Reasons[b];
                    Opt.innerHTML = Reasons[b];
                    NewSelect.appendChild(Opt);
               }
               Select.parentNode.insertBefore(NewSelect, Select.nextSibling);
          }
     }
}

// Récupération des informations et requête de page

function liveAskForSysop() {
  var GotOption = false;
  var GotOptionParams = false
  var GotReason = false;
  var Select = document.getElementById('AskForSysop');
  var Options = Select.getElementsByTagName('option');
  for(var a=0,l=Options.length;a<l;a++){
    var Option = Options[a];
    if(Option.selected && !GotOption){
      GotOption = Option;
      var ID = GotOption.id;
      for(var Ask in lstAskForSysop){
        var Type = lstAskForSysop[Ask].userright;
        if(Type!=ID) continue;
        GotOptionParams = lstAskForSysop[Ask];
      }
    }
  }
  var message = GotOption.value;
  var summary = message;
  var ReasonsSelect = document.getElementById('AskForSysopReasons');
  var ReasonsOptions = ReasonsSelect.getElementsByTagName('option');
  for(var a=0,l=ReasonsOptions.length;a<l;a++){
    var ReasonsOption = ReasonsOptions[a];
    if(ReasonsOption.selected){
      GotReason = ReasonsOption.value;
    }
  }
  if(!GotOption || !GotOptionParams || !GotReason) return;
  lrcDisableLink('LiveAskForSysop');
  lrcDisableLink('AskForSysop');
  lrcDisableLink('AskForSysopReasons');
  var URL = wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+encodeURIComponent(GotOptionParams.page)
  wpajax.http({ url       : URL,
                onSuccess : postAskForSysop,
                message   : message,
                summary   : summary,
                page      : GotOptionParams.page,
                reason    : GotReason
  });
  return false;
}

// Traitement de la requête de demande administrative

function postAskForSysop(xmlreq, data) {
  var page = data.page;
  var message = data.message;
  var summary = data.summary;
  var reason = data.reason;
  var ObjetXML = xmlreq.responseXML;
  var Isprotected = false;
  var PR = ObjetXML.getElementsByTagName("pr");
  for(var a=0,l=PR.length;a<l;a++){
    var Type = PR[a].getAttribute("type");
    var Level = PR[a].getAttribute("level");
    if(Type=="edit" && wgUserGroups.indexOf(Level)==-1) Isprotected = true;
  }
  if(Isprotected){
    alert('Page protégée');
    return;
  }
  var Page = ObjetXML.getElementsByTagName("page")[0];
  var EditParam = new Array();
  EditParam["token"] = encodeURIComponent(Page.getAttribute("edittoken"));
  EditParam["appendtext"] = encodeURIComponent('\n\n{{subst:' + message + '|raison='+reason+'}}\n');
  EditParam["summary"] = encodeURIComponent("");
  EditParam["title"] = encodeURIComponent(page);
  EditParam["watchlist"] = "preferences";
  if(lrcParams["BypassWatchdefault"]) EditParam["watchlist"] = "nochange";
  var Params = new Array();
  for(var Param in EditParam){
    Params.push(Param+"="+EditParam[Param]);
  }
  Params = Params.join("&");
  var headers = new Array();
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=edit',
                method: "POST", headers: headers,
                data: Params});
}
/* 

 Module de gestion des variables 

 Récupération de la page de paramétrage 

 */

// Récupération oldid de la page de paramétrage

function LiveRC_ManageParams_GetOldParamsOldid(RequeteOldid){
  var ObjetXML = RequeteOldid.responseXML;
  if (ObjetXML){
    var LastRevision = ObjetXML.getElementsByTagName('rev')[0];
    if (LastRevision){
      var Oldid = LastRevision.getAttribute('revid');
      wpajax.http({url:wgServer + wgScript + '?title=User:' + encodeURIComponent(wgUserName) + '/LiveRCparam.js&action=raw&oldid=' + Oldid, onSuccess:LiveRC_ManageParams_GetOldParams });
    }
  }
}

// Récupération de la page de paramétrage

function LiveRC_ManageParams_GetOldParams(Req){
     var Response = Req.responseText;
     if(Response=="") return;
     var FoundSetup = false;
     var ResponseLines = Response.split('\n');
     for(var line = 0,linelength=ResponseLines.length;line<linelength;line++){
          var ThisLine = ResponseLines[line];
          if(ThisLine.indexOf(LiveRC_ExtensionSetupComment)!=-1){
               FoundSetup = true;
               for(var a=0,l=lrcExtensions.length;a<l;a++){
                    var Installed = false;
                    if(ThisLine.indexOf("|"+lrcExtensions[a]["name"]+"|")!=-1){
                         Installed = true;
                    }
                    lrcExtensions[a]["Installed"] = Installed;
               }
          }
     }
     if(!FoundSetup) for(var a=0,l=lrcExtensions.length;a<l;a++) lrcExtensions[a]["Installed"] = false;
}

/* 

 Menu de paramétrage 

 */

// Création des variables

function LiveRC_ManageParams_Fill(OptionArray, ArrayName, AddButton){
        LiveRC_Params[ArrayName] = new Array();
        for(var Param in OptionArray){
            var ParamName = Param;
            var ParamOldValue = OptionArray[Param];
            var ParamType = typeof(ParamOldValue);  // 'number', 'string', 'boolean', 'object'
            if(ParamType == 'number' || ParamType == 'string' || ParamType == 'boolean' || ParamType == 'object'){
                var NewArray = {
                    "Type"      : "Variable",
                    "Name"      : ParamName,
                    "Desc"      : LiveRC_ManageParams_Translate(ParamName, 0),
                    "ValueType" : ParamType,
                    "OldValue"  : ParamOldValue,
                    "AddButton" : (AddButton ? true : false)
                }
                if(LiveRC_Params[ArrayName].indexOf(NewArray)==-1) LiveRC_Params[ArrayName].push(NewArray);
            }
        }
}

// Traduction du noms des variables

function LiveRC_ManageParams_Translate(Text, Index){
  if(!Index) Index == 0;
  for(var Vars in lrcManageParams_Desc){
    if(" Desc"+Text == " "+Vars) return lrcManageParams_Desc[Vars][Index];
  }
  return ("<"+Text+">").htmlize();
}

// Fermeture du menu

function LiveRC_ManageParams_CloseMenu(){
    var Menu = document.getElementById("LiveRC_ParamMenu");
    if(Menu) Menu.parentNode.removeChild(Menu);
    removeClass(document.body, "LiveRCConfigDisplayed");
    lrcInitTableHeight();
}

// Création du menu

function LiveRC_ManageParams_OpenMenu(){
    var OldMenu = document.getElementById("LiveRC_ParamMenu");
    if(OldMenu){
        LiveRC_ManageParams_CloseMenu();
        return;
    }
    lrcCloseAll();
    addClass(document.body, "LiveRCConfigDisplayed");
    LiveRC_ManageParams_Fill(lrcParams, "lrcParams");
    LiveRC_ManageParams_Fill(lrcOptionMenuValues, "lrcOptionMenuValues");
    LiveRC_ManageParams_Fill(lstBlank, "lstBlank", true);
    LiveRC_ManageParams_Fill(lrcRevertMessages, "lrcRevertMessages", true);
    LiveRC_ManageParams_Fill(lstAvert, "lstAvert", true);
    LiveRC_ManageParams_Fill(lstTag, "lstTag", true);
    LiveRC_ManageParams_Fill(lrcIcon, "lrcIcon");
    if(lrcParams["AddExtensionCustom"]) LiveRC_ManageParams_Fill(lrcExtensions, "lrcExtensions", true);
    LiveRC_ManageParams_Fill(lang_menu, "lang_menu");
    LiveRC_ManageParams_Fill(lang_tooltips, "lang_tooltips");
    LiveRC_ManageParams_Fill(lang_messages, "lang_messages");
    LiveRC_ManageParams_Fill(lrcManageParamsText, "lrcManageParamsText");
    LiveRC_ManageParams_Fill(lrcManageParams_Desc, "lrcManageParams_Desc");
    LiveRC_RunHooks("AfterFillParamPanel");
    var TargetDiv = document.getElementById("OutFixedBottomPanel");
    if(!TargetDiv) return;
    var Menu = document.createElement('div');
    Menu.id = "LiveRC_ParamMenu";
    var MenuAnchor = document.createElement('div');
    MenuAnchor.id = "LiveRC_ParamMenuAnchor";
    MenuAnchor.innerHTML  = "صفحه تنظیمات";
    Menu.appendChild(MenuAnchor);
    var MenuContent = document.createElement('div');
    MenuContent.id = "LiveRC_ParamMenuContent";
    addClass(MenuContent, "LiveRC_MenuContent");
    var Form = document.createElement('form');
    Form.id = "LiveRC_ParamMenuForm";
    MenuContent.appendChild(Form);
    for(var ThisVariableIndex in LiveRC_Params){
        var ArrayVariable = LiveRC_Params[ThisVariableIndex];
        var VariableFieldset = document.createElement('fieldset');
        VariableFieldset.id = "LiveRC_ParamMenu_"+ThisVariableIndex;
        VariableFieldset.setAttribute("style", "text-align:right;");
        var VariableLegend = document.createElement('legend');
        VariableLegend.appendChild(document.createTextNode(LiveRC_ManageParams_Translate(ThisVariableIndex, 0)));
        VariableFieldset.appendChild(VariableLegend);
        VariableFieldset.appendChild(LiveRC_ManageParams_CreateActionButtons());
        var VariableDiv = document.createElement('div');
        VariableDiv.className = "LiveRC_ParamMenuPart";
        var VariableUl = document.createElement('ul');
        var Columns = "";
        if(!ArrayVariable[0]) continue;
        if(ArrayVariable[0]["ValueType"]!='object') Columns ="-moz-column-count:2;-webkit-column-count:2;column-count:2;";
        VariableUl.setAttribute("style", "list-style:none;list-image:none;margin:0;"+Columns);
        VariableDiv.appendChild(VariableUl);
        VariableFieldset.appendChild(VariableDiv);
        for(var a=0,l=ArrayVariable.length;a<l;a++){
            var ThisVariable = ArrayVariable[a];
            var P = document.createElement('li');
            addClass(P, "ParamMenuLi");
            var AddButton = ThisVariable["AddButton"];
            if(ThisVariable["ValueType"]!='object'){
                var Input = document.createElement('input');
                Input.id = ThisVariable["Name"];
                Input.name = ThisVariable["Name"];
                if(ThisVariable["ValueType"]=="boolean"){
                    Input.type = "checkbox";
                    if(ThisVariable["OldValue"]) Input.checked = "checked";
                }else{
                    Input.type = "text";
                    Input.size = 30;
                    Input.setAttribute("style", "padding:2px;margin:0");
                    Input.value = ThisVariable["OldValue"];
                }
                var Label = document.createElement('label');
                Label.setAttribute('for', ThisVariable["Name"]);
                Label.innerHTML = ThisVariable["Desc"];
                P.appendChild(Input);
                P.appendChild(document.createTextNode(" "));
                P.appendChild(Label);
            }else{
                for(var VarIndex in ThisVariable["OldValue"]){
                    var VariableType = typeof(ThisVariable["OldValue"][VarIndex]);
                    if(VariableType!="boolean" && VariableType!="number" && VariableType!="string") continue;
                    var Input = document.createElement('input');
                    Input.id = VarIndex;
                    Input.name = VarIndex;
                    if(VariableType=="boolean"){
                        Input.type = "checkbox";
                        if(ThisVariable["OldValue"][VarIndex]) Input.checked = "checked";
                    }else{
                        Input.type = "text";
                        if(VariableType=="string") Input.size = 40;
                        if(VariableType=="number") Input.size = 15;
                        Input.setAttribute("style", "padding:2px;margin:0");
                        Input.value = ThisVariable["OldValue"][VarIndex];
                    }
                    var Label = document.createElement('label');
                    Label.setAttribute('for', VarIndex);
                    Label.innerHTML = VarIndex;
                    P.appendChild(Label);
                    P.appendChild(document.createTextNode(":"));
                    P.appendChild(Input);
                    P.appendChild(document.createTextNode(" "));
                }
                if(AddButton) P.appendChild(LiveRC_ManageParams_AddDeleteLink());
            }
            VariableUl.appendChild(P);
        }
        if(AddButton){
            var P = document.createElement('li');
            var Types = new Array()
            for(var VarIndex in ThisVariable["OldValue"]){
                Types.push(lrcEscapeStr(VarIndex)+":"+lrcEscapeStr(typeof(ThisVariable["OldValue"][VarIndex])));
            }
            P.innerHTML = '<a id="AddParam_'+ThisVariableIndex+'" href="javascript:LiveRC_ManageParams_AddNewParam('+lrcEscapeStr(ThisVariableIndex)+', {'+Types.join(",")+'});" >(+)</a>';
            VariableUl.appendChild(P);
        }
        Form.appendChild(VariableFieldset);
    }
    Menu.appendChild(MenuContent);
    TargetDiv.appendChild(Menu);
    LiveRC_ManageParams_AddContactListMenu();
    LiveRC_ManageParams_AddExtensionsMenu();
    LiveRC_ManageParams_CreateToggleButtons();
    LiveRC_ManageParams_ToggleMenu();
    LiveRC_SetVerticalResizeZone(document.getElementById("LiveRC_ParamMenuAnchor"),
                         getElementsByClass("LiveRC_ParamMenuPart",document.getElementById("LiveRC_ParamMenu"),"div"),
                         document.getElementById("LiveRC_ParamMenu")
                        );
    lrcInitTableHeight();
    LiveRC_RunHooks("AfterCreateParamPanel");
}

// Ajouter une nouvele ligne

function LiveRC_ManageParams_AddNewParam(Id, Vars){
    var Link = document.getElementById('AddParam_'+Id);
    if(!Link) return;
    var P = document.createElement('li');
    addClass(P, "ParamMenuLi");
    for(var iName in Vars){
        var Label = document.createElement('label');
        Label.setAttribute('for', iName);
        Label.innerHTML = iName;
        var Input = document.createElement('input');
        Input.id = iName;
        Input.name = iName;
        if(Vars[iName]=="boolean"){
            Input.type = "checkbox";
        }else{
            Input.type = "text";
            Input.size = 40;
            Input.setAttribute("style", "padding:2px;margin:0");
            Input.value = "";
        }
        P.appendChild(Label);
        P.appendChild(document.createTextNode(":"));
        P.appendChild(Input);
        P.appendChild(document.createTextNode(" "));
    }
    P.appendChild(LiveRC_ManageParams_AddDeleteLink());
    var Li = Link.parentNode;
    Li.parentNode.insertBefore(P, Li);
}

// Bouton de suppression de ligne

function LiveRC_ManageParams_AddDeleteLink(){
    var Link = document.createElement('a');
    Link.innerHTML = ('(–)');
    Link.href = "javascript:;"
    Link.onclick = function(){ LiveRC_ManageParams_DeleteThisParam(this); }
    return Link;
}

// Suppression d'une ligne

function LiveRC_ManageParams_DeleteThisParam(Link){
    var Line = Link.parentNode;
    Line.parentNode.removeChild(Line);
    return false;
}

// Création boutons d’action ( Valider / RAZ )

function LiveRC_ManageParams_CreateActionButtons(){
    var ActionP = document.createElement('p');
    var OKInput = document.createElement('input');
    OKInput.type = "button";
    OKInput.value = lrcManageParamsText["OK"];
    OKInput.onclick = function(){ LiveRC_ManageParams_CheckMenu(this); return false;}
    OKInput.onselect = function(){ LiveRC_ManageParams_CheckMenu(this); return false;}
    ActionP.appendChild(OKInput);
    var RAZInput = document.createElement('input');
    RAZInput.type = "button";
    RAZInput.value = lrcManageParamsText["RAZ"];
    RAZInput.onclick = function(){ LiveRC_ManageParams_RAZParams(this); return false;}
    RAZInput.onselect = function(){ LiveRC_ManageParams_RAZParams(this); return false;}
    ActionP.appendChild(RAZInput);
    var CancelInput = document.createElement('input');
    CancelInput.type = "button";
    CancelInput.value = lrcManageParamsText["Cancel"];
    CancelInput.onclick = function(){ LiveRC_ManageParams_CloseMenu(this); return false;}
    CancelInput.onselect = function(){ LiveRC_ManageParams_CloseMenu(this); return false;}
    ActionP.appendChild(CancelInput);
    return ActionP;
}

// Création des onglets

function LiveRC_ManageParams_CreateToggleButtons(){
    var Form = document.getElementById("LiveRC_ParamMenuForm");
    var P = document.createElement('p');
    P.id = "ToggleButtons";
    var Fieldsets = Form.getElementsByTagName('fieldset');
    for(var a=0,l=Fieldsets.length;a<l;a++){
        var Id = ""+Fieldsets[a].id.split("LiveRC_ParamMenu_").join("");
        var Input = document.createElement('input');
        Input.id = "LiveRC_ParamMenuInput_"+Id;
        Input.type = "button";
        Input.setAttribute("style", "padding:0;");
        Input.value = LiveRC_ManageParams_Translate(Id, 1);
        Input.onclick = function(){ LiveRC_ManageParams_ToggleMenu(this); return false;};
        Input.onselect = function(){ LiveRC_ManageParams_ToggleMenu(this); return false;};
        P.appendChild(Input);
    }
    if(lrcUserHasRight("edituserjs")){
        var MSInput = document.createElement('input');
        MSInput.type = "button";
        MSInput.title = "Mise à jour des messages système utilisés";
        MSInput.setAttribute("style", "margin-Right:0.5em");
        MSInput.value = lrcManageParamsText["MessagesLegend"];
        MSInput.onclick = function(){ LiveMessages(true); return false;}
        MSInput.onselect = function(){ LiveMessages(true); return false;}
        P.appendChild(MSInput);
    }
    Form.parentNode.insertBefore( P, Form);
}

// Gestion des onglets

function LiveRC_ManageParams_ToggleMenu(Input){
    var Id = false;
    if(Input) Id = Input.id.split("LiveRC_ParamMenuInput_").join("LiveRC_ParamMenu_");
    var Form = document.getElementById("LiveRC_ParamMenuForm");
    var Onglets = document.getElementById("ToggleButtons").getElementsByTagName('input');
    var Fieldsets = Form.getElementsByTagName('fieldset');
    for(var a=0,l=Fieldsets.length;a<l;a++){
        if(Id){
            Onglets[a].setAttribute("style", ((Id == Fieldsets[a].id)? "font-weight:bold;padding:0;" : "padding:0;") );
            Fieldsets[a].style.display = ((Id == Fieldsets[a].id)? "" : "none");
        }else{
            Onglets[a].setAttribute("style", ((a==0)? "font-weight:bold;padding:0;" : "padding:0;") );
            Fieldsets[a].style.display = ((a==0)? "" : "none");
        }
    }
}

// Vérification du menu

function LiveRC_ManageParams_CheckMenu(Input){
    var Menu = document.getElementById("LiveRC_ParamMenu");
    if(!Menu) return;
    lrcDisableLink(Input);
 // Variables
    var FieldSets = Menu.getElementsByTagName('fieldset');
    for(var b=0,m=FieldSets.length;b<m;b++){
        var ArrayName = FieldSets[b].id.split("LiveRC_ParamMenu_").join("");
        if(!LiveRC_Params[ArrayName]) continue;
        var Lis = FieldSets[b].getElementsByTagName('li');
        var Type = Lis[0].getElementsByTagName('input').length;
        for(var a=0,l=Lis.length;a<l;a++){
            var Inputs = Lis[a].getElementsByTagName('input');
            if(Inputs.length==0) continue;
            if(Type>1){   // ------------------------- object
                if(typeof(LiveRC_Params[ArrayName][a])=='undefined'){
                    LiveRC_Params[ArrayName][a] = new Array();
                }
                var NewValue = new Array();
                for(var i=0,il=Inputs.length;i<il;i++){
                    var Input = Inputs[i];
                    var iName = Input.name;
                    var iValue;
                    if(Input.type=="checkbox"){
                        iValue = (Input.checked ? "true" : "false");
                    }else{
                        iValue = lrcEscapeStrHTML(Input.value);
                    }
                    NewValue.push(lrcEscapeStr(iName)+":"+iValue);
                }
                LiveRC_Params[ArrayName][a]["NewValue"] = "{ "+NewValue.join(", ")+" }";
            }else{                // ------------------------- boolean, number, text
                var Input = Inputs[0];
                if(!Input) continue;
                var InputName = Input.name;
                var InputType = Input.type;
                var InputId = Input.id;
                if(InputName){
                    if(InputType=="text"){
                        for(var i=0,j=LiveRC_Params[ArrayName].length;i<j;i++){
                            if(LiveRC_Params[ArrayName][i]["Name"] != InputName) continue;
                            if(LiveRC_Params[ArrayName][i]["ValueType"] == "string") LiveRC_Params[ArrayName][i]["NewValue"] = lrcEscapeStrHTML(Input.value);
                            if(LiveRC_Params[ArrayName][i]["ValueType"] == "number") LiveRC_Params[ArrayName][i]["NewValue"] = parseInt(Input.value);
                        }
                    }
                    if(InputType=="checkbox"){
                        for(var i=0,j=LiveRC_Params[ArrayName].length;i<j;i++){
                            if(LiveRC_Params[ArrayName][i]["Name"] != InputName) continue;
                            LiveRC_Params[ArrayName][i]["NewValue"] = (Input.checked ? "true" : "false");
                        }
                    }
                }
            }
        }
    }
 // Extensions
    var ExtensionsFieldset = document.getElementById("LiveRC_ParamMenu_ExtensionsLegend");
    var Inputs = ExtensionsFieldset.getElementsByTagName('input');
    for(var a=0,l=Inputs.length;a<l;a++){
        var iName = Inputs[a].name;
        if(Inputs[a].checked){
            for(var b=0,m=lrcExtensions.length;b<m;b++){
                var ExtName = lrcExtensions[b]["name"];
                if(ExtName==iName) lrcExtensions[b]["ToInstall"] = true;
            }
        }
    }
    LiveRC_ManageParams_CreateNewParamPage();
}

// Création nouveau script (≠RAZ)

function LiveRC_ManageParams_CreateNewParamPage(Input){
    lrcDisableLink(Input);
    var ParamPage = "// "+lrcManageParamsText["Comment"]+ "\n";
    var Variables = "\n/* ** "+lrcManageParamsText["VariableLegend"] + " ** */\n\n";

    Variables += "function LiveRC_getUserCustom(){\n\n";
    for(var ArrayName in LiveRC_Params){
        var ThisArray = LiveRC_Params[ArrayName];
        if(typeof(ThisArray[0])=="undefined") continue;
        Variables += "  // "+ LiveRC_ManageParams_Translate(ArrayName, 0) +"\n";
        Variables += "try{\n";
        if(ThisArray[0]["Name"] === 0 || ThisArray[0]["Name"] === "0" ){
            var AllValues = new Array()
            for(var i=0,j=ThisArray.length;i<j;i++){
                if(typeof(ThisArray[i]["NewValue"])!="undefined") AllValues.push("\n "+ThisArray[i]["NewValue"]);
            }
            Variables += ArrayName + " = [" + AllValues.join(", ") + "\n];\n";
        }else{
            for(var i=0,j=ThisArray.length;i<j;i++){
                Variables += ArrayName +"[\""+ThisArray[i]["Name"]+"\"] = "+ThisArray[i]["NewValue"] + ";\n";
            }
        }
        Variables += "}catch(e){ }\n\n";
    }
    Variables += "}\n\n";
    //alert(Variables); return;
    try{ eval(Variables); LiveRC_getUserCustom(); }catch(e){ }
    ParamPage += Variables;
    var Extensions = "\n/* ** "+lrcManageParamsText["ExtensionLegend"] + " ** */\n\n"
                     + LiveRC_ExtensionSetupComment;
    var ExtensionList = "";
    for(var ArrayName in lrcExtensions){
        var ThisArray = lrcExtensions[ArrayName];
        if(ThisArray["ToInstall"] === true){
            Extensions += " |"+ThisArray["name"]+"|";
            ExtensionList += "// "+ThisArray["name"]+ " : "+ThisArray["desc"]+"\n"
                           + "importScriptURI('"+ThisArray["url"]+"&action=raw&ctype=text/javascript');\n\n"
        }
    }
    Extensions += "\n\n"+ExtensionList;
    ParamPage += Extensions;
    LiveRC_ManageParams_UpdateParams(ParamPage);
}

// Création nouveau script (RAZ)

function LiveRC_ManageParams_RAZParams(){
    var ParamPage = "// "+lrcManageParamsText["Comment"]+ "\n";
    LiveRC_ManageParams_UpdateParams(ParamPage);
}

// Édition du script

function LiveRC_ManageParams_UpdateParams(NewPage){
    NewPage = NewPage + "\n" + LiveRC_ParamComment;
    var Menu = document.getElementById("LiveRC_ParamMenuForm");
    var P = document.getElementById("LiveRC_ParamMenuRunning");
    if(!P){
        P = document.createElement('p');
        P.id = "LiveRC_ParamMenuRunning";
        Menu.insertBefore(P,Menu.firstChild);
    }
    if(P) P.innerHTML = lrcManageParamsText["EditRunning"].split("$1").join(wgFormattedNamespaces[2]+":"+wgUserName+"/LiveRCparam.js");
    wpajax.http({ url: wgServer + wgScript + '?title='+wgFormattedNamespaces[2]+':' + wgUserName.replace(/&/g, "26") + '/LiveRCparam.js&action=edit',
                onSuccess: LiveRC_ManageParams_SaveParams, param:NewPage});
}

// Sauvegarde du script

function LiveRC_ManageParams_SaveParams(Req, data){
    var NewPage = data.param;
    var Temp = document.createElement('div');
    Temp.id = "TempDiv";
    Temp.style.display = "none";
    document.body.insertBefore(Temp, document.body.firstChild);
    Temp.innerHTML = Req.responseText;
    var Textarea = getElementWithId("wpTextbox1", 'textarea', Temp);
    Textarea.value = NewPage;
    getElementWithId("wpSummary", 'input', Temp).value = lang_messages.RESUMESTART + lrcManageParamsText["Comment"];
    var P = document.getElementById("LiveRC_ParamMenuRunning");
    if(P) P.innerHTML += "<br />"
                       + lrcManageParamsText["SaveRunning"].split("$1").join(wgFormattedNamespaces[2]+":"+wgUserName+"/LiveRCparam.js");
    var Editform = getElementWithId("editform", 'form', Temp);
    var action = Editform.action;
    var params = new Array();
    var Params = getFormParams(Editform);
    for(var Param in Params){
        params.push(Param+"="+encodeURIComponent(Params[Param]));
    }
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST", headers: headers,
                  onSuccess:LiveRC_ManageParams_SaveParamsDone,
                  data: params.join("&")
    });
    if(Temp) Temp.parentNode.removeChild(Temp);
}

// Script sauvegardé

function LiveRC_ManageParams_SaveParamsDone(Req){
    var P = document.getElementById("LiveRC_ParamMenuRunning");
    if(P) P.innerHTML += "<br />"
                       + lrcManageParamsText["SaveDone"].split("$1").join(wgFormattedNamespaces[2]+":"+ wgUserName+"/LiveRCparam.js" )
                       + "<br/>" + lrcManageParamsText["SaveRefresh"];
}

/* 

 Menu de gestion des contacts 

 */

// Création du menu des contacts

function LiveRC_ManageParams_AddContactListMenu(){
    var Form = document.getElementById("LiveRC_ParamMenuForm");
    if(!Form) return;
    var ContactListFieldset = document.createElement('fieldset');
    ContactListFieldset.id = "LiveRC_ParamMenu_ContactListLegend";
    var ContactListLegend = document.createElement('legend');
    ContactListLegend.appendChild(document.createTextNode(LiveRC_ManageParams_Translate("ContactListLegend", 0)));
    ContactListFieldset.appendChild(ContactListLegend);
    ContactListFieldset.appendChild(LiveRC_ManageParams_CreateContactButtons());
    var ContactListDiv = document.createElement('div');
    ContactListDiv.className = "LiveRC_ParamMenuPart";
    var ContactListUl = document.createElement('ul');
    ContactListUl.id = "LiveRC_ParamMenu_ContactListUL";
    ContactListUl.setAttribute("style", "list-style:none;list-image:none;margin:0;-moz-column-count:3;-webkit-column-count:3;column-count:3;");
    ContactListDiv.appendChild(ContactListUl);
    ContactListFieldset.appendChild(ContactListDiv);
    Form.appendChild(ContactListFieldset);
    for (var user in lstContact) {
        if(!lstContact[user]) continue;
        var P = document.createElement('li');
        addClass(P, "ParamMenuLi");
        var Link = document.createElement('a');
        Link.className = "contact";
        Link.title = user;
        Link.innerHTML = user;
        Link.href= "javascript:liveArticle("+lrcEscapeStr(user)+");";
        P.appendChild(Link);
        P.appendChild(document.createTextNode(" "));
        P.appendChild(LiveRC_ManageParams_AddDeleteLink());
        ContactListUl.appendChild(P);
    }
}

// Création boutons

function LiveRC_ManageParams_CreateContactButtons(){
    var Paragraphe = document.createElement('p');
    var InputAdd = document.createElement('input');
    InputAdd.type = "button";
    InputAdd.value = "Ajouter un contact";
    InputAdd.onclick = function(){ LiveRC_ManageParams_AddNewContact(); };
    InputAdd.onselect = function(){ LiveRC_ManageParams_AddNewContact(); };
    Paragraphe.appendChild(InputAdd);
    var InputOK = document.createElement('input');
    InputOK.type = "button";
    InputOK.value = "OK";
    InputOK.onclick = function(){ LiveRC_ManageParams_CheckContactListMenu(); };
    InputOK.onselect = function(){ LiveRC_ManageParams_CheckContactListMenu(); };
    Paragraphe.appendChild(InputOK);
    var CancelInput = document.createElement('input');
    CancelInput.type = "button";
    CancelInput.value = lrcManageParamsText["Cancel"];
    CancelInput.onclick = function(){ LiveRC_ManageParams_CloseMenu(this); return false;}
    CancelInput.onselect = function(){ LiveRC_ManageParams_CloseMenu(this); return false;}
    Paragraphe.appendChild(CancelInput);
    return Paragraphe;
}

// Ajout d'un contact

function LiveRC_ManageParams_AddNewContact(Name){
    var Ul  = document.getElementById("LiveRC_ParamMenu_ContactListUL");
    if(!Ul) return;
    var P = document.createElement('li');
    addClass(P, "ParamMenuLi");
    var Span = document.createElement('span')
    var Input = document.createElement('input');
    Input.type = "text";
    Input.value = (Name ? Name : "");
    Span.appendChild(Input);
    Input.onkeyup = function(){
          LiveRC_ManageParams_AddNewContact_GetSuggestions(this);
    }
    var Select = document.createElement('select');
    Select.setAttribute('style', 'display:none;')
    Span.appendChild(Select);
    var InputOK = document.createElement('input');
    InputOK.type = "button";
    InputOK.value = "OK";
    InputOK.onclick = function(){ LiveRC_ManageParams_AddThisContact(this); };
    InputOK.onselect = function(){ LiveRC_ManageParams_AddThisContact(this); };
    Span.appendChild(InputOK);
    P.appendChild(Span);
    P.appendChild(document.createTextNode(" "));
    P.appendChild(LiveRC_ManageParams_AddDeleteLink());
    Ul.appendChild(P);
    Input.focus();
}

// Ajout d'un contact (requête suggestions)

function LiveRC_ManageParams_AddNewContact_GetSuggestions(Input){
    if(!Input) return;
    var Select = Input.nextSibling;
    if(!Select) return;
    var User = Input.value;
    if(!User) return;
    var URL = wgServer + wgScriptPath
            + "/api.php?format=xml&action=query&list=allusers"
            + "&auprefix=" + encodeURIComponent(User)
            + "&aulimit=10";
    wpajax.http({ url       : URL,
                  onSuccess : LiveRC_ManageParams_AddNewContact_ShowSuggestions,
                  user : User,
                  input : Input,
                  select : Select
    });
}

// Ajout d'un contact (affichage suggestions)

var lrcLiveRC_ManageParams_AddNewContact_ShowSuggestions_ZIndex = 10000;
function LiveRC_ManageParams_AddNewContact_ShowSuggestions(Req, data){
    var TailleListe = 5;
    var xml = Req.responseXML ;
    var Select = data.select;
    var Input = data.input;
    var User = data.user;
    if ( xml == null || !Select || !Input || !User ) return ;
    var titles = new Array () ;
    var pages = xml.getElementsByTagName("u") ;
    for(var i=0;i<pages.length;i++){
        var s = pages[i].getAttribute("name");
        if(titles.indexOf(s)==-1) titles.push(s);
    }
    var suggestion = titles[0];
    if(titles.length==0 || suggestion===Input.value){
        Select.style.display = "none" ;
        return;
    }
    if(titles.length<TailleListe) TailleListe = titles.length;
    Select.style.display = "inline" ;
    Select.size = TailleListe ;
    Select.style.align = "right" ;
    Select.style.zIndex = lrcLiveRC_ManageParams_AddNewContact_ShowSuggestions_ZIndex++ ;
    Select.style.position = "relative" ;
    Select.style.width = Input.offsetWidth + "px" ;
    Select.style.height = (TailleListe * 20) + "px" ;
    while(Select.firstChild) Select.removeChild(Select.firstChild);
    for ( var i = 0 ; i < titles.length ; i++ ) {
         var opt = document.createElement("option");
         var ot = document.createTextNode(titles[i]);
         opt.appendChild(ot) ;
         opt.value = titles[i];
         Select.appendChild(opt) ;
    }
    Select.style.marginTop = "-" + (TailleListe * 20) + "px" ;
    Select.style.marginRight = "-" + Input.offsetWidth + "px" ;
    Select.onkeyup = lrcLiveRC_ManageParams_AddNewContact_ReplaceSuggestionsKeyPress;
    Select.onclick = lrcLiveRC_ManageParams_AddNewContact_ReplaceSuggestions;
    if(suggestion.indexOf(Input.value)==0){
        var CurrentValueLength = Input.value.length;
        Input.value = suggestion;
        if (Input.createTextRange) {
            var ra = Input.createTextRange();
            ra.moveStart("character", CurrentValueLength);
            ra.moveEnd("character", suggestion.length);
            ra.select();
        } else if( Input.setSelectionRange ) {
            Input.setSelectionRange( CurrentValueLength, suggestion.length );
        } else {
            Input.selectionStart = CurrentValueLength;
            Input.selectionEnd = suggestion.length ;
        }
    }
}

// Ajout d'un contact (sélection suggestion)

function lrcLiveRC_ManageParams_AddNewContact_ReplaceSuggestionsKeyPress(e){
     if (!e) var e = window.event;
     if (e.keyCode != 13) return;
     lrcLiveRC_ManageParams_AddNewContact_ReplaceSuggestions();
}

function lrcLiveRC_ManageParams_AddNewContact_ReplaceSuggestions(){
     var Select = this;
     if(!Select) return;
     var Input = Select.previousSibling;
     if(!Input) return;
     var Options = Select.getElementsByTagName('option');
     for(var a=0;a<Options.length;a++){
          if(Options[a].selected){
               Input.value = Options[a].value;
               Input.focus();
               LiveRC_ManageParams_AddNewContact_GetSuggestions(Input);
               return;
          }
     }
}

// Ajout d'un contact (validation)

function LiveRC_ManageParams_AddThisContact(OK){
    if(!OK) return;
    var Li = OK.parentNode.parentNode;
    if(!Li) return;
    var UserInput = Li.getElementsByTagName('input')[0]
    if(!UserInput) return;
    var User = UserInput.value;
    if(!User) return;
    Li.removeChild(Li.getElementsByTagName('span')[0]);
    var Link = document.createElement('a');
    Link.className = "contact";
    Link.title = User;
    Link.innerHTML = User;
    Link.href= "javascript:liveArticle("+lrcEscapeStr(User)+");";
    Li.insertBefore(Link, Li.firstChild);
}

// Vérification du menu des contacts

function LiveRC_ManageParams_CheckContactListMenu(){
    var Menu = document.getElementById("LiveRC_ParamMenu_ContactListLegend");
    if(!Menu) return;
    var Contacts = getElementsByClass("contact", Menu, "a");
    var ContactList = new Array();
    for(var a=0,l=Contacts.length;a<l;a++){
        var userName = Contacts[a].title;
        ContactList.push(userName);
        if(!lstContact[userName]){
            addWatch(userName , true);
        }
    }
    for(var user in lstContact){
        if(ContactList.indexOf(user)==-1){
            addWatch(user, false);
        }
    }
}
/* 

 Menu de gestion des extensions 

 */

// Création du menu des extensions

function LiveRC_ManageParams_AddExtensionsMenu(){
    var Form = document.getElementById("LiveRC_ParamMenuForm");
    if(!Form) return;
    var ExtensionFieldset = document.createElement('fieldset');
    ExtensionFieldset.id = "LiveRC_ParamMenu_ExtensionsLegend";
    var ExtensionLegend = document.createElement('legend');
    ExtensionLegend.appendChild(document.createTextNode(LiveRC_ManageParams_Translate("ExtensionsLegend", 0)));
    ExtensionFieldset.appendChild(ExtensionLegend);
    ExtensionFieldset.appendChild(LiveRC_ManageParams_CreateActionButtons());
    var ExtensionDiv = document.createElement('div');
    ExtensionDiv.className = "LiveRC_ParamMenuPart";
    var ExtensionUl = document.createElement('ul');
    ExtensionUl.setAttribute("style", "list-style:none;list-image:none;margin:0;");
    ExtensionDiv.appendChild(ExtensionUl);
    ExtensionFieldset.appendChild(ExtensionDiv);
    for(var a=0,l=lrcExtensions.length;a<l;a++){
        var ThisExtension = lrcExtensions[a];
        var P = document.createElement('li');
        addClass(P, "ParamMenuLi");
        var Input = document.createElement('input');
        Input.id = ThisExtension["name"];
        Input.name = ThisExtension["name"];
        Input.type = "checkbox";
        if(ThisExtension["Installed"] && ThisExtension["Installed"]==true) Input.checked = "checked";
        var Label = document.createElement('label');
        Label.setAttribute('for', ThisExtension["name"]);
        Label.innerHTML = '<a href="'+ThisExtension["url"] + '" target="_blank" >'+ThisExtension["name"]+'</a> : ' +ThisExtension["desc"];
        P.appendChild(Input);
        P.appendChild(document.createTextNode(" "));
        P.appendChild(Label);
        ExtensionUl.appendChild(P);
    }
    Form.appendChild(ExtensionFieldset);
}

/* 

 Manipulation de classes 

 */

if(typeof(hasClass)!='function')
function hasClass(node, className){
    var haystack = node.className;
    if(!haystack) return false;
    if (className === haystack) {
        return true;
    }
    return (" " + haystack + " ").indexOf(" " + className + " ") > -1;
}

if(typeof(addClass)!='function')
function addClass(node, className) {
    if (hasClass(node, className)) {
        return false;
    }
    var cache = node.className;
    if (cache) {
        node.className = cache + ' ' + className;
    } else {
        node.className = className;
    }
    return true;
}

if(typeof(removeClass)!='function')
function removeClass(node, className) {
  if (!hasClass(node, className)) {
    return false;
  }
  node.className = node.className.replace(new RegExp('(^|\\s+)'+ className +'($|\\s+)','g'), ' ');
  return true;
}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

/* 

 Fenêtre de débogage 

 */

function lrcDisplayDebug(text){
  var DebugDiv = document.getElementById("debug");
  var DebugUl = document.getElementById("debug_ul");
  var DebugLogo = document.getElementById("debug_Logo");
  var Logo = document.getElementById("lrcLogo");
  var AnimatedLogo = document.getElementById("lrcAnimatedLogo");
  if(!text || text == ""){
    if(Logo && AnimatedLogo){
        Logo.style.display = "";
        AnimatedLogo.style.display = "none";
    }
    if(!lrcParams["DisplayDebug"]) return;
    if(DebugDiv) DebugDiv.style.display = "none";
    if(DebugUl) DebugUl.innerHTML = "";
  }else{
    if(Logo && AnimatedLogo){
        Logo.style.display = "none";
        AnimatedLogo.style.display = "";
    }
    if(!lrcParams["DisplayDebug"]) return;
    if(DebugDiv) DebugDiv.style.display = "block";
    if(DebugUl) DebugUl.innerHTML += '<li>' + text + '</li>';
  }
}

/* 

 Divers 

 */

function getElementWithId( elementId , elementTagName , elementParentNode ){
      if(!elementParentNode) elementParentNode = document;

      if (elementParentNode.getElementById) return elementParentNode.getElementById(elementId);

      var TheElement = false;
      var Elements = elementParentNode.getElementsByTagName(elementTagName);
      var elementcount = 0;
      while(elementcount<Elements.length){
            var Id = Elements[elementcount].getAttribute('id');
            if(Id){
                  if(Id==elementId){
                        TheElement = Elements[elementcount];
                        break;
                  }
            }
            elementcount++
      }
      if (! TheElement) return null;
      return TheElement;
}

function generateNewID() {
  nextFreeID++;
  return "idauto" + nextFreeID;
}

function canRevertUser(user) {
  return user == wgUserName || user == 'Salebot';
}

// HTMLize
String.prototype.htmlize = function() {
  var chars = new Array('&','<','>','"');
  var entities = new Array('amp','lt','gt','quot');
  var string = this;
  for (var i=0; i<chars.length; i++) {
    var regex = new RegExp(chars[i], "g");
    string = string.replace(regex, '&' + entities[i] + ';');
  }
  return string;
}

function lrcEncode(text){
 return encodeURIComponent(text).replace(/%3A/g, ":").replace(/%2F/g, "/");
}

function lrcGetPageURL(page) {
  return wgServer + wgArticlePath.split('$1').join(lrcEncode(page));
}

function lrcGetUglyPageURL(page, params) {
  return wgServer + wgScript + '?title=' + lrcEncode(page)+ (params ? params : "");
}

function lrcGetUserLink(user) {
  var regexpIP = /^\d{1,3}\.\d{1,3}.\d{1,3}.\d{1,3}$/;
  var prefix = wgFormattedNamespaces[2]+":";
  var LiveFunction = "liveArticle("+lrcEscapeStr(prefix+user)+");";
  if (regexpIP.exec(user)) {
    prefix = "Special:Contributions/";
    LiveFunction = "liveContrib("+lrcEscapeStr(user)+");";
  }
  var link = '<a class="lrc_EditorLink" '
           + 'href="' + lrcGetPageURL(prefix + user) + '" '
           + 'onClick="'+LiveFunction+' return false;" '
           + '>' + lrcStripString(user, lrcParams["UserLengthLimit"]) + '</a>';
  return link;
}

/* Returns s such that, when a piece of js code containing s is inserted in the
   property innerHTML of an element, the evaluation of s is the string str. */
function lrcEscapeStr(str) {
  return "'" + (""+str).replace(/\\/g, '\\\\').replace(/'/g, '\\\'').htmlize() + "'";
}
function lrcEscapeStrHTML(str) {
  return "'" + (""+str).replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'";
}

function lrcComputeWatchParam(doc) {
  var result;
  if (lrcParams["BypassWatchdefault"]) {
    result = doc.getElementById('ca-unwatch');
  }
  else {
    result = doc.getElementById('wpWatchthis').checked;
  }
  return result ? "&wpWatchthis=1" : "";
}

function lrcStripString(string, limit){
  if(!limit || string.length<limit) return string;
  return string.substring(0, limit) + "…";
}

function lrcDisableLink(id) {
  var lnk = document.getElementById(id);
  if(!lnk) return;
  if(!lnk.tagName) return;
  var DisableElementTimer = 2;
  if(lnk.tagName.toLowerCase() == "a"){
    var DisabledLink = document.createElement('a');
    DisabledLink.id = id + "_disabled";
    DisabledLink.title = lnk.title;
    DisabledLink.innerHTML = lnk.innerHTML;
    DisabledLink.href = "javascript:;";
    DisabledLink.style.color = "silver";
    DisabledLink.style.cursor = "default";
    DisabledLink.style.textDecoration = "none";
    lnk.style.display = "none";
    lnk.parentNode.insertBefore(DisabledLink, lnk);
  }else if(lnk.tagName.toLowerCase() == "input" || lnk.tagName.toLowerCase() == "select"){
    lnk.disabled = "disabled";
  }
  setTimeout("lrcEnableLink('"+id+"')", DisableElementTimer*1000);
}

function lrcEnableLink(id, OldHref, OldOnclick, OldColor, OldCursor, OldTextDecoration) {
  var lnk = document.getElementById(id);
  if(!lnk) return;
  if(!lnk.tagName) return;
  var DisableElementTimer = 5;
  if(lnk.tagName.toLowerCase() == "a"){
    var DisabledLink = document.getElementById(id+"_disabled");
    if(!DisabledLink) return;
    DisabledLink.parentNode.removeChild(DisabledLink);
    lnk.style.display = "";
  }else if(lnk.tagName.toLowerCase() == "input" || lnk.tagName.toLowerCase() == "select"){
    lnk.disabled = false;
  }
}

function tsToHhMm(timestamp) {
  var tz = lrcGetTimeZone();
  var regex = new RegExp(/^\d\d\d\d-\d\d-\d\dT(\d\d):(\d\d):\d\dZ$/);
  match = regex.exec(timestamp);
  if (!match) {
    return 'xx:xx';
  }
  var tt = (match[1]*60 + match[2]*1 + tz + 1440) % 1440;
  var mm = tt % 60;
  var hh = (tt - mm) / 60 % 24;
  return hh + ':' + (mm < 10 ? '0' : '') + mm;
}

function lrcGetTimeZone(){
  var tz;
  var match;
  if (lrcParams["TZ"]) {
    var regex = new RegExp(/^([-+])?(\d?\d):?(\d\d)$/);
    match = regex.exec(lrcParams["TZ"]);
    if (!match) {
      return 0;
    }
    tz = match[2]*60 + match[3]*1;
    tz = match[1] == '-' ? -tz : tz;
  } else {
    var now = new Date();
    tz = -now.getTimezoneOffset();
  }
  return tz;
}

function lrcGetArgFromURL(URL, Arg){
  if(!URL || !Arg) return false;
  try{
    var Args = decodeURIComponent(URL).split("&");
    for(var a=0,l=Args.length;a<l;a++){
      if(Args[a].indexOf(Arg+"=")!=-1) return Args[a].split("=")[1];
    }
  }catch(e){
    return false;
  }
  return false;
}

function getNamespaceInfoFromPage(Page, ToReturn){
     if(!ToReturn) ToReturn = false;
     var NamespaceNumber = 0;
     var NamespaceName = "";
     var PageName = Page;
     var Found = false;
     for(var NS in wgFormattedNamespaces){
          if(Found) continue;
          var ThisNamespaceName = wgFormattedNamespaces[NS];
          if(ThisNamespaceName==="") continue;
          var NamespaceNameRegExp = new RegExp("^"+ThisNamespaceName+":", "ig");
          var Matches = Page.match(NamespaceNameRegExp);
          if(Matches!=null && Matches.length == 1){
               NamespaceNumber = parseInt(NS);
               NamespaceName = ThisNamespaceName;
               PageName = Page.replace(NamespaceNameRegExp, "");
               Found = true;
          }
     }
     if(ToReturn==="NamespaceName") return NamespaceName;
     if(ToReturn==="PageName") return PageName;
     return NamespaceNumber;
}

if(typeof(getTextContent)!='function'){
  function getTextContent(oNode) {
    if(!oNode) return null;
    if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
    switch (oNode.nodeType) {
      case 3: // TEXT_NODE
      case 4: // CDATA_SECTION_NODE
        return oNode.nodeValue;
        break;
      case 7: // PROCESSING_INSTRUCTION_NODE
      case 8: // COMMENT_NODE
        if (getTextContent.caller!=getTextContent) {
          return oNode.nodeValue;
        }
        break;
      case 9: // DOCUMENT_NODE
      case 10: // DOCUMENT_TYPE_NODE
      case 12: // NOTATION_NODE
        return null;
        break;
    }
    var _textContent = "";
    oNode = oNode.firstChild;
    while (oNode) {
      _textContent += getTextContent(oNode);
      oNode = oNode.nextSibling;
    }
    return _textContent;
  }
}

/* 

 Fonctions d'initialisation 

 Activation 

 */

function LiveRC_Init() {
  if (wgPageName == LiveRC_PageTitle && (wgAction=="view"||wgAction=="purge")) {

    // Get Site params
    if(typeof(LiveRC_getSiteCustom)==="function") try{ LiveRC_getSiteCustom(); }catch(e){ }

    // Get User params
    if(typeof(LiveRC_getUserCustom)==="function") try{ LiveRC_getUserCustom(); }catch(e){ }

    // Check LiveRC version
    var VersionContainer = document.getElementById("currentVersion");
    if(VersionContainer){
        var validatedVersion = '<span style="color:green;font-weight:bold">'+LiveRC_Version+'</span>';
        if(VersionContainer.innerHTML == LiveRC_Version){
            VersionContainer.innerHTML = validatedVersion;
        } else if (VersionContainer.innerHTML == validatedVersion) {
            VersionContainer.parentNode.innerHTML += '<br/>'+lang_messages.ALREADY_RUNNING;
        }else{
            VersionContainer.parentNode.innerHTML += '<br/>'+lang_messages.NEW_VERSION.split("$1").join(LiveRC_Version);
        }
    }
    // Update positions
    lrcFixPosition();
    // Set buttons
    lrcMakeButtons();
    // Set clocks
    lrcSetClocks();
    // Set resize zones
    LiveRC_setResizeZones();
    lrcInitTableHeight();
    // Update icons
    for(var Icon in lrcIcon){
      var IconContainer = document.getElementById("lrcIcon_"+Icon);
      if(!IconContainer) continue;
      IconContainer.innerHTML = lrcIcon[Icon];
    }
    // Start
    lrcDisplayDebug("Get extensions");
    wpajax.http({url: wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=revisions&rvlimit=1&rvprop=ids&titles=User:'+encodeURIComponent(wgUserName) + "/LiveRCparam.js",
                 onSuccess: LiveRC_ManageParams_GetOldParamsOldid});
    lrcDisplayDebug("Get user rights");
    wpajax.http({url: wgServer + wgScriptPath + '/api.php?action=query&meta=userinfo&uiprop=rights&format=xml',
                onSuccess: getRights});
  }
  // Add LiveRC link in Right panel
  var RCLi = document.getElementById("n-recentchanges");
  if(RCLi){
    var LiveRCLi = document.createElement('li');
    LiveRCLi.id = 'n-liveRC';
    var LiveRCLink = document.createElement('a');
    LiveRCLink.title = 'LiveRC';
    LiveRCLink.href = wgServer+wgArticlePath.split("$1").join(encodeURIComponent(LiveRC_PageTitle));
    LiveRCLink.appendChild(document.createTextNode('LiveRC'));
    LiveRCLi.appendChild(LiveRCLink);
    RCLi.parentNode.insertBefore(LiveRCLi,RCLi.nextSibling);
    if((wgNamespaceNumber==2 || wgNamespaceNumber==3) && wgPageName.indexOf('/') == -1 ){
        wpajax.http({url : wgServer + wgScriptPath
                         + '/api.php?action=query&list=watchlistraw&wrlimit=1&format=xml&wrcontinue='
                         + encodeURIComponent('0|LiveRCWatch:' + wgTitle),
                     onSuccess : LiveWatchInitButton
        });
    }
  }
}
$(LiveRC_Init);

/* 

 Récupération des droits utilisateur 

 */

function getRights(xmlreq, data) {
  var api = xmlreq.responseXML;

  if (api.firstChild.nodeName == "error") return;

  var rights = api.getElementsByTagName('query')[0].getElementsByTagName('userinfo')[0].getElementsByTagName('rights')[0].getElementsByTagName('r');
  var len = rights.length;
  var i;
  var id,right;

  for (i=0; i<len; i++) {
    right = rights[i].textContent;
    // Handle IE
    if (!right) right = rights[i].text;

    if(right) lrcUserRights.push(right);
  }
  if(lrcUserHasRight("apihighlimits")) lrcAPIlimit = 4999;
  LiveMessages();
}

function lrcUserHasRight(Right){
  return (lrcUserRights.indexOf(Right)!=-1);
}

/* 

 Récupération des messages système 

 */

function LiveMessages(update){
  var lrcMissingMessages = new Array();
  if(update){
    for(var MessageName in lrcMediawikiMessages){
        lrcMissingMessages.push(MessageName);
    }
  }else{
    for(var a=0,l=lrcNeededMessages.length;a<l;a++){
      if(typeof(lrcMediawikiMessages[lrcNeededMessages[a]])=="undefined") lrcMissingMessages.push(lrcNeededMessages[a]);
    }
  }
  if(lrcMissingMessages.length>0){
    lrcDisplayDebug("Get system messages");
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=query&meta=allmessages&ammessages='+lrcMissingMessages.join('|')+'&format=xml',
                  onSuccess: getAllmessages,
                  updateMode:(update ? true : false)
               });
  }else if(!update){
    getDisambiguationTemplates();
    buildControlBar();
  }
}

function getAllmessages(xmlreq, data){
  var api = xmlreq.responseXML;
  if (api.firstChild.nodeName == "error") return;
  var messages = api.getElementsByTagName('message');
  for(var a=0,l=messages.length;a<l;a++){
    var MessageName = messages[a].getAttribute('name');
    var MessageValue = (messages[a].firstChild ? messages[a].firstChild.nodeValue : "");
    lrcMediawikiMessages[MessageName] = MessageValue;
  }
  if(data.updateMode===true){
    lrcDisplayDebug("Save system messages");
    UpdateAllmessages();
  }else{
    buildControlBar();
    getDisambiguationTemplates();
  }
}

function UpdateAllmessages(){
    var Messages = "\n/* ** "+lrcManageParamsText["MessagesLegend"] + " ** */\n\n";
    for(var MessageName in lrcMediawikiMessages){
        Messages += "lrcMediawikiMessages[\""+MessageName+"\"] = "
                  + lrcEscapeStrHTML(lrcMediawikiMessages[MessageName].split('\n').join("")) + ";\n";
    }
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+encodeURIComponent(LiveRC_MessagesPage),
                onSuccess: UpdateAllmessagesRunning, messages: Messages});
}

function UpdateAllmessagesRunning(Req, data){
    var EditParam = new Array();
    var Page = Req.responseXML.getElementsByTagName("page")[0];
    EditParam["token"] = encodeURIComponent(Page.getAttribute("edittoken"));
    EditParam["text"] = encodeURIComponent(data.messages);
    EditParam["summary"] = encodeURIComponent(lang_messages.RESUMESTART+lang_messages.UPDATEMESSAGES);
    EditParam["title"] = encodeURIComponent(LiveRC_MessagesPage);
    EditParam["watchlist"] = "preferences";
    if(lrcParams["BypassWatchdefault"]) EditParam["watchlist"] = "nochange";

    var Params = new Array();
    for(var Param in EditParam){
        Params.push(Param+"="+EditParam[Param]);
    }
    Params = Params.join("&");
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: wgServer + wgScriptPath + '/api.php?action=edit',
                  method: "POST", headers: headers,
                  onSuccess:UpdateAllmessagesDone,
                  data: Params
    });
}

function UpdateAllmessagesDone(Req, data){
    lrcDisplayDebug("");
}

/* 

 فهرست الگوهای ابهام‌زدایی 

 */

function getDisambiguationTemplates(){
  lrcDisplayDebug("Get disambiguation templates")
  var DisambiguationPage = lrcMediawikiMessages["disambiguationspage"];
  var Reg = new RegExp("\\[\\[[^\\]]+\\]\\]", "g");
  var AllLinks = DisambiguationPage.match(Reg);
  if(AllLinks==null) return;
  for(var a=0,l=AllLinks.length;a<l;a++){
    var ThisLink = AllLinks[a].split("[[").join("").split("]]").join("");
    if(getNamespaceInfoFromPage(ThisLink)!=10) continue;
    lrcHomonTemplates.push(ThisLink);
  }
  buildAskForSysopCreateReasons();
}

/* 

 Création du menu de contrôle 

 */
function buildControlBar(){
  lrcDisplayDebug("Create control bar");
  var showIPNEWopt = "";
  if (lrcUserHasRight("autopatrol")) {
    showIPNEWopt = '<option value="IPNEW">' + lang_menu.IPNEW + '</option>'
  }

  var lvPreviewFoot = document.getElementById( 'livePreviewFoot' );
  var TR = lvPreviewFoot.getElementsByTagName('tr')[0];
  if(!TR) return;
  while(TR.firstChild){ TR.removeChild(TR.firstChild); }

  var SupprLigneForm = ''
    + '<form id="SupprLigneForm">'
    + '<input type="button" '
    + 'onclick="supprLigne(\'*\'); return false;" '
    + 'onselect="supprLigne(\'*\'); return false;" '
    + 'style="color: red; font-weight: bold;" '
    + 'title="'+lang_tooltips.HIDE_ALL+'" value="X" />'
    + '|'
    + '<input type="button" '
    + 'onclick="supprLigne(\'d\'); return false;" '
    + 'onselect="supprLigne(\'d\'); return false;" '
    + 'style="color: rgb(255, 235, 71); font-weight: bold;" '
    + 'title="'+lang_tooltips.HIDE_REVIEWED+'" value="X" />'
    + '<input type="button" '
    + 'onclick="supprLigne(\'r\'); return false;" '
    + 'onselect="supprLigne(\'r\'); return false;" '
    + 'style="color: rgb(255, 99, 83); font-weight: bold;" '
    + 'title="'+lang_tooltips.HIDE_REVERTS+'" value="X" />'
    + '<input type="button" '
    + 'onclick="supprLigne(\'n\'); return false;" '
    + 'onselect="supprLigne(\'n\'); return false;" '
    + 'style="color: rgb(178, 243, 113); font-weight: bold;" '
    + 'title="'+lang_tooltips.HIDE_NEW+'" value="X" />'
    + '<input type="button" '
    + 'onclick="supprLigne(\'c\'); return false;" '
    + 'onselect="supprLigne(\'c\'); return false;" '
    + 'style="color: white; font-weight: bold;" '
    + 'title="'+lang_tooltips.HIDE_BLANKING+'" value="X" />'
    + '</form>';
  AddButtonToControlBar(SupprLigneForm, false);

  var PreviewNavigationForm = ''
    + '<form id="PreviewNavigationForm">'
    + '<span id="historyPanel"></span>'
    + '<input id="btnNext" type="button" onclick="goNext();" onselect="goNext();" '
    + 'value="' + lang_menu.NEXTDIFF + '" style="padding:0;" />'
    + '</form>';
  AddButtonToControlBar(PreviewNavigationForm, true);

  var StopForm = ''
    + '<form id="StopForm">'
    + '<input id="stopLive"  type="checkbox" value="true" '+(lrcOptionMenuValues.Stop ? 'checked="checked"':'')+'/>'
    + '<label for="stopLive">' + lang_menu.PAUSE   + '</label>'
   + '</form>';
  AddButtonToControlBar(StopForm, true);

  var DiffRForm = ''
    + '<form id="DiffRForm">'
    + '<input id="showDiffR" type="checkbox" '+(lrcOptionMenuValues.Diff ? 'checked="checked"':'')+'/>'
    + '<label for="showDiffR">'+ lang_menu.LOWDIFF + '</label>'
    + '</form>';
  AddButtonToControlBar(DiffRForm, true);

  var ModeSelectionForm = ''
    + '<form id="ModeSelectionForm">'
    + '<input id="showRC" type="checkbox" '+(lrcOptionMenuValues.RC ? 'checked="checked"':'')+' />'
    + '<label for="showRC">' + lang_menu.RCLABEL  + ' </label>'
    + '<input id="showLog"    type="checkbox" '+(lrcOptionMenuValues.Log ? 'checked="checked"':'')+'/>'
    + '<label for="showLog">'   + lang_menu.LOGSHOW  + ' </label>'
    + '<input id="showFilter"    type="checkbox" '+(lrcOptionMenuValues.Filter ? 'checked="checked"':'')+'/>'
    + '<label for="showFilter">'   + lang_menu.ABSHOW  + '</label>'
    + '</form>';
  AddButtonToControlBar(ModeSelectionForm, true);

  var UserTypeForm = ''
    + '<form id="UserTypeForm">'
    + '<select id="showUsers">'
     +'<option value="RESTMODE">' + lang_menu.RESTMODE + '</option>'
     + '<option value="IPONLY">' + lang_menu.IPONLY + '</option>'
     + showIPNEWopt
     + '<option value="ALLUSERS">' + lang_menu.ALLUSERS + '</option>'
     + '<option value="ALLNBOTS">' + lang_menu.ALLNBOTS + '</option>'
    + '</select>'
    + '</form>';
  AddButtonToControlBar(UserTypeForm, true);

  var NamespaceForm = ''
    + '<form id="NamespaceForm">'
    + '<span id="selectNS" ></span>'
    + '</form>';
  AddButtonToControlBar(NamespaceForm, true);

  // Apply options
  if(lrcOptionMenuValues.Lists) lrcToggleLiveFollow();
  if(lrcOptionMenuValues.Tchat) buildTchatWindow();
  if(lrcOptionMenuValues.Preview) lrcTogglePreview();
  updateRCTypeSelect();
  updatePreviewWindowAttributes();
  buildHistoryPanel();

  LiveRC_RunHooks("AfterOptions");
  liveNS();
}

function updateRCTypeSelect(){
  var RCTypeSelector = document.getElementById("showUsers")
  var RCTypeOptions = RCTypeSelector.getElementsByTagName('option');
  var OptionsSet = false;
  for(var a=0,l=RCTypeOptions.length;a<l;a++){
    if(RCTypeOptions[a].value == lrcOptionMenuValues.RCType) RCTypeOptions[a].selected = "selected";
  }
  if(!OptionsSet){
    lrcOptionMenuValues.RCType == "ALLUSERS";
    if(lrcUserHasRight("autopatrol")) lrcOptionMenuValues.RCType = "IPNEW";
    RCTypeSelector = lrcOptionMenuValues.RCType;
  }
}

function updateNSSelect(){
  var Select = document.getElementById("showNS0");
  var OptionsNS = Select.getElementsByTagName('option');
  for(var a=0,l=OptionsNS.length;a<l;a++){
    if(OptionsNS[a].value === lrcOptionMenuValues.RCns || parseInt(OptionsNS[a].value) === lrcOptionMenuValues.RCns){
      Select.value = lrcOptionMenuValues.RCns;
    }
  }
}

function AddButtonToControlBar(Button, AddSeparator){
  if(!Button) return;
  var ControlBar = document.getElementById("livePreviewFoot");
  if(!ControlBar) return;
  var Line = ControlBar.getElementsByTagName('tr')[0];
  if(!Line) return;
  if(AddSeparator){
    var Separator = document.createElement('td');
    Separator.valign = "middle";
    addClass(Separator, "noHover");
    Separator.innerHTML = "•";
    Line.appendChild(Separator);
  }
  var NewTD = document.createElement('td');
  NewTD.valign = "middle";
  Line.appendChild(NewTD);
  if(typeof(Button)=="string"){
    NewTD.innerHTML = Button;
  }else if(typeof(Button)=="object"){
    NewTD.appendChild(Button);
  }
}

/* 

 Récupération des espaces de noms 

 */

function liveNS() {
  lrcDisplayDebug("Get namespaces names");
  if(typeof(wgFormattedNamespaces)!="undefined"){
    var ns;
    var options = "";
    var lstNs = new Array();
    for (var id in wgFormattedNamespaces) {
      ns = wgFormattedNamespaces[id];
      if (id < 0) continue;
      if (id == 0) ns = lang_main_namespace;
      options += '<option value="' + id + '">' + ns + '</option>';
      lstNs.push(id);
    }
    options = '<option value="' + lstNs.join('|') + '">*</option>' + options;
    document.getElementById('selectNS').innerHTML = '<label for="showNS0">'+lang_menu.NAMESP+' </label><select id="showNS0">' + options + '</select>';
    updateNSSelect();
    liveSysop();
  }else{
    wpajax.http({url: wgServer + wgScriptPath + '/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml',
                 onSuccess: getNS, message: "Pobieranie nazw przestrzeni" });
  }
}

function getNS(xmlreq, data) {
  var api = xmlreq.responseXML;

  if (api.firstChild.nodeName == "error") return;

  var nss = api.getElementsByTagName('query')[0].getElementsByTagName('namespaces')[0].getElementsByTagName('ns');
  var len = nss.length;
  var i;
  var id,ns;
  var options = "";
  var lstNs = new Array();
  var lstNsName = new Array();

  for (i=0; i<len; i++) {
    id = nss[i].getAttribute('id');
    ns = nss[i].textContent;
    // Handle IE
    if (!ns)  ns = nss[i].text;

    if (id < 0) continue;
    lstNsName.push(ns);
    lstNs.push(id);
    if (id == 0) ns = lang_main_namespace;
    options += '<option value="' + id + '">' + ns + '</option>';

  }
  if(typeof(wgFormattedNamespaces)=="undefined"){
    wgFormattedNamespaces = new Array();
    for(var a=0,l=lstNs.length;a<l;a++){
        wgFormattedNamespaces[lstNs[a]] = lstNsName[a];
    }
  }
  options = '<option value="' + lstNs.join('|') + '">*</option>' + options;
  document.getElementById('selectNS').innerHTML = '<label for="showNS0">'+lang_menu.NAMESP+' </label><select id="showNS0">' + options + '</select>';
  updateNSSelect();
  liveSysop();
}

/* 

 Récupération de la liste des administrateurs 

 */

function liveSysop() {
  lrcDisplayDebug("Get sysop names");
  wpajax.http({url:wgServer + wgScriptPath + '/api.php?action=query&list=allusers&augroup=sysop&aulimit=' +lrcAPIlimit +'&format=xml', onSuccess: getSysop, message: "Traitement en cours...\n\n" });
  if (lrcParams["LoadWatchlist"]) {
    liveWatch(false);
  } else {
    liveRC();
    loadBlocks(false);
  }
}

function getSysop(xmlreq, data) {
  var api = xmlreq.responseXML.getElementsByTagName('api')[0];
  if (api.firstChild.nodeName == "error") return;
  var rcs = api.getElementsByTagName('query')[0].getElementsByTagName('allusers')[0].getElementsByTagName('u');
  leni=rcs.length;
  for (i=leni-1; i>=0; i--) {
    lstSysop.push(rcs[i].getAttribute('name'));
  }
}

/* 

 Récupération de la liste de suivi 

 */

function liveWatch(reload) {
  lrcDisplayDebug("Get watchlist");
  wpajax.http({url:wgServer + wgScriptPath + '/api.php?action=query&list=watchlistraw&wrlimit=' +lrcAPIlimit +'&format=xml',
               onSuccess: getWatch,
               reload:(reload ? reload : false),
               suivi:new Array(),
               contact:new Array()
  });
}

function getWatch(xmlreq, data) {
  var lstContact_Temp = data.contact;
  var lstSuivi_Temp = data.suivi;
  var api = xmlreq.responseXML.getElementsByTagName('api')[0];
  var clPrefix = 'LiveRCWatch:';
  if (api.firstChild.nodeName == "error") return;
  var rcs = api.getElementsByTagName('watchlistraw')[0].getElementsByTagName('wr');
  leni=rcs.length;
  for (i=0; i<leni; i++) {
    var article = rcs[i].getAttribute('title');
    if (article.substr(0, clPrefix.length) == clPrefix) {
      var userName = article.substr(clPrefix.length);
      lstContact_Temp[userName] = {ts: 0, fromjs: false};
    } else {
      lstSuivi_Temp[article] = "--:--";
    }
  }
  var wc1=api.getElementsByTagName('query-continue')[0];
  if (wc1){
    var wrcontinue=wc1.getElementsByTagName('watchlistraw')[0].getAttribute('wrcontinue');
    var URL = wgServer + wgScriptPath + '/api.php?format=xml&action=query&list=watchlistraw'
            + '&wrlimit=' +lrcAPIlimit
            + '&wrcontinue=' + encodeURIComponent(wrcontinue);
    wpajax.http({url:URL,
        onSuccess: getWatch,
        reload:reload,
        suivi:lstSuivi_Temp,
        contact:lstContact_Temp
    });
  }else{
    var reload = data.reload;
    if(!reload){
      lstSuivi = lstSuivi_Temp;
      lstContact = lstContact_Temp;
      liveRC();
      loadBlocks(false);
    }else{
      for(var user in lstContact_Temp){
        if(!lstContact.hasOwnProperty(user) && lstContact_Temp.hasOwnProperty(user)) lstContact[user] = lstContact_Temp[user];
      }
      for(var user in lstContact){
        if(lstContact.hasOwnProperty(user)  && !lstContact_Temp.hasOwnProperty(user)) delete lstContact[user];
      }
      delete lstContact_Temp;
      for(var user in lstSuivi_Temp){
        if(!lstSuivi.hasOwnProperty(user) && lstSuivi_Temp.hasOwnProperty(user)) lstSuivi[user] = lstSuivi_Temp[user];
      }
      for(var user in lstSuivi){
        if(lstSuivi.hasOwnProperty(user)  && !lstSuivi_Temp.hasOwnProperty(user)) delete lstSuivi[user];
      }
      delete lstSuivi_Temp;
    }
    clearTimeout(lrcTimeout["Watchlist"]);
    lrcTimeout["Watchlist"] = setTimeout("liveWatch(true);", lrcParams["ReloadList"]*1000);
  }
}

/* 

 Récupération des derniers blocages 

 */

function loadBlocks(reload) {
  if (lrcParams["LoadIPCat"]) {
    lrcDisplayDebug("Get blocked users");
    wpajax.http({url: wgServer + wgScriptPath + '/api.php?action=query&list=logevents&letype=block&lelimit=' + lrcAPIlimit + '&format=xml',
                 onSuccess: readBlocks,
                 minCount: 1000,
                 reload:reload,
                 blocked:new Array()
    });
  }
}

function readBlocks(xmlreq, data) {
  var logevents = xmlreq.responseXML.getElementsByTagName('logevents')[0];
  if (typeof(logevents) == 'undefined') return;
  var lstBlocks_Temp = data.blocked;
  lst = logevents.childNodes;
  for (var i = 0; i < lst.length; i++) {
    if (lst[i].getAttribute('action') == 'block') {
      var user = lst[i].getAttribute('title');
      if (user != null) {
        user = user.substr(user.indexOf(':') + 1);
        lstBlocks_Temp[user] = 1;
      }
    }
  }
  if (data.minCount > lrcAPIlimit) {
    var lestart = xmlreq.responseXML.getElementsByTagName('query-continue')[0].firstChild.getAttribute('lestart');
    var URL = wgServer + wgScriptPath + '/api.php?format=xml&action=query&list=logevents&letype=block'
            + '&lelimit=' + lrcAPIlimit
            + '&lestart=' + encodeURIComponent(lestart);
    wpajax.http({url: URL,
                 onSuccess: readBlocks,
                 minCount: data.minCount - lrcAPIlimit,
                 blocked:lstBlocks_Temp
    });
  } else {
    lstBlocks = lstBlocks_Temp;
    setTimeout("loadBlocks(true);", lrcParams["ReloadList"]*1000);
    if(data.reload) loadUsersInCats(watchCategories);
  }
}

/* 

 Récupération des catégories d'utilisateurs 

 */

function loadUsersInCats(watchCategories) {
  lrcDisplayDebug("Get category members");
  for (var i = 0 ; i < watchCategories.length; i++) {
    wpajax.http({url: wgServer + wgScriptPath
                    + '/api.php?format=xml&action=query&list=categorymembers'
                    + '&cmlimit=' + lrcAPIlimit
                    + '&cmtitle=' + encodeURIComponent(watchCategories[i].category),
                 onSuccess: fillUserCat,
                 wcIndex: i,
                 category:watchCategories[i].category
    });
  }
}

function fillUserCat(xmlreq,data) {
  var cats = xmlreq.responseXML.getElementsByTagName('cm');
  for (var a = 0; a < cats.length; a++) {
    var ns = parseInt(cats[a].getAttribute('ns'));
    if (ns == 3) {
      var title = cats[a].getAttribute('title').split(wgFormattedNamespaces[3]+":").join("");
      lstUserCat[title] = data.wcIndex;
    }else{
      continue;
    }
  }
  var cmcontinue="";
  if (xmlreq.responseXML.getElementsByTagName('query-continue')[0]) {
    cmcontinue = xmlreq.responseXML.getElementsByTagName('query-continue')[0].getElementsByTagName('categorymembers')[0].getAttribute('cmcontinue');
    var URL = wgServer + wgScriptPath
            + '/api.php?format=xml&action=query&list=categorymembers'
            + '&cmlimit=' + lrcAPIlimit
            + '&cmtitle=' + encodeURIComponent(data.category)
            + '&cmcontinue=' + encodeURIComponent(cmcontinue)
    wpajax.http({url: URL,
                 onSuccess: fillUserCat,
                 wcIndex: data.wcIndex,
                 category:data.category
    });
  }
}

/* 

 Fonctions de mise à jour des modifications récentes 

 Lancement de la requête de mise à jour 

 */

function liveRC() {
  if (document.getElementById('stopLive').checked){
    lrcDisplayDebug("");
    clearTimeout(lrcTimeout["RCRequest"]);
    lrcTimeout["RCRequest"] = setTimeout("liveRC()",1000);
     LiveRC_RequestError = 0;
    return;
  }
  lrcDisplayDebug("Get RC");
  clearTimeout(lrcTimeout["RCRequest"]);
  lrcTimeout["RCRequest"] = setTimeout("LiveRC_RequestError++; if(LiveRC_RequestError>4){ document.getElementById('stopLive').checked = 'checked'; }; liveRC(); ",(lrcParams["Refresh"]+30)*1000);

  var HookResult = LiveRC_RunHooks("BeforeRC");
  if(!HookResult) return;

  var rcns = document.getElementById('showNS0').value;
  if (rcns == null) return;

  var withFilters = document.getElementById('showFilter').checked;

  var URL = wgServer + wgScriptPath
    + '/api.php?action=query&list=recentchanges|logevents' + (withFilters ? '|abuselog&aflprop=ids|filter|user|title|action|result|timestamp|hidden' : '') + '&rcnamespace=' + rcns
    + '&rcprop=user|comment|parsedcomment|flags|timestamp|title|ids|sizes|tags' + (lrcUserHasRight("autopatrol") ? '|patrolled' : '')
    + (document.getElementById("showUsers").value != "ALLNBOTS" ? '&rcshow=!bot' : '')
    + '&rcend=' + lastrctimestamp + '&rclimit=' + lrcParams["RCLimit"]
    + '&leend=' + lastletimestamp + '&lelimit=' + lrcParams["RCLimit"]
    + (withFilters ? '&aflend=' + lastfiltertimestamp + '&afllimit=' + lrcParams["RCLimit"] : '')
    + '&format=xml';

  wpajax.http({url:URL, onSuccess:getRC, message:lang_tooltips.WORKING, nsfilter:rcns , withFilters:withFilters});
}

/*

 Récupération de la requête de mise à jour 

 */

function getRC(xmlreq, data) {
  if (document.getElementById('stopLive').checked){
    lrcDisplayDebug("");
    clearTimeout(lrcTimeout["RCRequest"]);
    lrcTimeout["RCRequest"] = setTimeout("liveRC()",1000);
    return;
  }
  var NSFilter = data.nsfilter;
  var api = xmlreq.responseXML.getElementsByTagName('api')[0];

  if (api.firstChild.nodeName == "error") return;

  var query = api.getElementsByTagName('query')[0];

  var rcs = query.getElementsByTagName('recentchanges')[0].getElementsByTagName('rc');
  var i,j,leni,lenj,rc;

  goNext(2); // Set lrcAllLinesSeen if we need to preload a line after the function completes.

  leni=rcs.length;
  for (i=leni-1; i>=0; i--) {
    // Using rcid as revid can be 0 (e.g. when moving a page)
    if (rcs[i].getAttribute('rcid') <= lastrcid) continue;

    rc = new Object();
    rc.state = new Array();
    lenj = rcs[i].attributes.length;
    for (j=0; j<lenj; j++) {
      switch(rcs[i].attributes[j].name) {
        case 'anon':
          rc.state = lrcAddState(rc.state, "IP");
          break;
        case 'bot':
          rc.state = lrcAddState(rc.state, "BOT");
          break;
        case 'new':
          rc.state = lrcAddState(rc.state, "NEW");
          break;
        case 'minor':
          rc.state = lrcAddState(rc.state, "MINOR");
          break;
        case 'new_ns':
          rc.state = lrcAddState(rc.state, "NEWNS");
          break;
        case 'new_title':
          rc.state = lrcAddState(rc.state, "RENAMED");
          break;
        case 'patrolled':
          rc.state = lrcAddState(rc.state, "PATROLLED");
          break;
        case 'type':
          break;
        default:
          rc[rcs[i].attributes[j].name] = rcs[i].attributes[j].value;
          break;
      }
    }

    var tags = rcs[i].getElementsByTagName('tags')[0].getElementsByTagName('tag');
    if (tags.length) {
      rc.state = lrcAddState(rc.state, "TAG");
      rc.tags = tags;
    }

    if (typeof(rc.comment) != "undefined") {
      lenj = commenttests.length;
      for (j=0; j<lenj; j++)
        if (new RegExp(commenttests[j].regex).test(rc.comment))
          rc.state = lrcAddState(rc.state, commenttests[j].state);
    }

    if (rc.newlen == 0) rc.state = lrcAddState(rc.state, "BLANKING");

    if (lstSysop.indexOf(rc.user) != -1)
      rc.state = lrcAddState(rc.state, "SYSOP");

    var mitigating = (lrcHasState(rc.state, "REVERT"))
      || (lrcHasState(rc.state, "BLANKING"))
      || (lrcHasState(rc.state, "REPLACED"))
      || (lrcHasState(rc.state, "TAG"))
      || lstContact[rc.user]
      || (lstRevoc[rc.user])
      || (rc.user == wgUserName)
      || (lrcParams["WLAllChanges"] && lstSuivi.indexOf(rc.title) != -1);

    if (!mitigating) {
      if (document.getElementById("showUsers").value == "RESTMODE") continue;
      if (document.getElementById("showUsers").value == "IPONLY" && !(lrcHasState(rc.state, "IP"))) continue;
      if (document.getElementById("showUsers").value == "IPNEW" && (lrcHasState(rc.state, "PATROLLED"))) continue;
    }

    if ((typeof(rc.logtype) != "undefined") && rc.logtype == "newuser") continue;

    if (lstHidden[rc.user]) continue;

    if (lrcParams["LoadCatAndTemplates"]) {
      wpajax.http({url: wgServer + wgScriptPath + '/api.php?titles=' + encodeURIComponent(rc.title) + '&action=query&prop=categories|templates&cllimit='+lrcAPIlimit+'&clprop=hidden&tllimit='+lrcAPIlimit+'&redirects&format=xml',
                   onSuccess: getRedirCat, rc: rc });
    } else {
      getRevision(rc);
    }
  }

  // Log
  var logs = query.getElementsByTagName('logevents')[0].getElementsByTagName('item');
  var i,j,leni,lenj,log;

  leni=logs.length;
  for (i=leni-1; i>=0; i--) {
    if (logs[i].getAttribute('logid') <= lastlogid) continue;
    log = new Object();
    log.state = 0;

    lenj = logs[i].attributes.length;
    for (j=0; j<lenj; j++) {
        if (logs[i].attributes[j].name == 'type')
        {
          switch(logs[i].attributes[j].value) {
            case 'patrol':
            log.state = lrcAddState(log.state, "PATROL");
              break;
            case 'newusers':
              log.state = lrcAddState(log.state, "NEWUSER");
              break;
            case 'upload':
              log.state = lrcAddState(log.state, "UPLOAD");
              break;
            case 'block':
              log.state = lrcAddState(log.state, "BLOCK");
              if (logs[i].firstChild)
                log.duration = logs[i].firstChild.attributes[1].value;
              break;
            case 'delete':
              log.state = lrcAddState(log.state, "DELETE");
              break;
            case 'move':
              log.state = lrcAddState(log.state, "MOVE");
              if (logs[i].firstChild)
                log.new_title = logs[i].firstChild.attributes[1].value;
            case 'protect':
              log.state = lrcAddState(log.state, "PROTECT");
              break;
            case 'review':
              log.state = lrcAddState(log.state, "REVIEW");
              break;
            default:
              break;
          }
        }
        else
          log[logs[i].attributes[j].name] = logs[i].attributes[j].value;

        //Set a dummy revid to prevent deletion
        log.revid=log.logid;
    }

    if (typeof(log.comment) != "undefined") {
      lenj = commenttests.length;
      for (j=0; j<lenj; j++)
        if (new RegExp(commenttests[j].regex).test(log.comment))
          log.state = lrcAddState(log.state, commenttests[j].state);
    }

    if (lstSysop.indexOf(log.user) != -1)
      log.state = lrcAddState(log.state, "SYSOP");

    if( (NSFilter.indexOf("|")==-1) && (log.ns!=null) && (NSFilter!=log.ns) ) continue;

    if (!(lrcHasState(log.state, "REVIEW"))) {
      if (lrcParams["LoadCatAndTemplates"]) {
        wpajax.http({url: wgServer + wgScriptPath + '/api.php?titles=' + encodeURIComponent(log.title) + '&action=query&prop=categories|templates&cllimit='+lrcAPIlimit+'&clprop=hidden&tllimit='+lrcAPIlimit+'&redirects&format=xml',
                     onSuccess: getRedirCat2, log: log });
      } else {
        getRevision(log);
      }
    }
  }

  if (data.withFilters) {
    // Filters
    var filters = query.getElementsByTagName('abuselog')[0].getElementsByTagName('item');
    var i,j,leni,lenj,filter;

    leni=filters.length;
    for (i=leni-1; i>=0; i--) {
      if (filters[i].getAttribute('id') <= lastfilterid) continue;
      filter = new Object();

      filter.state = new Array();
      filter.state = lrcAddState(filter.state, "ABFILTER");

      lenj = filters[i].attributes.length;
      for (j=0; j<lenj; j++) {
        filter[filters[i].attributes[j].name] = filters[i].attributes[j].value;
      }

      //Set a dummy revid to prevent deletion
      filter.revid = filter.id;

      // Get filter description

      //Set a dummy revid to prevent deletion
      filter.revid = filter.id

      if( (NSFilter.indexOf("|")==-1) && (filter.ns!=null) && (NSFilter!=filter.ns) ) continue;

      getRevision(filter);
    }
    if(filters[0]){
      lastfilterid = filters[0].getAttribute('id');
      lastfiltertimestamp = filters[0].getAttribute('timestamp').replace(new RegExp(/\D/g), "");
    }
  }
  if(rcs[0]){
    lastrcid = rcs[0].getAttribute('rcid');
    lastrctimestamp = rcs[0].getAttribute('timestamp').replace(new RegExp(/\D/g), "");
  }
  if(logs[0]){
    lastlogid = logs[0].getAttribute('logid');
    lastletimestamp = logs[0].getAttribute('timestamp').replace(new RegExp(/\D/g), "");
  }

  lrcDisplayDebug("");
  LiveRC_RequestError = 0;
  clearTimeout(lrcTimeout["RCRequest"]);
  lrcTimeout["RCRequest"] = setTimeout("liveRC()",lrcParams["Refresh"]*1000);
}

/*

 Requête des modèles et catégories (RC) 

 */

function getRedirCat(xmlreq, data) {
  var yurik = xmlreq.responseXML.getElementsByTagName('api')[0];
  if (yurik.firstChild.nodeName == "error") return;

  var rc = data.rc;
  var pageid = rc.pageid;
  var revid = rc.revid;
  var state = rc.state;

  var page = yurik.getElementsByTagName('pages')[0].getElementsByTagName('page')[0];
  if (page.getElementsByTagName('redirect').length) {
    state = lrcAddState(state, "REDIRECT");
    if (page.getElementsByTagName('redirect')[0].getElementsByTagName('to').length)
      rc.redirect = page.getElementsByTagName('redirect')[0].getElementsByTagName('to')[0].textContent;
  }
  rc.categories = new Array();
  if (page.getElementsByTagName('categories').length) {
    var cats = page.getElementsByTagName('categories')[0].getElementsByTagName('cl');
    var i,j;
    var leni = cats.length;
    var lenj = categoriestests.length;
    var pageHasCat = false;
    for (i=0; i<leni; i++){
      if(cats[i].getAttribute("hidden")==null) pageHasCat = true;
      var catTitle = cats[i].getAttribute('title');
      rc.categories.push(catTitle);
      for (j=0; j<lenj; j++){
        if (new RegExp(lang_category+categoriestests[j].regex, "i").test(catTitle)){
          state = lrcAddState(state, categoriestests[j].state);
        }
      }
    }
    if(pageHasCat) state = lrcAddState(state, "CATEGORIZED");
  }
  rc.templates = new Array();
  if (page.getElementsByTagName('templates').length) {
    var temps = page.getElementsByTagName('templates')[0].getElementsByTagName('tl');
    var i,j;
    var leni = temps.length;
    for (i=0; i<leni; i++){
      var templateTitle = temps[i].getAttribute('title');
      if(lrcHomonTemplates.indexOf(templateTitle)!=-1) state = lrcAddState(state, "ابهام‌زدایی");
      if(templateTitle=="Modèle:Méta lien vers portail") state = lrcAddState(state, "PORTAIL");
      if(lrcRecentTemplates.indexOf(templateTitle.split(wgFormattedNamespaces[10]+":").join(""))!=-1) state = lrcAddState(state, "RECENT");
      rc.templates.push(templateTitle);
    }
  }
  rc.state = state;
  getRevision(rc);
}

/*

 Requête des modèles et catégories (Log) 

 */

function getRedirCat2(xmlreq, data) {
  var api = xmlreq.responseXML.getElementsByTagName('api')[0];
  if (api.firstChild.nodeName == "error") return;

  var log = data.log;
  var pageid = log.pageid;
  var revid = log.revid;
  var state = log.state;

  var query = api.getElementsByTagName('query')[0];
  if (query.getElementsByTagName('redirects').length) {
    state = lrcAddState(state, "REDIRECT");
    if (query.getElementsByTagName('redirects')[0].getElementsByTagName('r').length)
      log.redirect = query.getElementsByTagName('redirects')[0].getElementsByTagName('r')[0].getAttribute('to');
  }
  log.categories = new Array();
  if (query.getElementsByTagName('categories').length) {
    var cats = query.getElementsByTagName('categories')[0].getElementsByTagName('cl');
    var i,j;
    var leni = cats.length;
    var lenj = categoriestests.length;
    var queryHasCat = false;
    for (i=0; i<leni; i++){
      if(cats[i].getAttribute("hidden")==null) queryHasCat = true;
      var catTitle = cats[i].getAttribute('title');
      log.categories.push(catTitle);
      for (j=0; j<lenj; j++){
        if (new RegExp(lang_category+categoriestests[j].regex, "i").test(catTitle)){
          state = lrcAddState(state, categoriestests[j].state);
        }
      }
    }
    if(queryHasCat) state = lrcAddState(state, "CATEGORIZED");
  }
  log.templates = new Array();
  if (query.getElementsByTagName('templates').length) {
    var temps = query.getElementsByTagName('templates')[0].getElementsByTagName('tl');
    var i,j;
    var leni = temps.length;
    for (i=0; i<leni; i++){
      var templateTitle = temps[i].getAttribute('title');
      if(lrcHomonTemplates.indexOf(templateTitle)!=-1) state = lrcAddState(state, "ابهام‌زدایی");
      if(templateTitle=="Modèle:Méta lien vers portail") state = lrcAddState(state, "درگاه");
      if(lrcRecentTemplates.indexOf(templateTitle.split(wgFormattedNamespaces[10]+":").join(""))!=-1) state = lrcAddState(state, "RECENT");
      log.templates.push(templateTitle);
    }
  }
  log.state = state;
  getRevision(log);
}

/* 

 Gestion des noms de filtres 

 */

function getFilterAction(action){
  if(lrcMediawikiMessages[("abusefilter-action-"+action)]) return lrcMediawikiMessages[("abusefilter-action-"+action)];
  return action;
}

function getFilterComment(filter) {
  filter.comment = lang_messages.FILTER+' '
  filter.comment += '<a href="'+lrcGetUglyPageURL("Special:AbuseFilter/"+filter.filter_id)+'" '
+ ' onclick="liveFilter(\'AbuseFilter\', '+filter.filter_id+'); return false;" >'+filter.filter_id+'</a>';
  filter.comment += ': ';
  filter.comment += filter.filter;
  filter.comment += ' ('+getFilterAction("action")+' : '+ getFilterAction(filter.result) + ')';
  return filter.comment;
}

/* 

 Affichage d'une ligne RC 

 */

var lrcRCpaused = new Array();

function getRevisionPaused() {
  if (document.getElementById('stopLive').checked){
    setTimeout("getRevisionPaused()", 1000);
    return;
  }
  for(var a=0,l=lrcRCpaused.length;a<l;a++){
    if(lrcRCpaused[a]) getRevision(lrcRCpaused[a]);
  }
  while(lrcRCpaused[0]){ lrcRCpaused.pop(); }
}

function getRevision(rc) {
  if (document.getElementById('stopLive').checked){
    var ID = lrcRCpaused.length;
    lrcRCpaused[ID] = rc;
    if(ID==0) setTimeout("getRevisionPaused()", 1000);
    return;
  }
  var ScrollTop = document.body.scrollTop;
  var title = rc.title;
  var pageid = rc.pageid;
  var revid = rc.revid;
  var oldid = rc.old_revid;
  var user = rc.user;
  var comment = (rc.comment ? rc.comment : "");
  var parsedcomment = (rc.parsedcomment ? rc.parsedcomment : "");
  var timestamp = rc.timestamp;
  var ns = rc.ns;
  var state = rc.state;
  var oldsize = rc.oldlen
  var newsize = rc.newlen
  var sizediff = newsize - oldsize;
  var lineUID = generateNewID();

  var match;
  var escTitle = lrcEscapeStr(title);
  var escUser = lrcEscapeStr(user);

  // INITIALISATION LIGNE RC //

  var tr1 = document.createElement('tr');
  var th0 = document.createElement('th');
  var th1 = document.createElement('th');
  var td2 = document.createElement('td');
  var td3 = document.createElement('td');
  var td4 = document.createElement('td');
  th0.className = "th0RC";
  th1.className = "th1RC";
  td2.className = "td2RC";
  td3.className = "td3RC";
  td4.className = "td4RC";
  lrcLines[lineUID] = {tr1: tr1, title: title, user: user, revid: revid, oldid: oldid, state: state};

  // SUPPR. LIGNE //

  th0.innerHTML = '<a href="javascript:;" onClick="supprLigne(\''+pageid+'_'+revid+'\'); return false;" style="color:red" title="'+lang_tooltips.HIDE_THIS+'">X</a>';
  th0.id = lineUID;

  // ARTICLE //

  var arti = "", artiStyle = "";
  var preArti = "", postArti = "";

  var diff = "";
  var diffClose = "";
  if (lrcParams["AutoCloseDiff"] == 1)
    diffClose='supprLigne(\''+pageid+'_'+revid+'\');';
  if (lrcHasState(state, "NEW")) {
    diff = '<a class="lrc_PreviewLink" '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveArticle('+escTitle+','+escUser+');'+diffClose+' return false;" '
         + 'style="color:green">New</a>';
  }else if (lrcHasState(state, "UPLOAD")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=upload&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'upload\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color:darkslateblue">Log</a>';
  }else if (lrcHasState(state, "NEWUSER")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=newusers&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'newusers\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color:lime">Log</a>';
  }else if (lrcHasState(state, "BLOCK")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=block&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'block\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color:darkgoldenrod">Log</a>';
  }else if (lrcHasState(state, "DELETE")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=delete&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'delete\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color: saddlebrown">Log</a>';
  }else if (lrcHasState(state, "MOVE")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=move&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'move\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color:black">Log</a>';
  }else if (lrcHasState(state, "PROTECT")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:Log', '&type=protect&user=&page='+encodeURIComponent(title))+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveLog(\'protect\',{page:'+escTitle+'});'+diffClose+' return false;" '
         + 'style="color: darkslategray">Log</a>';
  }else if (lrcHasState(state, "ABFILTER")){
    diff = '<a '
         + 'href="'+lrcGetUglyPageURL('Special:AbuseLog', '&details='+revid)+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveFilter(\'AbuseLog\', {\'details\':'+revid+'});'+diffClose+' return false;" '
         + 'style="color: darkslategray">Filt</a>';
  }else{ // simple edit
    diff = '<a class="lrc_PreviewLink" '
         + 'href="'+lrcGetUglyPageURL(title, '&diff='+revid+'&oldid='+oldid+'&unhide=1')+'" '
         + 'onClick="changeLigne(\''+pageid+'_'+revid+'\');liveDiff('+escTitle+','+revid+','+oldid+');'+diffClose+' return false;" '
         + 'style="color:orange" title="'+lang_tooltips.DIFF_TIP+'">'+lang_tooltips.DIFF_SHORT+'</a>'
  }
  var hist = '';
  var edit = '';
  var watch = '';
  var admin = '';
  // Don't show link for log rows
  if (!(lrcHasState(state, "UPLOAD")) &&
      !(lrcHasState(state, "NEWUSER")) &&
      !(lrcHasState(state, "BLOCK")) &&
      !(lrcHasState(state, "DELETE")) &&
      !(lrcHasState(state, "PROTECT")) &&
      !(lrcHasState(state, "PATROL")) &&
      !(lrcHasState(state, "MOVE")) &&
      !(lrcHasState(state, "ABFILTER")))
  {
    hist = '<a '
         + 'href="'+lrcGetUglyPageURL(title,'&action=history') + '" '
         + 'onClick="liveHist('+escTitle+'); return false;" '
         + 'style="color:darkorange;" title="'+lang_tooltips.HIST_TIP+'">'+lang_tooltips.HIST_SHORT+'</a>';
    edit = '<a '
         + 'href="'+lrcGetUglyPageURL(title,'&action=edit') + '" '
         + 'onClick="liveEdit('+escTitle+'); return false;" '
         + 'style="color:tomato" title="'+lang_tooltips.EDIT_TIP+'">'+lang_tooltips.EDIT_SHORT+'</a>';

    if(lstSuivi[title]){
        watch = '<a href="'+lrcGetUglyPageURL(title,'&action=unwatch') + '" '
              + 'onClick="LiveWatchArticle(this, 0, '+escTitle+'); return false;" '
              + 'title="'+lang_tooltips.UNWATCH_TIP+' « '+title+' »" '
              + '>'+lang_tooltips.UNWATCH_SHORT+'</a>';
    }else{
        watch = '<a href="'+lrcGetUglyPageURL(title,'&action=watch') + '" '
              + 'onClick="LiveWatchArticle(this, 0, '+escTitle+'); return false;" '
              + 'title="'+lang_tooltips.WATCH_TIP+' « '+title+' »" '
              + '>'+lang_tooltips.WATCH_SHORT+'</a>';
    }
    if (lrcUserHasRight("delete")) {
      admin += ' • <a '
             + 'href="'+lrcGetUglyPageURL(title,'&action=delete') + '" '
             + 'onClick="liveDelete('+escTitle+'); return false;" '
             + 'style="color:orangered;" title="'+lang_tooltips.DEL_TIP+'">'+lang_tooltips.DEL_SHORT+'</a>';
    }
    if (lrcUserHasRight("protect")) {
      admin += ' • <a '
             + 'href="'+lrcGetUglyPageURL(title,'&action=protect') + '" '
             + 'onClick="liveProtect('+escTitle+'); return false;" '
             + 'style="color:coral;" title="'+lang_tooltips.PROTECT_TIP+'">'+lang_tooltips.PROTECT_SHORT+'</a>';
    }
  }

  // Disambig / ابهام‌زدایی ? ;
  ///////////////////////////
  if (ns == 0 && lrcHasState(state, "ابهام‌زدایی")) {
    artiStyle = 'color: darkorange; font-weight: bold; font-style: italic;';
    preArti += lrcIcon["Homon"] + ' ';
  }

  // Stub / خرد ? ;
  ///////////////////////////
  if (lrcHasState(state, "STUB")) {
    preArti += lrcIcon["Stub"] + ' ';
  }

  // Page protégée ? ;
  ////////////////////
  if (lrcHasState(state, "FULLLOCK"))
    preArti += lrcIcon["FullLock"]+' ';
  if (lrcHasState(state, "LOCK"))
    preArti += lrcIcon["Lock"]+' ';

  // Copyright ? ;
  //////////
  if (lrcHasState(state, "COPYRIGHT"))
    preArti += lrcIcon["Copyright"]+' ';

  // PaS ? ;
  //////////////////
  if (lrcHasState(state, "PAS"))
    preArti += lrcIcon["PaS"]+' ';

  // Événement récent ? ;
  /////////////////////////////////////////
  if( lrcHasState(state, "RECENT") && (ns == 0) )
    preArti += lrcIcon["Recent"]+' ';

  // Adq ? ;
  //////////
  if (lrcHasState(state, "ADQ"))
    postArti += lrcIcon["AdQ"];

  // Bon article ? ;
  //////////////////
  if (lrcHasState(state, "BA"))
    postArti += lrcIcon["BA"];

  // Article potentiellement de qualité ? ;
  /////////////////////////////////////////
  if (lrcHasState(state, "APDQ"))
    postArti += lrcIcon["APDQ"];

  // Article catégorisé ? ;
  /////////////////////////
  if ((!(lrcHasState(state, "UPLOAD")) &&
      !(lrcHasState(state, "NEWUSER")) &&
      !(lrcHasState(state, "BLOCK")) &&
      !(lrcHasState(state, "DELETE")) &&
      !(lrcHasState(state, "PROTECT")) &&
      !(lrcHasState(state, "PATROL")) &&
      !(lrcHasState(state, "MOVE")) &&
      !(lrcHasState(state, "ABFILTER")))
    && !(lrcHasState(state, "REDIRECT"))
    && !(lrcHasState(state, "ابهام‌زدایی"))
    && !(lrcHasState(state, "CATEGORIZED"))
    && (ns == 0 || ns==6)
    && lrcParams["LoadCatAndTemplates"])
    postArti += lrcIcon["Nocat"];

  // Article sans portail ? ;
  /////////////////////////
  if ((!(lrcHasState(state, "UPLOAD")) &&
      !(lrcHasState(state, "NEWUSER")) &&
      !(lrcHasState(state, "BLOCK")) &&
      !(lrcHasState(state, "DELETE")) &&
      !(lrcHasState(state, "PROTECT")) &&
      !(lrcHasState(state, "PATROL")) &&
      !(lrcHasState(state, "MOVE")) &&
      !(lrcHasState(state, "ABFILTER")))
    && !(lrcHasState(state, "REDIRECT"))
    && !(lrcHasState(state, "ابهام‌زدایی"))
    && !(lrcHasState(state, "PORTAIL"))
    && (ns == 0)
    && lrcParams["LoadCatAndTemplates"])
    postArti += lrcIcon["Noportal"];

  // Redirect, Log, or simple edit ? ;
  //////////////////
  var dlbClick = 'onDblClick="window.open(' + lrcEscapeStr(lrcGetPageURL(title)) + ');"'
  if (lrcHasState(state, "MOVE")) {
//    artiStyle = 'color: magenta; font-weight: bold; font-style: italic;';
    postArti += ' '+lrcIcon["Move"];
    postArti += ' <a '
              + 'href="'+lrcGetPageURL(rc.new_title)+'" '
              + 'onClick="liveArticle('+lrcEscapeStr(rc.new_title)+','+escUser+'); return false;"'
              + '>'+lrcStripString(rc.new_title, lrcParams["ArticleLengthLimit"])+'</a>';
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + 'class="lrc_ArticleLink" style="'+artiStyle+'" >'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else if (lrcHasState(state, "REDIRECT")) {
    artiStyle = 'color: green; font-weight: bold; font-style: italic;';
    postArti += ' '+lrcIcon["Redirect"];
    postArti += ' <a '
              + 'href="'+lrcGetPageURL(rc.redirect)+'" '
              + 'onClick="liveArticle('+lrcEscapeStr(rc.redirect)+','+escUser+');" '
              + '>'+lrcStripString(rc.redirect, lrcParams["ArticleLengthLimit"])+'</a>';
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + 'class="lrc_ArticleLink" style="'+artiStyle+'" >'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  } else if (lrcHasState(state, "UPLOAD")) {
    postArti += ' '+lrcIcon["Upload"];
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + dlbClick + ' class="lrc_ArticleLink" style="'+artiStyle+'" >'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else if (lrcHasState(state, "NEWUSER")) {
    postArti += ' '+lrcIcon["NewUser"];
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + dlbClick + ' class="lrc_ArticleLink" style="'+artiStyle+'" >'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else if (lrcHasState(state, "BLOCK")) {
//    artiStyle = 'color: magenta; font-weight: bold; font-style: italic;';
    postArti += ' '+lrcIcon["Block"];
    postArti += ' <a '
              + 'href="'+lrcGetUglyPageURL('Special:Log','&type=block&user=&page='+encodeURIComponent(rc.title))+'" '
              + 'onClick="liveLog(\'block\',{page:'+lrcEscapeStr(rc.title)+'}); return false;" '
              + '>('+rc.duration+')</a>';
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + 'class="lrc_ArticleLink" style="'+artiStyle+'">'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else if (lrcHasState(state, "DELETE")) {
    postArti += ' '+lrcIcon["Delete"];
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + dlbClick + ' class="lrc_ArticleLink" style="'+artiStyle+'">'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else if (lrcHasState(state, "PROTECT")) {
    postArti += ' '+lrcIcon["Protect"];
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + dlbClick + ' class="lrc_ArticleLink" style="'+artiStyle+'">'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }else {
    arti = '<a '
         + 'href="'+lrcGetPageURL(title)+'" '
         + 'onClick="liveArticle('+escTitle+','+escUser+'); return false;" '
         + dlbClick + ' class="lrc_ArticleLink" style="'+artiStyle+'">'+lrcStripString(title, lrcParams["ArticleLengthLimit"])+'</a>';
  }

  th1.innerHTML = '<small>' + tsToHhMm(timestamp) + ' • ' + diff + ' • ' + hist + ' • ' + edit + ' • ' + watch + admin + ' • </small>'
                + preArti + arti + postArti;
  addClass(th1,"creator-title");
  th1.style.textAlign="Right";
  th1.style.border="1px";
  th1.style.width="40%";

  // EDITOR //
  ////////////
  var td2id = generateNewID();
  var discut  = '<a '
              + 'href="'+lrcGetPageURL(wgFormattedNamespaces[3]+':'+user)+'" '
              + 'onClick="liveArticle('+lrcEscapeStr(wgFormattedNamespaces[3]+':'+user)+'); return false;" '
              + 'style="color:seagreen" title="'+lang_tooltips.TALK_TIP+'">'+lang_tooltips.TALK_SHORT+'</a>';
  var contrib = '<a '
              + 'href="'+lrcGetPageURL('Special:Contributions/'+user)+'" '
              + 'onClick="liveContrib('+escUser+'); return false;" '
              + 'style="color:#43CD80" title="'+lang_tooltips.CONTRIB_TIP+'">'+lang_tooltips.CONTRIB_SHORT+'</a>';
  if (lrcUserHasRight("deletedhistory")) {
    contrib += '<a '
             + 'href="'+lrcGetPageURL('Special:DeletedContributions/'+user)+'" '
             + 'onClick="liveDeletedContrib('+escUser+'); return false;" '
             + 'style="color:#43CD80" title="'+lang_tooltips.DELETEDCONTRIB_TIP+'">'+lang_tooltips.DELETEDCONTRIB_SHORT+'</a>';
  }
  var uwatch;
  if (lstContact[user]) {
    uwatch = '<a href="javascript:;" onClick="addWatch('+escUser+',false,\'' + td2id + '\');" style="color:black" title="'+"عدم پیگیری"+'">'+'عدم‌پی'+'</a>';
  } else {
    uwatch = '<a href="javascript:;" onClick="addWatch('+escUser+',true,\'' + td2id + '\');" style="color:#AAAA00" title="'+"پیگیری"+'">'+'پی'+'</a>';
  }

  var editor = "", preEditor = "";

  // Reverted ? ;
  /////////////////
  if (lrcHasState(state, "REVERT"))
    preEditor += lrcIcon["Revert"]+' ';

  // Bot ? ;
  //////////
  if (lrcHasState(state, "BOT"))
    preEditor += lrcIcon["Bot"]+' ';

  // Sysop ? ;
  ////////////
  if (lrcHasState(state, "SYSOP"))
    preEditor += lrcIcon["Sysop"]+' ';

  // TOR potentiel / AOL
  var isTOR = new RegExp(/172\.\d+\.\d+\.\d+/);
  if (isTOR.test(user))
    preEditor += lrcIcon["TOR"]+' ';

  if (typeof(lstUserCat[user]) != 'undefined') {
    preEditor += lrcIcon[watchCategories[lstUserCat[user]].image]+' ';
  }
  if (typeof(lstBlocks[user]) != 'undefined' && user != wgUserName) {
    preEditor += lrcIcon["Blocked"]+' ';
  }

  editor = lrcGetUserLink(user);
  var uadmin   = '';
  if (lrcUserHasRight("block")) {
    uadmin = ' • <a '
           + 'href="'+lrcGetPageURL('Special:Blockip/' + user)+'" '
           + 'onClick="liveBlock('+escUser+'); return false;" '
           + 'style="color:seagreen" title="'+lang_tooltips.BLOCK_TIP+'">'+lang_tooltips.BLOCK_SHORT+'</a>';
  }

  var uhide = '<a href="javascript:;" onClick="supprLigne(\''+pageid+'_'+revid+'\'); hideUser('+ escUser +');" style="color:grey" title="'+lang_tooltips.USER_HIDE_TIP+'">'+lang_tooltips.USER_HIDE_SHORT+'</a>';

  td2.innerHTML = '<small>' + discut + ' • ' + contrib + ' • ' + uhide +  ' • ' +uwatch+ uadmin + ' • </small>'
                + preEditor + editor;
  addClass(td2, "creator-name");
  td2.style.border = "1px";
  td2.style.width = "20%";
  td2.id = td2id;

  if (lstRevoc[user]) {
    addClass(tr1, "RcReverted");
    td2.innerHTML += lrcIcon["NbRevoc"].split("$1").join(lstRevoc[user].nb).split("$2").join(escUser)+lrcGetAllRevoc(user);
  }

  // COMMENT //
  var wcomment = "";
  if( (lrcHasState(state, "UPLOAD")) || (lrcHasState(state, "NEWUSER")) || (lrcHasState(state, "BLOCK")) || (lrcHasState(state, "DELETE")) || (lrcHasState(state, "MOVE")) || (lrcHasState(state, "PROTECT")) ){
    wcomment = comment.htmlize();
    var regex1 = new RegExp(/\[\[(([^\]\|]*)(.*?))\]\]/g);
    wcomment = wcomment.replace(regex1, '<a href="'+wgServer+wgScript+'?title=$2&redirect=no" >$1</a>');
    var regex2 = new RegExp(/\>[^\]\|<]*\|([^\]\|<]*)</g);
    wcomment = wcomment.replace(regex2, ">$1<");
  }else if (lrcHasState(state, "ABFILTER")) {
    wcomment = getFilterComment(rc);
  }else{
    wcomment = parsedcomment;
  }
  if (lrcParams["BoldComments"]) wcomment = '<b>' + wcomment + '</b>';

  // Abusefilter tag ? ;
  /////////////////
  if (lrcHasState(state, "TAG")) {
    var TagTemplate = lrcIcon["Tag"];
    TagTemplate = TagTemplate.split("$1").join(rc.tags[0].firstChild.nodeValue);
    var TagList = "";
    for (var tagId = 1; tagId < rc.tags.length; ++tagId)
      TagList += ' | ' + rc.tags[tagId].firstChild.nodeValue;
    TagTemplate = TagTemplate.split("$2").join(TagList);
    wcomment += TagTemplate;
    addClass(tr1, "RcTag");
  } else {
    td3.style.border = "1px";
    td3.style.width = "40%";
  }
  td3.innerHTML = "<small>" + wcomment + "</small>";
  if (!(lrcHasState(state, "ABFILTER"))) {
    var CommentLinks = td3.getElementsByTagName('a');
    for(var a=0,l=CommentLinks.length;a<l;a++){
      var Target = CommentLinks[a].title.replace(lrcMediawikiMessages["red-link-title"].split("$1").join(""), "");
      if(!Target || Target === "") Target = CommentLinks[a].innerHTML;
      if(CommentLinks[a].className && CommentLinks[a].className == "new"){
        CommentLinks[a].setAttribute("onClick", "liveEdit("+lrcEscapeStr(Target)+", '&redlink=1'); return false;");
      }else{
        if(Target.indexOf(wgFormattedNamespaces[-1]+":"+lrcMediawikiMessages["mycontris"]+"/")==0){
          Target = CommentLinks[a].innerHTML;
          CommentLinks[a].setAttribute("onClick", "liveContrib("+lrcEscapeStr(Target)+"); return false;");
        }else{
          CommentLinks[a].setAttribute("onClick", "liveArticle("+lrcEscapeStr(Target)+"); return false;");
        }
      }
    }
  }

  if(lrcHasState(state, "PATROLLED")) addClass(tr1, "RcPatrolled");
  if(lrcHasState(state, "ABFILTER")) addClass(tr1, "RcAbFilter");
  if(lrcHasState(state, "UPLOAD")) addClass(tr1, "RcUpload");
  if(lrcHasState(state, "NEWUSER")) addClass(tr1, "RcNewUser");
  if(lrcHasState(state, "BLOCK")) addClass(tr1, "RcBlock");
  if(lrcHasState(state, "DELETE")) addClass(tr1, "RcDelete");
  if(lrcHasState(state, "MOVE")) addClass(tr1, "RcMove");
  if(lrcHasState(state, "PROTECT")) addClass(tr1, "RcProtect");
  if(lrcHasState(state, "REVERT")) addClass(tr1, "RcRevert");
  if(lrcHasState(state, "BLANKING") || newsize == 0)  addClass(tr1, "RcBlanking");
  if(lrcHasState(state, "NEW")) addClass(tr1, "RcNew");
  if(lrcHasState(state, "IP")) addClass(tr1, "RcIp");
  if(isTOR.test(user)) addClass(tr1, "RcTOR");
  if(lrcHasState(state, "REPLACED")) {
    addClass(tr1, "RcReplaced");
    td4.innerHTML = lrcIcon["Replaced"];
  }

  // CONTACT LIST //
  //////////////////
  if (lstContact[user]) {
    addClass(tr1, "RcContact");
  } else if (user == wgUserName) {
    addClass(tr1, "RcSelf");
  }

  // DELTA SIZE //

  // delta de modif ;
  ///////////////////
  if(""+sizediff != "NaN") {
    var txtdiff = "";
    if (sizediff < 0)
      txtdiff = '<sub class="mw-plusminus-neg">'+sizediff+'</sub>';
    else if (sizediff == 0)
      txtdiff = '<small class="mw-plusminus-null">='+sizediff+'</small>';
    else
      txtdiff = '<sup class="mw-plusminus-pos">+'+sizediff+'</sup>';
    td4.innerHTML += txtdiff;
    td4.style.border = "1px";
    td4.style.textAlign = "right";
  }

  // ASSEMBLAGE LIGNE //

  tr1.appendChild(th0);
  tr1.appendChild(th1);
  tr1.appendChild(td2);
  tr1.appendChild(td3);
  tr1.appendChild(td4);
  tr1.id = pageid+"_"+revid;

  var tabScroll = document.getElementById("liveRC_RCList");
  var tab = document.getElementById( 'tabRC' );

  if(!lrcParams["InvertUpdate"]){ // Save scrollTop
    var ScrollDown = (tab.offsetHeight - tabScroll.scrollTop);
  }

  // IE automatically inserts a TBODY that we have to take care of
  if (tab.firstChild && (tab.firstChild.nodeName == "TBODY")) tab=tab.firstChild;
  var elold = document.getElementById(pageid+"_"+oldid);

  if(lrcParams["KeepAllLines"]){     // NO LIMIT
    if(lrcParams["InvertUpdate"]){   // Insert in first position
      tab.appendChild(tr1);
    }else{                           // Insert in last position
      if (tab.firstChild != null)
        tab.insertBefore(tr1, tab.firstChild);
      else
        tab.appendChild(tr1);
    }
  }else{                             // LIMIT
    if(lrcParams["InvertUpdate"]){   // Insert in first position
      tab.appendChild(tr1);
      if (elold == null) {
        if (tab.childNodes.length > lrcParams["RCLimit"]) {
          var idt = tab.firstChild.id;
          supprLigne(idt);
        }
      } else {
        supprLigne(pageid+"_"+oldid);
      }
    }else{                           // Insert in last position
      if (tab.firstChild != null)
        tab.insertBefore(tr1, tab.firstChild);
      else
        tab.appendChild(tr1);
      if (elold == null) {
        if (tab.childNodes.length > lrcParams["RCLimit"]) {
          var idt = tab.lastChild.id;
          supprLigne(idt);
        }
      } else {
        supprLigne(pageid+"_"+oldid);
      }
    }
  }

  // Don't show RC if checkbox is not checked
  if ((!document.getElementById('showRC').checked) &&
     (!(lrcHasState(state, "UPLOAD")) &&
      !(lrcHasState(state, "NEWUSER")) &&
      !(lrcHasState(state, "BLOCK")) &&
      !(lrcHasState(state, "DELETE")) &&
      !(lrcHasState(state, "PROTECT")) &&
      !(lrcHasState(state, "MOVE")) &&
      !(lrcHasState(state, "ABFILTER"))))
    supprLigne(pageid+"_"+revid);

  if (lrcHasState(state, "PATROL"))
    supprLigne(pageid+"_"+revid);

  // Don't show Log if checkbox is not checked
  if ((!document.getElementById('showLog').checked) &&
     ((lrcHasState(state, "UPLOAD")) ||
      (lrcHasState(state, "NEWUSER")) ||
      (lrcHasState(state, "BLOCK")) ||
      (lrcHasState(state, "DELETE")) ||
      (lrcHasState(state, "PROTECT")) ||
      (lrcHasState(state, "MOVE"))))
    supprLigne(pageid+"_"+revid);

  if(!lrcParams["InvertUpdate"]){ // Reload scrollTop
    if(ScrollDown) tabScroll.scrollTop = (tab.offsetHeight - ScrollDown);
  }

  // MISE A JOUR LISTE "Liste de suivi" //

  if(lstSuivi[title]) {
    addClass(tr1, "RcWatched");
    updateFollowWatchlist(rc);
  }

  if (lstContact[user]) {
    lstContact[user].ts = timestamp;
    updateFollowContact();
  }

  if (lrcHasState(state, "REVERT")) {
    var regex = new RegExp(/\[\[Sp[ée]cial:Contributions\/([^\]\|]+)/);
    match = regex.exec(comment);
    if (!match) {
                var regex2 = new RegExp(/\[\[Specjalna:Wkład\/([^\]\|]+)/);
                match = regex2.exec(comment);
    }
    if (match) {
      var userR = match[1];
      if (userR != user && userR != wgUserName) {
        if (!lstRevoc[userR]) lstRevoc[userR] = { ts: 0, nb: 0, pages:new Array() };
        lstRevoc[userR].ts = timestamp;
        lstRevoc[userR].nb += 1;
        lstRevoc[userR].pages.push({title:title, oldid:oldid, timestamp:timestamp});
        updateFollowRevoc();
      }
    }
  }
  lrcInitTableHeight();
  if(typeof(ScrollTop)!="undefined") document.body.scrollTop = ScrollTop;
  LiveRC_RunHooks("AfterRC", {id:tr1.id, rc:rc});

  if (lrcAllLinesSeen && document.getElementById(tr1.id)) {
    lrcAllLinesSeen = false;
    goNext(1);
  }
}

/* 

 Passage au diff suivant 

 */

function goNext(mode) {
  //Argos
  var tab = document.getElementById('tabRC');
  // IE automatically inserts a TBODY that we have to take care of
  if (tab.firstChild && (tab.firstChild.nodeName == "TBODY")) tab=tab.firstChild;
  var lines = tab.getElementsByTagName('tr');
  var Nextlength = (lines.length - 1);
  var found = false;
  for (var j = Nextlength; j >= 0; j--) {
    var i = (lrcParams["InvertUpdate"]?(Nextlength - j):j);
    var thisline = lines[i];
    if(!hasClass(thisline, "RcChecked")){
      var Links = thisline.getElementsByTagName('a');
      for (var a=0,l=Links.length;a<l;a++) {
        if (Links[a].className && Links[a].className == "lrc_PreviewLink") {
          if (found || mode) {
            var ln = lrcLines[thisline.getElementsByTagName('th')[0].id];
            if (ln.title && ln.revid && ln.oldid) {
              if (mode == 2) return;
              var lnURL = lrcGetUglyPageURL(ln.title, '&diffonly=1&unhide=1&diff=' + ln.revid + '&oldid=' + ln.oldid)
              wpajax.preload(lnURL);
              return;
            }
          } else {
            var code = Links[a].getAttribute("onclick");
            var ReturnRegExp = new RegExp("return[ ]+false[ ]*;");
            code = code.replace(ReturnRegExp, "");
            eval(code);
            found = true;
          }
        }
      }
    }
  }
  if (mode == 2) {
    lrcAllLinesSeen = true;
  }
}

/* 

 Suppression de ligne(s) RC 

 */

function supprLigne(quelLigne) {
  var i,len;
  var tab = document.getElementById('tabRC');
  // IE automatically inserts a TBODY that we have to take care of
  if (tab.firstChild && (tab.firstChild.nodeName == "TBODY")) tab=tab.firstChild;
  var els = new Array();
  if (quelLigne == '*')
    els = tab.getElementsByTagName('tr');
  else if (quelLigne == 'd') {
    els = getElementsByClass("RcChecked",tab,'tr');
  } else if (quelLigne == 'r') {
    els = getElementsByClass("RcRevert",tab,'tr');
  } else if (quelLigne == 'n') {
    els = getElementsByClass("RcNew",tab,'tr');
  } else if (quelLigne == 'c') {
    els = getElementsByClass("RcBlanking",tab,'tr');
  } else
    els.push(document.getElementById(quelLigne));
  len = els.length;
  for (i=len-1; i>=0; i--){
    if (els[i] != null) {
      lineUID = els[i].getElementsByTagName('th')[0].id;
      delete lrcLines[lineUID];
      tab.removeChild(els[i]);
    }
  }
  return false;
}

/* 

  Validation d'une ligne RC 

 */

function changeLigne(quelLigne) {
  var el = document.getElementById(quelLigne);
  el.className = "RcChecked";
}

/* 

 Fonctions de mise à jour des listes 

 Liste de suivi 

 */

function updateFollowWatchlist(rc){
    if(!rc) return;
    var title = rc.title;
    var cstilde = lrcEscapeStr(title);
    lstSuivi[title] = tsToHhMm(rc.timestamp);
    var tempsAr = new Array();
    var len = lstSuivi.length;
    for (var n in lstSuivi) {
        if(!lstSuivi.hasOwnProperty(n)) continue;
        if(lstSuivi[n] == "--:--") continue;
        var cstilde = lrcEscapeStr(n);
        var sdiff = '<a '
                    + 'href="'+wgServer + wgScript + '?title='+encodeURIComponent(n)+'&diff=cur&oldid=prev&unhide=1" '
                + 'onClick="liveDiff('+cstilde+',\'cur\',\'prev\'); return false;" '
                + 'style="color:orange">Diff</a>';
        var shist = '<a '
                + 'href="'+wgServer + wgScript + '?title='+encodeURIComponent(n)+'&action=history" '
                + 'onClick="liveHist('+cstilde+'); return false;" '
                + 'style="color:darkorange">H</a>';
        var sarti = '<a '
                + 'href="'+lrcGetPageURL(n)+'" '
                + 'onClick="liveArticle('+cstilde+'); return false;"'
                + '>'+n+'</a>';
        var sotherns = getNamespaceInfoFromPage(n);
        var sotherpn = getNamespaceInfoFromPage(n, "PageName");
        if(sotherns%2==0){
            var sotherText = lang_tooltips.TALK_SHORT;
            var sothernsnumber = (sotherns+1);
        }else{
            var sotherText = lang_tooltips.SUBJECT_SHORT;
            var sothernsnumber = (sotherns-1);
        }
        var sothername = (sothernsnumber == 0 ? sotherpn : wgFormattedNamespaces[sothernsnumber]+":"+sotherpn);
        var stalk = '<a style="color: seagreen;" '
                + 'href="'+lrcGetPageURL(sothername)+'" '
                + 'onClick="liveArticle('+lrcEscapeStr(sothername)+'); return false;"'
                + '>'+sotherText+'</a>';
        var ligne='<li><small>' + lstSuivi[n] + ' • ' + sdiff + ' • ' + shist + ' • ' + stalk + ' • </small>' + sarti + '</li>';
        tempsAr.push(ligne);
    }
    tempsAr.sort();
    len = tempsAr.length;
    var lvSuivi = document.getElementById( 'liveSuivi' );
    lvSuivi.innerHTML = "";
    var List = "<ul>";
    for (var n=len-1; n >= 0; n--){
        if(tempsAr[n]) List += tempsAr[n];
    }
    List += "</ul>";
    lvSuivi.innerHTML = List;
}

/* 

 Masqués 

 */

function updateHidden() {
  var tempAr = new Array();
  for (var user in lstHidden) {
    if(!lstHidden.hasOwnProperty(user)) continue;
    var utilde = lrcEscapeStr(user);
    var uremove = '<a href="javascript:;" onClick="unhideUser('+utilde+');" style="color:grey">-</a>';
    var udiscut  = '<a '
                 + 'href="'+lrcGetPageURL(wgFormattedNamespaces[3]+':' + user)+'" '
                 + 'onClick="liveArticle('+lrcEscapeStr(wgFormattedNamespaces[3]+':'+user)+'); return false;" '
                 + 'style="color:seagreen" '
                 + 'title="'+lang_tooltips.TALK_TIP+'">'+lang_tooltips.TALK_SHORT+'</a>';
    var ucontrib = '<a '
                 + 'href=href="'+lrcGetPageURL('Special:Contributions/'+user)+'" '
                 + 'onClick="liveContrib('+utilde+'); return false;" '
                 + 'style="color:#43CD80" '
                 + 'title="'+lang_tooltips.CONTRIB_TIP+'">'+lang_tooltips.CONTRIB_SHORT+'</a>';
    var udeletedcontrib = '';
    var ublock   = '';
    if(lrcUserHasRight("deletedhistory")) {
       udeletedcontrib = '<a '
                       + 'href="'+lrcGetPageURL('Special:DeletedContributions/'+user)+'" '
                       + 'onClick="liveDeletedContrib('+utilde+'); return false;" '
                       + 'style="color:#43CD80" '
                       + 'title="'+lang_tooltips.DELETEDCONTRIB_TIP+'">'+lang_tooltips.DELETEDCONTRIB_SHORT+'</a>';
    }
    if(lrcUserHasRight("block")) {
       ublock = ' • <a '
              + 'href="'+lrcGetPageURL('Special:Blockip/' + user)+'" '
              + 'onClick="liveBlock('+utilde+'); return false;" '
              + 'style="color:seagreen" '
              + 'title="'+lang_tooltips.BLOCK_TIP+'">'+lang_tooltips.BLOCK_SHORT+'</a>';
    }
    var ueditor  = lrcGetUserLink(user);
    var ligne = '<li><span id="hidden-' + user + '"><small>' + uremove + ' • ' + udiscut + ' • ' + ucontrib + udeletedcontrib + ublock + ' • </small>' + ueditor + '</span></li>';
    tempAr.push(ligne);
  }
  tempAr.sort();
  var lvHidden = document.getElementById('liveHidden');
  lvHidden.innerHTML = "";
  var len = tempAr.length;
  var List = "<ul>";
  for (var n=len-1; n>=0; n--){
    if(tempAr[n]) List += tempAr[n];
  }
  List += "</ul>";
  lvHidden.innerHTML = List;
}

function hideUser(name) {
   lstHidden[name] = true;
   updateHidden();
}

function unhideUser(name) {
   delete lstHidden[name];
   updateHidden();
}

/* 

 Contacts 

 */

function updateFollowContact() {
  var tempAr = new Array();
  for (var user in lstContact) {
    if(!lstContact.hasOwnProperty(user)) continue;
    var timestamp = lstContact[user].ts;
    if (timestamp == 0) continue;
    var utilde = lrcEscapeStr(user);
    var udiscut  = '<a '
                 + 'href="'+lrcGetPageURL(wgFormattedNamespaces[3]+':' + user)+'" '
                 + 'onClick="liveArticle('+lrcEscapeStr(wgFormattedNamespaces[3]+':'+user)+'); return false;" '
                 + 'style="color:seagreen" '
                 + 'title="'+lang_tooltips.TALK_TIP+'">'+lang_tooltips.TALK_SHORT+'</a>';
    var ucontrib = '<a '
                 + 'href=href="'+lrcGetPageURL('Special:Contributions/'+user)+'" '
                 + 'onClick="liveContrib('+utilde+'); return false;" '
                 + 'style="color:#43CD80" '
                 + 'title="'+lang_tooltips.CONTRIB_TIP+'">'+lang_tooltips.CONTRIB_SHORT+'</a>';
    var udeletedcontrib = '';
    var ublock   = '';
    if(lrcUserHasRight("deletedhistory")) {
       udeletedcontrib = '<a '
                       + 'href="'+lrcGetPageURL('Special:DeletedContributions/'+user)+'" '
                       + 'onClick="liveDeletedContrib('+utilde+'); return false;" '
                       + 'style="color:#43CD80" '
                       + 'title="'+lang_tooltips.DELETEDCONTRIB_TIP+'">'+lang_tooltips.DELETEDCONTRIB_SHORT+'</a>';
    }
    if(lrcUserHasRight("block")) {
       ublock = ' • <a '
              + 'href="'+lrcGetPageURL('Special:Blockip/' + user)+'" '
              + 'onClick="liveBlock('+utilde+'); return false;" '
              + 'style="color:seagreen" '
              + 'title="'+lang_tooltips.BLOCK_TIP+'">'+lang_tooltips.BLOCK_SHORT+'</a>';
    }
    var ueditor  = lrcGetUserLink(user);
    var ligne = '<li><span id="contact-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + udiscut + ' • ' + ucontrib+ udeletedcontrib + ublock + ' • </small>' + ueditor + '</span></li>';
    tempAr.push(ligne);
  }
  tempAr.sort();
  var lvContact = document.getElementById('liveContact');
  lvContact.innerHTML = "";
  var List = "<ul>";
  var len = tempAr.length;
  for (var n=len-1; n>=0; n--){
    if(tempAr[n]) List += tempAr[n];
  }
  List += "</ul>";
  lvContact.innerHTML = List;
}

/* 

 Révoqués 

 */

function updateFollowRevoc() {
  var tempAr = new Array();
  for (var user in lstRevoc) {
    if(!lstRevoc.hasOwnProperty(user)) continue;
    var timestamp = lstRevoc[user].ts;
    var utilde = lrcEscapeStr(user);
    var uremove = '<a href="javascript:;" onClick="removeRevoc('+utilde+');" style="color:grey">-</a>';
    var udiscut  = '<a '
                 + 'href="'+lrcGetPageURL(wgFormattedNamespaces[3]+':' + user)+'" '
                 + 'onClick="liveArticle('+lrcEscapeStr(wgFormattedNamespaces[3]+':'+user)+'); return false;" '
                 + 'style="color:seagreen" '
                 + 'title="'+lang_tooltips.TALK_TIP+'">'+lang_tooltips.TALK_SHORT+'</a>';
    var ucontrib = '<a '
                 + 'href=href="'+lrcGetPageURL('Special:Contributions/'+user)+'" '
                 + 'onClick="liveContrib('+utilde+'); return false;" '
                 + 'style="color:#43CD80" '
                 + 'title="'+lang_tooltips.CONTRIB_TIP+'">'+lang_tooltips.CONTRIB_SHORT+'</a>';
    var udeletedcontrib = '';
    var ublock   = '';
    if(lrcUserHasRight("deletedhistory")) {
       udeletedcontrib = '<a '
                       + 'href="'+lrcGetPageURL('Special:DeletedContributions/'+user)+'" '
                       + 'onClick="liveDeletedContrib('+utilde+'); return false;" '
                       + 'style="color:#43CD80" '
                       + 'title="'+lang_tooltips.DELETEDCONTRIB_TIP+'">'+lang_tooltips.DELETEDCONTRIB_SHORT+'</a>';
    }
    if(lrcUserHasRight("block")) {
       ublock = ' • <a '
              + 'href="'+lrcGetPageURL('Special:Blockip/' + user)+'" '
              + 'onClick="liveBlock('+utilde+'); return false;" '
              + 'style="color:seagreen" '
              + 'title="'+lang_tooltips.BLOCK_TIP+'">'+lang_tooltips.BLOCK_SHORT+'</a>';
    }
    var ueditor  = lrcGetUserLink(user);
    var MoreLink = lrcGetAllRevoc(user);
    var ligne = '<li><span id="revoc-' + timestamp + '"><small>' + tsToHhMm(timestamp) + ' • ' + uremove + ' • ' + udiscut + ' • ' + ucontrib + udeletedcontrib + ublock + ' • </small>' + ueditor + ' : ' + lstRevoc[user].nb + ' '+lang_menu.XTIMES + MoreLink + '</span></li>';
    tempAr.push(ligne);
  }
  tempAr.sort();
  var lvRevoc = document.getElementById('liveRevoc');
  lvRevoc.innerHTML = "";
  var List = "<ul>";
  var len = tempAr.length;
  for (var n=len-1; n>=0; n--){
    if(tempAr[n]) List += tempAr[n];
  }
  List += "</ul>";
  lvRevoc.innerHTML = List;
}

function lrcGetAllRevoc(user){
    if(!lstRevoc[user]) return "";
    var pages = lstRevoc[user].pages;
    var RevocLink = '<a href="javascript:;" onclick="lrcShowHideAllRevoc(this);"><b>+</b></a>'
                  + '<ul style="display:none">';
    for(var a=0,l=pages.length;a<l;a++){
        var Page = pages[a].title;
        var Oldid = pages[a].oldid;
        var Time = pages[a].timestamp;
        var Links = new Array();
        Links.time = tsToHhMm(Time);
        Links.page = '<a href="'+lrcGetPageURL(Page)+'" onclick="liveArticle('+lrcEscapeStr(Page)+'); return false;">'+Page+'</a>';
        Links.diff = '<a href="'+lrcGetUglyPageURL(Page, '&diffonly=1&unhide=1&diff=next&oldid='+Oldid)+'" onclick="liveDiff('+lrcEscapeStr(Page)+', \'next\', '+Oldid+'); return false;">'+lang_tooltips.DIFF_SHORT+'</a>';
        RevocLink += '<li><span style="margin-Right:0.5em;font-size:75%">'+Links.time+' – '+Links.page+' ('+Links.diff+')</span></li>';
    }
    RevocLink += '</ul>';
    return RevocLink;
}

function removeRevoc(name) {
   delete lstRevoc[name];
   updateFollowRevoc();
}

function lrcShowHideAllRevoc(Link){
   if(!Link) return false;
   var Span = Link.nextSibling;
   if(!Span) return false;
   if(Span.style.display == "none"){
      Span.style.display = "";
   }else{
      Span.style.display = "none";
   }
}

/* 

 Fonctions de prévisualisation 

 LiveDiff 

 */

// Lien "Marquer cette modification comme relue"

var lrcPatrolLnk;
var lrcPatrolLnkHref = "";

function lrcReplacePatrolLink(Node) {
  var x = getElementsByClass('patrollink',Node,null)[0];
  if (x == null) return false;
  lrcPatrolLnk = x.getElementsByTagName('a')[0];
  lrcPatrolLnkHref = lrcPatrolLnk.href;
  lrcPatrolLnk.href = "javascript:;";
  lrcPatrolLnk.style.color = "darkgreen";
  lrcPatrolLnk.onclick = lrcPatrolEdit;
  return true;
}

function lrcPatrolEdit() {
  var oldLink = lrcPatrolLnkHref;
  if(lrcPatrolLnkHref == "") return;
  lrcPatrolLnkHref = "";
  lrcPatrolLnk.style.color = "silver";
  lrcPatrolLnk.style.cursor = "default";
  lrcPatrolLnk.style.textDecoration = "none";
  wpajax.http({ url: oldLink, onSuccess: lrcAfterPatrolEdit});
}

function lrcAfterPatrolEdit(xmlreq, data) {
  lrcPatrolLnk.innerHTML = "Modification relue";
}

// Requête et affichage Diff

function liveDiff(page, id, oldid) {
  nextDiffNum++;
  lrcAddToHistory("liveDiff", new Array(lrcEscapeStr(page), lrcEscapeStr(id), lrcEscapeStr(oldid)), wgServer+wgScript+'?title='+encodeURIComponent(page)+'&diff='+id+'&oldid='+oldid+'&unhide=1', page + " : diff="+id+' oldid='+oldid);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Diff : <span style='color:red'>"+page+"</span>...</b>");
  wpajax.http({ url: lrcGetUglyPageURL(page, '&diffonly=1&unhide=1&diff='+id+'&oldid='+oldid),
                onSuccess: getDiff, mpage: page, mid: id, moldid:oldid,
                diffNum: nextDiffNum});
}

function getDiff(xmlreq, data) {
  // Cancel if the user has clicked on another link after this one
  if (nextDiffNum != data.diffNum) return;
  var page=data.mpage;
  var oldid=data.moldid;
  var id=data.mid;
  var bC  = getPageContent(xmlreq);
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  var lD = getElementsByClass('diff',bC,null);
  var upage = lrcEscapeStr(page);

  if (lD[0] == null) {
    LP.innerHTML = bC.innerHTML;
    if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  }else {
    if (document.getElementById('showDiffR').checked) {
      var avantEl = getElementsByClass('diff-deletedline',bC,null);
      var apresEl = getElementsByClass('diff-addedline',bC,null);
      var rollback = getElementsByClass('mw-rollback-link',bC,null);
      var revisiondelete = getElementsByClass('mw-revdelundel-link',bC,null);
      var patrol = getElementsByClass('patrollink',bC,null);
        var rl = "";
      if (rollback[0] != null){
        rl += '<span class="mw-rollback-link">'+ rollback[0].innerHTML + '</span>  ';
      }
      if (revisiondelete[0] != null){
        rl += lang_tooltips.REVISIONDELETE_SHORT + ' :';

        for(var a=0,l=revisiondelete.length;a<l;a++){
          var rdl = revisiondelete[a].getElementsByTagName('a')[0];
          var Page = lrcGetArgFromURL(rdl.href, "target");
          var Id = lrcGetArgFromURL(rdl.href, "ids");
          var rdlLink = '<a '
                       + 'href="'+wgServer + wgScript + '?title=Special:Revisiondelete&type=revision&target='+encodeURIComponent(Page)+'&ids='+Id+'" '
                       + 'onClick="liveRevisiondelete('+lrcEscapeStr(Page)+','+Id+'); return false;" '
                       + 'title="'+lang_tooltips.REVISIONDELETE_TIP+' '+Id+'">'+Id+'</a>'
          rl += ' <span class="mw-revdelundel-link">'+rdlLink+'</span> ';
        }
      }
      if (patrol[0] != null){
        rl += ' <span class="patrollink">'+ patrol[0].innerHTML + '</span>';
      }
      if(rl!="") rl += "<br />";
      var avant = "";
      var apres = "";
      var lav = avantEl.length;
      var lap = apresEl.length;
      for(var n=0; n < lav ; n++)
        avant = avant + avantEl[n].innerHTML + "<br />";
      for(var n=0; n < lap ; n++)
        apres = apres + apresEl[n].innerHTML + "<br />";
      LP.innerHTML = rl+"<table width='100%'><tr><td width='50%' class='diff-deletedline' style='vertical-align:top'>"+
                avant+"</td><td class='diff-addedline' style='vertical-align:top'>"+apres+"</td></tr></table>";
    }
    else {
      LP.innerHTML = "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>"+lD[0].innerHTML+"</table>";
    }
  }
  var notPatrolled = lrcReplacePatrolLink(LP);
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  if (typeof (setupTooltips) != 'undefined') {
    setupTooltips(dLP, false, true);
  }
  // Get username of submitter
  var user1 = getElementWithId('mw-diff-otitle2', 'div', bC);
  if (user1 != null) {
    user1 = user1.getElementsByTagName('a')[0].innerHTML;
  }
  var user2 = getElementWithId('mw-diff-ntitle2', 'div', bC);
  if (user2 != null) {
    user2 = user2.getElementsByTagName('a')[0].innerHTML;
  }
  var Previous = false;
  var asPreviousDiff = getElementWithId('differences-prevlink', 'a', bC);
  if(asPreviousDiff !=null){
    var PreviousOldid = lrcGetArgFromURL(asPreviousDiff.href, "oldid");
    if(PreviousOldid){
      Previous = {
                  "url"   : asPreviousDiff.href,
                  "text"  : asPreviousDiff.innerHTML,
                  "title" : (asPreviousDiff.title ? asPreviousDiff.title : ""),
                  "oldid" : PreviousOldid
                 }
    }
  }
  var Next = false;
  var asNextDiff = getElementWithId('differences-nextlink', 'a', bC);
  if (asNextDiff != null){
    var NextOldid = lrcGetArgFromURL(asNextDiff.href, "oldid");
    if(NextOldid){
      Next = {
              "url"   : asNextDiff.href,
              "text"  : asNextDiff.innerHTML,
              "title" : (asNextDiff.title ? asNextDiff.title : ""),
              "oldid" : NextOldid
             }
    }
  }
  buildPreviewBar({
    "Mode"     : "Diff",
    "Url"      : lrcGetPageURL(page),
    "Page"     : page,
    "User1"    : user1,
    "User2"    : user2,
    "Oldid"    : oldid,
    "Previous" : Previous,
    "Next"     : Next,
    "patrolledDiff": !notPatrolled
  });
  updatePreviewWindowAttributes();
  LiveRC_RunHooks("AfterPreviewDiff");
}

/* 

 LiveHist 

 */

function liveHist(page, Params) {
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Hist : <span style='color:red'>"+page+"</span>...</b>");
  var URL = lrcGetUglyPageURL(page, '&action=history');
  if(!Params){
    lrcAddToHistory("liveHist",
                    new Array(lrcEscapeStr(page)),
                    URL,
                    page
                   );
  }else{
    var HistoryParams = new Array();
    for(var param in Params){
      if(Params[param]){
        if(param!="title" && param!="action"){
          HistoryParams.push(param+":"+lrcEscapeStr(Params[param]));
          URL += "&"+param+"="+encodeURIComponent(Params[param]);
         }
      }
    }
    lrcAddToHistory("liveHist",
                    new Array(lrcEscapeStr(page), "{"+HistoryParams.join(",")+"}"),
                    URL,
                    page + " : " + HistoryParams.join(" ")
                   );
  }
  wpajax.http({url:URL, onSuccess: getHist, message: page });
}

function getHist(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var c=data.message;
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildPreviewBar({
    "Mode"  : "Hist",
    "Url"   : lrcGetUglyPageURL(c, '&action=history'),
    "Page"  : c,
    "User1" : ""
  });
  modifyHistInput();
  updatePreviewWindowAttributes();
  LiveRC_RunHooks("AfterPreviewHistory");
}

function modifyHistInput(){
  var LP = document.getElementById( 'livePreview' );
  var SearchForm = getElementWithId('mw-history-searchform', 'form', LP);
  var SInputs = SearchForm.getElementsByTagName('input');
  for(var a=0,l=SInputs.length;a<l;a++){
    if(SInputs[a].type && SInputs[a].type === "submit"){
      var Input = SInputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processHistSearch(this)}
      NewInput.onselect = function(){ processHistSearch(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.parentNode.removeChild(Input);
    }
  }
  var CompareForm = getElementWithId('mw-history-compare', 'form', LP);
  var CInputs = CompareForm.getElementsByTagName('input');
  for(var a=0,l=CInputs.length;a<l;a++){
    if(CInputs[a].type && CInputs[a].type === "submit"){
      var Input = CInputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processHistCompare(this)}
      NewInput.onselect = function(){ processHistCompare(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.parentNode.removeChild(Input);
    }
  }
  var DRButtons = CompareForm.getElementsByTagName('button');
  for(var a=0,l=DRButtons.length;a<l;a++){
    if(DRButtons[a] && DRButtons[a].className && DRButtons[a].className=="mw-history-revisiondelete-button"){
      var Input = DRButtons[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.innerHTML + " (live)";
      NewInput.onclick = function(){ processHistRevisionDelete(this)}
      NewInput.onselect = function(){ processHistRevisionDelete(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.parentNode.removeChild(Input);
    }
  }
}

function processHistSearch(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var page = Params["title"];
  liveHist(page, Params);
}

function processHistCompare(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var page = Params["title"];
  var diff = Params["diff"];
  var oldid = Params["oldid"];
  liveDiff(page, diff, oldid);
}

function processHistRevisionDelete(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var page = Params["title"];
  var Ids = new Array();
  for(var Id in Params){
   if(Id.indexOf("ids[")==0) Ids.push(Id.split("ids[").join("").split("]").join(""));
  }
  if(!Ids[0]) return;
  liveRevisiondelete(page,Ids);
}

/* 

 LiveArticle 

 */

function liveArticle(page, user) {
  lrcAddToHistory("liveArticle", new Array(lrcEscapeStr(page), (user ? lrcEscapeStr(user):lrcEscapeStr(""))), wgServer + wgScript + '?title=' + encodeURIComponent(page) + '&redirect=no', page + (user ? " NewPage : User:"+user :""));
  buildBlanckPreviewBar("<b style='text-decoration: blink;'><span style='color:red'>"+page+"</span>...</b>");
  wpajax.http({url:lrcGetUglyPageURL(page, '&redirect=no'),
          onSuccess: getArticle,
          onFailure: getArticle, /* The return code might be 404 if the page has been deleted. */
          page: page, user:user });
}

function getArticle(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var c=data.page;
  var User=data.user;
  var Url = data.url;
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  if (bC == null) {
    var CreateLink = '<a '
                   + 'href="'+wgServer +wgScript+'?title='+encodeURIComponent(c)+'&action=edit&redlink=1" '
                   + 'onClick="liveEdit('+lrcEscapeStr(c)+', \'&redlink=1\'); return false;";>';
    LP.innerHTML = lang_messages.NOEXIST.split("$1").join(CreateLink).split("$2").join('</a>');
  } else {
    LP.innerHTML = bC.innerHTML;
  }
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildPreviewBar({
    "Mode"  : "Article",
    "Url"   : lrcGetPageURL(c),
    "Page"  : c,
    "User1" : (User ? User : false)
  });
  updatePreviewWindowAttributes();
  LiveRC_RunHooks("AfterPreviewArticle", data);
}

/* 

 LiveContrib 

 */

function liveContrib(user, Params) {
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Contributions : <span style='color:red'>"+user+"</span>...</b>");
  if(!Params){
    var URL = lrcGetPageURL('Special:Contributions/'+user);
    lrcAddToHistory("liveContrib",
                    new Array(lrcEscapeStr(user)),
                    URL,
                    user
                   );
  }else{
    var URL = lrcGetUglyPageURL('Special:Contributions')+"&contribs=user&target="+encodeURIComponent(user);
    var HistoryParams = new Array();
    for(var param in Params){
      if(Params[param]){
        URL += "&"+param+"="+encodeURIComponent(Params[param]);
        if(param!="target") HistoryParams.push(param+":"+lrcEscapeStr(Params[param]));
      }
    }
    lrcAddToHistory("liveContrib",
                    new Array(lrcEscapeStr(user), "{"+HistoryParams.join(",")+"}"),
                    URL,
                    user + " : " + HistoryParams.join(" ")
                   );
  }
  wpajax.http({url:URL, onSuccess: getContrib, message: user });
}

function getContrib(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var user=data.message;
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildPreviewBar({
    "Mode"  : "Contrib",
    "Url"   : lrcGetPageURL("Special:Contributions/" + user),
    "Page"  : "Special:Contributions/"+user,
    "User1" : user
  });
  modifyContribInput();
  LiveRC_RunHooks("AfterPreviewContribs");
}

function modifyContribInput(){
  var LP = document.getElementById( 'livePreview' );
  var Form = LP.getElementsByTagName('form')[0];
  var Inputs = Form.getElementsByTagName('input');
  for(var a=0,l=Inputs.length;a<l;a++){
    if(Inputs[a].type && Inputs[a].type === "submit"){
       var Input = Inputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processContrib(this)}
      NewInput.onselect = function(){ processContrib(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.style.display = "none";
    }
  }
  updatePreviewWindowAttributes();
}

function processContrib(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var user = Params["target"];
  liveContrib(user, Params);
}

/* 

 LiveDeletedContrib 

 */

function liveDeletedContrib(user, Params) {
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>DeletedContributions : <span style='color:red'>"+user+"</span>...</b>");
  if(!Params){
    var URL = lrcGetPageURL('Special:DeletedContributions/'+user);
    lrcAddToHistory("liveDeletedContrib",
                    new Array(lrcEscapeStr(user)),
                    URL,
                    user
                   );
  }else{
    var URL = lrcGetUglyPageURL('Special:DeletedContributions')+"&target="+encodeURIComponent(user);
    var HistoryParams = new Array();
    for(var param in Params){
      if(Params[param]){
        URL += "&"+param+"="+encodeURIComponent(Params[param]);
        if(param!="target") HistoryParams.push(param+":"+lrcEscapeStr(Params[param]));
      }
    }
    lrcAddToHistory("liveDeletedContrib",
                    new Array(lrcEscapeStr(user), "{"+HistoryParams.join(",")+"}"),
                    URL,
                    user + " : " + HistoryParams.join(" ")
                   );
  }
  wpajax.http({url:URL, onSuccess: getDeletedContrib, message: user });
}

function getDeletedContrib(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var user=data.message;
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildPreviewBar({
    "Mode"  : "DeletedContrib",
    "Url"   : lrcGetPageURL("Special:DeletedContributions/" + user),
    "Page"  : "Special:DeletedContributions/"+user,
    "User1" : user
  });
  modifyDeletedContribInput();
  LiveRC_RunHooks("AfterPreviewDeletedContribs");
}

function modifyDeletedContribInput(){
  var LP = document.getElementById( 'livePreview' );
  var Form = LP.getElementsByTagName('form')[0];
  var Inputs = Form.getElementsByTagName('input');
  for(var a=0,l=Inputs.length;a<l;a++){
    if(Inputs[a].type && Inputs[a].type === "submit"){
       var Input = Inputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processDeletedContrib(this)}
      NewInput.onselect = function(){ processDeletedContrib(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.style.display = "none";
    }
  }
  updatePreviewWindowAttributes();
}

function processDeletedContrib(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var user = Params["target"];
  liveDeletedContrib(user, Params);
}

/* 

 LiveLog 

 */
// (:it:User:Jalo)

function liveLog(action , params) {
  var titolo = getLogTitle(action);
  var URLParams = "";
  var HistoryParams = new Array();
  for(var param in params){
    if(params[param]){
      URLParams += "&"+ param + "=" + encodeURIComponent(params[param]);
      HistoryParams.push(param + ":" + lrcEscapeStr(""+params[param]));
    }
  }
  lrcAddToHistory("liveLog", new Array(lrcEscapeStr(action), "{"+HistoryParams.join(",")+"}"), wgServer + wgScript + '?title=Special:Log&type=' + action + URLParams, titolo + " : " + HistoryParams.join(", "));
  buildBlanckPreviewBar("<b style='text-decoration: blink;'><span style='color:red'>"+titolo+"</span>...</b>");
  wpajax.http({url:lrcGetUglyPageURL('Special:Log', '&type=' + action + URLParams), onSuccess: getLog, page:params["page"] , user:params["user"] });
}

function getLogTitle(action){
  var lrcLogNames = {
   'upload':'uploadlogpage',
   'newusers':'newuserlogpage',
   'block':'blocklogpage',
   'delete':'dellogpage',
   'move':'movelogpage',
   'protect':'protectlogpage',
   'patrol':'review-logpage',
   'gblblock':'globalblocking-logpage',
   'renameuser':'renameuserlogpage',
   'import':'importlogpage',
   'globalauth':'centralauth-log-name',
   'gblrights':'centralauth-rightslog-name',
   'abusefilter':'abusefilter-log-name',
   'merge':'mergelog',
   'rights':'rightslog'
  }
  for(var Action in lrcLogNames){
    if(action == Action) return lrcMediawikiMessages[lrcLogNames[Action]];
  }
  return lrcMediawikiMessages["log"];
}

function getLog(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var c = data.page;
  var pref = "Page : ";
  if(!c){
    c=data.user;
    pref = "User : ";
  }
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildBlanckPreviewBar('<b><a href="'+lrcGetPageURL(c)+'" target="_new">'+pref+c+'</a></b>', true);
  modifyLogInput();
  LiveRC_RunHooks("AfterPreviewLog");
}

function modifyLogInput(){
  var LP = document.getElementById( 'livePreview' );
  var Form = LP.getElementsByTagName('form')[0];
  var Inputs = Form.getElementsByTagName('input');
  for(var a=0,l=Inputs.length;a<l;a++){
    if(Inputs[a].type && Inputs[a].type === "submit"){
       var Input = Inputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processLog(this)}
      NewInput.onselect = function(){ processLog(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.style.display = "none";
    }
  }
  updatePreviewWindowAttributes();
}

function processLog(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var action = Params["type"];
  var page = Params["page"];
  var user = Params["user"];
  liveLog(action, {page:page,user:user});
}

/* 

 LiveFilter 
 */

function liveFilter(Page, params) {
  var URL = wgServer;
  if(Page=="AbuseFilter"){
    URL += wgArticlePath.split("$1").join("Special:AbuseFilter/"+params);
    var FilterParams = params;
  }else{
    URL += wgScript + "?title=Special:AbuseLog";
    var FilterParams = new Array();

    for(var param in params){
      if(params[param]){
        URL += "&"+ param + "=" + encodeURIComponent(params[param]);
        FilterParams.push(param + ":" + lrcEscapeStr(""+params[param]));
      }
    }
    FilterParams = "{"+FilterParams.join(",")+"}";
  }
  lrcAddToHistory("liveFilter", new Array(lrcEscapeStr(Page), FilterParams), URL, FilterParams);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Filter: <span style='color:red'></span>...</b>");
  wpajax.http({ url: URL,
                onSuccess: getFilter,
                page: Page,
                args: params
              });
}

function getFilter(xmlreq, data) {
  var Args = data.args;
  var Page = data.page;
  var bC  = getPageContent(xmlreq);
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.dir='rtl';
  LP.dir='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  if(typeof(Args)!="object"){
    var LogLink = '<a href="'+lrcGetUglyPageURL("Special:Abuselog", "&wpSearchFilter="+Args)+'" '
                + ' onclick="liveFilter(\'AbuseLog\', {\'wpSearchFilter\': \''+Args+'\'}); return false;" '
                + '>Abuselog '+Args+'</a>';
    buildBlanckPreviewBar('<b><a href="'+data.url+'" target="_new">'+Page+'</a></b> '+Args, true, LogLink);
  }else{
    var Text = "";
    for(var param in Args){
        Text += param + " = " + Args[param] + " ; ";
    }
    buildBlanckPreviewBar('<b><a href="'+data.url+'" target="_new">'+Page+'</a></b> '+Text, true);
    var InputTD = getElementsByClass("mw-submit", LP, "td")[0];
    if(InputTD){
        var Input = InputTD.firstChild;
        var NewInput = document.createElement('input');
        NewInput.type = "button";
        NewInput.id = "Live_mw-submit";
        NewInput.value = Input.value + " (live)";
        NewInput.onclick = function(){ processFilter(this)}
        NewInput.onselect = function(){ processFilter(this)}
        Input.parentNode.insertBefore(NewInput, Input);
        Input.style.display = "none";
     }
  }
  updatePreviewWindowAttributes();
  LiveRC_RunHooks("AfterPreviewFilter", data);
}

function processFilter(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  liveFilter("AbuseLog", Params);
}

/* 

 LiveDelete 

 */

function liveDelete(Title){
  lrcAddToHistory("liveDelete", new Array(lrcEscapeStr(Title)), lrcGetUglyPageURL(Title, '&action=delete'), Title);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Suppr : <span style='color:red'>"+Title+"</span>...</b>");
  wpajax.http({url: lrcGetUglyPageURL(Title, '&action=delete'),
               onSuccess: getDelete, title:Title});
}

function getDelete(xmlreq, data){
    var c = data.title;
    var bC  = getPageContent(xmlreq, "deleteconfirm");
    if(!bC) bC = getPageContent(xmlreq, "mw-img-deleteconfirm");
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = "";
    PreviewWindow.appendChild(bC);
    var PreviewDiv = document.getElementById( 'divLivePreview' );
    PreviewDiv.dir='rtl';
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    var Input = document.getElementById("wpConfirmB");
    if(!Input) Input = document.getElementById("mw-filedelete-submit");
    var NewInput = document.createElement('input');
    NewInput.type = "button";
    NewInput.id = "Live_wpConfirmB";
    NewInput.value = Input.value + " (live)";
    NewInput.onclick = function(){ processDelete(this)}
    NewInput.onselect = function(){ processDelete(this)}
    Input.parentNode.insertBefore(NewInput, Input);
    Input.style.display = "none";
    buildPreviewBar({
      "Mode"  : "Delete",
      "Url"   : lrcGetPageURL(c),
      "Page"  : c,
      "User1" : ""
    });
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewDelete");
}

function processDelete(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    var action = Form.action;
    var Page = false;
    try{ Page = action.split("?title=")[1].split("&action=delete")[0]; }catch(e){ }
    try{ Page = decodeURIComponent(Page); }catch(e){ }
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL.join("&"),
                  onSuccess:doneDelete,
                  page:Page
                });
}

function doneDelete(ajaxDelete, data){
    var bC  = getPageContent(ajaxDelete);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = bC.innerHTML;
    if(data.data.indexOf("&wpWatch=1")!=-1){
        if(!lstSuivi[data.page]) lstSuivi[data.page] = "--:--";
    }else{
        if(lstSuivi[data.page]) delete lstSuivi[data.page];
    }
}

/* 

 LiveProtect 

 */

function liveProtect(Title){
  lrcAddToHistory("liveProtect", new Array(lrcEscapeStr(Title)), wgServer + wgScript + '?title=' + Title + '&action=protect', Title);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Protect : <span style='color:red'>"+Title+"</span>...</b>");
  wpajax.http({url: lrcGetUglyPageURL(Title, '&action=protect'),
               onSuccess: getProtect, title:Title});
}

function getProtect(xmlreq, data){
    var c = data.title;
    var ProtectionForm  = getPageContent(xmlreq, "mw-Protect-Form");
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = "";
    PreviewWindow.appendChild(ProtectionForm);
    var PreviewDiv = document.getElementById( 'divLivePreview' );
    PreviewDiv.div='rtl';
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    buildPreviewBar({
      "Mode"  : "Protect",
      "Url"   : wgServer + wgScript + '?title=' + encodeURIComponent(c) + '&action=protect',
      "Page"  : c,
      "User1" : ""
    });
    modifyProtectform();
}

function modifyProtectform(){
    var Input = document.getElementById("mw-Protect-submit");
    var NewInput = document.createElement('input');
    NewInput.type = "button";
    NewInput.id = "Live_mw-Protect-submit";
    NewInput.value = Input.value + " (live)";
    NewInput.onclick = function(){ processProtect(this)}
    NewInput.onselect = function(){ processProtect(this)}
    Input.parentNode.insertBefore(NewInput, Input);
    Input.style.display = "none";
    var Cascade = document.getElementById('mwProtect-cascade');
    if(Cascade) Cascade.checked = false;
    var PreviewWindow = document.getElementById("livePreview");

    var ProtectEditSelect  = getElementWithId("mwProtect-level-edit", 'select', PreviewWindow);
    ProtectEditSelect.onchange = function(){ modifyProtectformUpdate(this); };
    var ProtectMoveSelect  = getElementWithId("mwProtect-level-move", 'select', PreviewWindow);
    ProtectMoveSelect.onchange = function(){ modifyProtectformUpdate(this); };

    var ProtectSet = getElementWithId("mwProtectSet", "table", PreviewWindow);
    var Target = ProtectSet.getElementsByTagName('tr')[0].nextSibling;
    var UnchainedInput = document.createElement('input');
    UnchainedInput.id = "mwProtectUnchained";
    UnchainedInput.type = "checkbox";
    UnchainedInput.onclick = function(){ ProtectUnchainedToggle(); };
    var UnchainedLabel = document.createElement('label');
    UnchainedLabel.setAttribute("for", "mwProtectUnchained");
    UnchainedLabel.innerHTML = lrcMediawikiMessages["protect-unchain-permissions"];
    var UnchainedTr = document.createElement('tr');
    var UnchainedTd = document.createElement('td');
    UnchainedTd.appendChild(UnchainedInput);
    UnchainedTd.appendChild(UnchainedLabel);
    UnchainedTr.appendChild(UnchainedTd);
    Target.parentNode.insertBefore(UnchainedTr, Target);

    ProtectUnchainedToggle();
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewProtect");
}

function ProtectUnchainedToggle(){
    var PreviewWindow = document.getElementById("livePreview");
    var ProtectUnchainedInput  = getElementWithId("mwProtectUnchained", 'input', PreviewWindow);
        var ProtectMoveSelect  = getElementWithId("mwProtect-level-move", 'select', PreviewWindow);
        if(ProtectUnchainedInput.checked){
            ProtectMoveSelect.disabled = false;
        }else{
            ProtectMoveSelect.disabled = "disabled";
        }
}

function modifyProtectformUpdate(Select){
    var PreviewWindow = document.getElementById("livePreview");
    var ProtectEditSelect  = getElementWithId("mwProtect-level-edit", 'select', PreviewWindow);
    var ProtectMoveSelect  = getElementWithId("mwProtect-level-move", 'select', PreviewWindow);
    var ProtectUnchainedInput  = getElementWithId("mwProtectUnchained", 'input', PreviewWindow);
    if(!ProtectEditSelect ||!ProtectMoveSelect || !ProtectUnchainedInput ) return;
    if(ProtectUnchainedInput.checked) return;
    var Value = Select.value;
    ProtectEditSelect.value = Value;
    ProtectMoveSelect.value = Value;
}

function processProtect(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    var action = Form.action;
    var Page = false;
    try{ Page = action.split("?title=")[1].split("&action=protect")[0]; }catch(e){ }
    try{ Page = decodeURIComponent(Page); }catch(e){ }
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL.join("&"),
                  onSuccess:doneProtect,
                  page:Page
                });
}

function doneProtect(ajaxProtect, data){
    var bC  = getPageContent(ajaxProtect);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = bC.innerHTML;
    if(data.data.indexOf("&mwProtectWatch=1")!=-1){
        if(!lstSuivi[data.page]) lstSuivi[data.page] = "--:--";
    }else{
        if(lstSuivi[data.page]) delete lstSuivi[data.page];
    }
}

/* 

 LiveBlock 

 */

function liveBlock(UserName){
  lrcAddToHistory("liveBlock", new Array(lrcEscapeStr(UserName)), lrcGetPageURL('Special:Blockip/' + UserName), UserName);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Block : <span style='color:red'>"+UserName+"</span>...</b>");
  wpajax.http({url: lrcGetPageURL('Special:Blockip/' + UserName) ,
               onSuccess: getBlock, user:UserName});
}

function getBlock(xmlreq, data){
    var c = data.user;
    var bC  = getPageContent(xmlreq, "blockip");
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = "";
    PreviewWindow.appendChild(bC);
    var PreviewDiv = document.getElementById( 'divLivePreview' );
    PreviewDiv.div='rtl';
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    var Input = document.getElementsByName("wpBlock")[0];
    var NewInput = document.createElement('input');
    NewInput.type = "button";
    NewInput.id = "Live_wpBlock";
    NewInput.value = Input.value + " (live)";
    NewInput.onclick = function(){ processBlock(this)}
    NewInput.onselect = function(){ processBlock(this)}
    Input.parentNode.insertBefore(NewInput, Input);
    Input.style.display = "none";
    buildPreviewBar({
      "Mode"  : "Block",
      "Url"   : wgServer + wgScript + '?title=Special:Blockip/' + encodeURIComponent(c),
      "Page"  : c,
      "User1" : c
    });
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewBlock");
}

function processBlock(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    var user = Params["wpBlockAddress"];
    var duration = Params["wpBlockExpiry"];
    if(Params["wpBlockOther"]!="") duration = Params["wpBlockOther"];
    var action = Form.action;
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL.join("&"),
                  onSuccess:doneBlock,
                  user:user,
                  duration:duration
                });
}

function doneBlock(ajaxBlock, data){
    var user = data.user;
    var userpage = wgFormattedNamespaces[2]+":"+user;
    var usertalk = wgFormattedNamespaces[3]+":"+user;
    if(data.data.indexOf("&wpWatchUser=1")!=-1){
        if(!lstSuivi[userpage]) lstSuivi[userpage] = "--:--";
        if(!lstSuivi[usertalk]) lstSuivi[usertalk] = "--:--";
    }else{
        if(lstSuivi[userpage]) delete lstSuivi[userpage];
        if(lstSuivi[usertalk]) delete lstSuivi[usertalk];
    }
    var bC  = getPageContent(ajaxBlock);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = bC.innerHTML;
    var user = data.user;
    var duration = data.duration;
    if(user && duration ){
        var Bar = PreviewBarTemplate;
        var UserLink = '<b>'+lrcGetUserLink(user)+' '+lang_messages.BLOCKED+'</b>';
        var BlockAverto = ' <small>'
                        + '<a id="BlockAvertoLink" href="javascript:;" '
                        + 'onClick="doBlockAverto('+lrcEscapeStr(user)+');" title="'+lang_menu.USERMSG+' « '+user+' »">'+lang_menu.USERMSG+'</a> : '
                        + '<input id="BlockAvertoParam" type="text" value="'+lang_messages.BLOCKTEMPLATE+'|'+duration+'" />'
                        + '</small>';
        Bar = Bar.split('$1').join(UserLink);
        Bar = Bar.split('$2').join(" ");
        Bar = Bar.split('$3').join(" ");
        Bar = Bar.split('$4').join(BlockAverto);
        var TabContainer = document.getElementById("livePreviewTitle");
        if(TabContainer) TabContainer.innerHTML = Bar;

    }
}

function doBlockAverto(user){
  var message = document.getElementById("BlockAvertoParam").value;
  var summary = lang_messages.BLOCKAVERTO;
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+wgFormattedNamespaces[3]+":"+user.replace(/&/g, "%26"),
                onSuccess: postLiveAverto,
                user: user, message: message, summary:summary });
}

/* 

 LiveEdit 

 */

function liveEdit(Title, Param){
  lrcAddToHistory("liveEdit", new Array(lrcEscapeStr(Title), (Param?lrcEscapeStr(""+Param):'\'\'')), wgServer + wgScript + '?title=' + Title + '&action=edit' + (Param ? Param : ""), Title + (Param ? ' Param="'+Param+'"' : ""));
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Edit : <span style='color:red'>"+Title+"</span>...</b>");
  wpajax.http({url: lrcGetUglyPageURL(Title, '&action=edit' + (Param ? Param : "")),
               onSuccess: getEdit, title:Title});
}

function getEdit(xmlreq, data){
    var c = data.title;
    var bC  = getPageContent(xmlreq);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = "";
    PreviewWindow.appendChild(bC);
    var PreviewDiv = document.getElementById( 'divLivePreview' );
    PreviewDiv.div='rtl';
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    buildPreviewBar({
      "Mode"  : "Edit",
      "Url"   : wgServer + wgScript + '?title=' + encodeURIComponent(c) + '&action=edit',
      "Page"  : c,
      "User1" : ""
    });
    modifyEditform(bC);
}

function modifyEditform(Editform){
    var inputs = new Array("wpSave", "wpPreview", "wpDiff");
    for(var a=0,l=inputs.length;a<l;a++){
        var Input = document.getElementById(inputs[a]);
        var NewInput = document.createElement('input');
        NewInput.type = "button";
        NewInput.id = "Live_" + Input.id;
        NewInput.value = Input.value + " (live)";
        NewInput.onclick = function(){ processEdit(this)}
        NewInput.onselect = function(){ processEdit(this)}
        Input.parentNode.insertBefore(NewInput, Input);
        Input.style.display = "none";
    }
    currentFocused = document.getElementById("wpTextbox1"); // Do not change variable name : used by insertTags()
    currentFocused.rows = 10;
    try{
        var ToolbarButtons = document.getElementById('toolbar').getElementsByTagName('script')[0].innerHTML;
        eval(ToolbarButtons);
        mwSetupToolbar();
    }catch(e){ }
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewEdit");
}

function processEdit(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    var Type = Input.id.replace(/.*_/g, "");
    ParamsInURL  = ParamsInURL.join("&")+"&"+Type+"=1";
    var action = Form.action;
    var Page = false;
    try{ Page = action.split("?title=")[1].split("&action=submit")[0]; }catch(e){ }
    try{ Page = decodeURIComponent(Page); }catch(e){ }
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL,
                  onSuccess:doneEdit,
                  type:Type,
                  page:Page
                });
}

function doneEdit(ajaxEdit, data){
    var Type = data.type;
    var bC  = getPageContent(ajaxEdit);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = bC.innerHTML;
    if(getElementWithId("editform", 'form', bC)){
        modifyEditform();
        if(Type=="wpDiff") getElementWithId('wikiPreview', 'div', PreviewWindow).style.display = "";
    }else if(Type == "wpSave"){
        PreviewWindow.className = "";
        if(data.data.indexOf("&wpWatchtis=1")!=-1){
            if(!lstSuivi[data.page]) lstSuivi[data.page] = "--:--";
        }else{
            if(lstSuivi[data.page]) delete lstSuivi[data.page];
        }
        LiveRC_RunHooks("AfterPreviewArticle", data);
    }
}

/* 

 LiveMove 

 */

function liveMove(Title){
  lrcAddToHistory("liveMove", new Array(lrcEscapeStr(Title)), lrcGetPageURL("Special:Movepage/"+ Title), Title);
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Move : <span style='color:red'>"+Title+"</span>...</b>");
  wpajax.http({url: lrcGetPageURL("Special:Movepage/"+ Title), onSuccess: getMove, title:Title});
}

function getMove(xmlreq, data){
    var c = data.title;
    var bC  = getPageContent(xmlreq, "movepage");
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = "";
    PreviewWindow.appendChild(bC);
    var PreviewDiv = document.getElementById( 'divLivePreview' );
    PreviewDiv.div='rtl';
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    var MoveSubmit = false;
    var Inputs = bC.getElementsByTagName("input");
    for(var a=0,l=Inputs.length;a<l;a++){
        if(Inputs[a].name && Inputs[a].name == "wpMove") MoveSubmit = Inputs[a];
    }
    if(MoveSubmit){
        var NewInput = document.createElement('input');
        NewInput.type = "button";
        NewInput.id = "Live_wpMove";
        NewInput.name = "Live_wpMove";
        NewInput.value = MoveSubmit.value + " (live)";
        NewInput.onclick = function(){ processMove(this)}
        NewInput.onselect = function(){ processMove(this)}
        MoveSubmit.parentNode.insertBefore(NewInput, MoveSubmit);
        MoveSubmit.style.display = "none";

    }
    buildPreviewBar({
      "Mode"  : "Move",
      "Url"   : lrcGetPageURL('Special:Movepage/'+ c),
      "Page"  : c,
      "User1" : ""
    });
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewMove");
}

function processMove(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    var action = Form.action;
    var OldPage = Params["wpOldTitle"];
    var NewPage = Params["wpNewTitle"];
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL.join("&"),
                  onSuccess:doneMove,
                  oldpage:OldPage,
                  newpage:NewPage
                });
}

function doneMove(ajaxMove, Type){
    var bC  = getPageContent(ajaxMove);
    var PreviewWindow = document.getElementById("livePreview");
    var MoveForm = getElementWithId("movepage", 'form', PreviewWindow)
    if(MoveForm){
        var OldTitle = document.getElementsByName("wpOldTitle")[0].value;
        getMove(ajaxMove, OldTitle);
    }else{
        PreviewWindow.innerHTML = bC.innerHTML;
        if(data.data.indexOf("&wpWatch=1")!=-1){
            if(!lstSuivi[data.oldpage]) lstSuivi[data.oldpage] = "--:--";
            if(!lstSuivi[data.newpage]) lstSuivi[data.newpage] = "--:--";
        }else{
            if(lstSuivi[data.oldpage]) delete lstSuivi[data.oldpage];
            if(lstSuivi[data.newpage]) delete lstSuivi[data.newpage];
        }
    }
}

/* 

 LiveRevisiondelete 

 */

function buildRevisiondeleteBar(Page){
    var PreviewDiv = document.getElementById( 'livePreview' );
    if(!PreviewDiv) return "";
    var HideSpans = getElementsByClass("mw-revdelundel-link", PreviewDiv, "span");
    var HideLinks = new Array();
    for(var a=0,l=HideSpans.length;a<l;a++){
        var Link = HideSpans[a].getElementsByTagName('a')[0];
        var Id = lrcGetArgFromURL(Link.href, "ids");
        var HideLink = '<a href="'+wgServer + wgScript + '?title=Special:Revisiondelete&type=revision&target='+encodeURIComponent(Page)+'&ids='+Id+'" '
                     + 'onClick="liveRevisiondelete('+lrcEscapeStr(Page)+','+Id+'); return false;" '
                     + 'title="'+lang_tooltips.REVISIONDELETE_TIP+' '+Id+'">'+Id+'</a>';
        HideLinks.push(HideLink);
    }
    if(HideLinks.length==0) return "";
    var RevisiondeleteTabs = '<small>'
                           + lang_tooltips.REVISIONDELETE_SHORT
                           + ' : '
                           + HideLinks.join(' | ')
                           + '</small>'
                           + '   •   ';
    return RevisiondeleteTabs;
}

function liveRevisiondelete(Page,Id){
    var URLids = "";
    var Histids = "";
    var HistPamamids = Id;
    if(typeof(Id)=='object'){
        URLids = lrcGetUglyPageURL(Page, '&action=historysubmit&revisiondelete=1&diff=prev&oldid='+Id[0]);
        HistPamamids = new Array();
        for(var Num in Id){
            HistPamamids.push(Num+":"+Id[Num]);
            URLids += "&ids[" + Id[Num] + "]=1";
            Histids += Id[Num] + " ";
        }
        HistPamamids = "{"+HistPamamids.join(",")+"}";
    }else{
        URLids = lrcGetUglyPageURL('Special:Revisiondelete', '&type=revision&target='+encodeURIComponent(Page)+"&");
        URLids += 'ids='+Id;
        Histids = Id;
    }
    lrcAddToHistory("liveRevisiondelete", new Array(lrcEscapeStr(Page), HistPamamids), URLids, Page + " id="+Histids);
    buildBlanckPreviewBar("<b style='text-decoration: blink;'>Revision delete : <span style='color:red'>"+Page+" id="+Histids+"</span>...</b>")
    wpajax.http({ url: URLids, onSuccess: getRevisiondelete, mpage: Page});
}

function getRevisiondelete(xmlreq, data){
    var c = data.mpage;
    var bC  = getPageContent(xmlreq);
    var PreviewDiv = document.getElementById( 'livePreview' );
    PreviewDiv.innerHTML = bC.innerHTML;
    if (PreviewDiv.innerHTML == "undefined") PreviewDiv.innerHTML = bC.xml;
    lrcCloseAll();
    addClass(document.body, "LiveRCPreviewDisplayed");
    buildPreviewBar({
      "Mode"  : "Revisiondelete",
      "Url"   : lrcGetPageURL(c),
      "Page"  : c,
      "User1" : "",
      "User2" : "",
      "patrolledDiff": true
    });
    getRevisiondelete_ModifyInputs();
}

function getRevisiondelete_ModifyInputs(){
    var Form = document.getElementById("mw-revdel-form-revisions");
    if(!Form) return;
    var Input = document.getElementsByName("wpSubmit")[0];
    if(Input){
        var NewInput = document.createElement('input');
        NewInput.type = "button";
        NewInput.id = "Live_Revisiondelete";
        NewInput.value = Input.value + " (live)";
        NewInput.onclick = function(){ processRevisiondelete(this)}
        NewInput.onselect = function(){ processRevisiondelete(this)}
        Input.parentNode.insertBefore(NewInput, Input);
        Input.style.display = "none";
    }
    updatePreviewWindowAttributes();
    LiveRC_RunHooks("AfterPreviewRevisiondelete");
}

function processRevisiondelete(Input){
    var Form = getFormFromThisInput(Input);
    var Params = getFormParams(Form);
    if(!Params) return;
    var Page = decodeURIComponent(Params["target"]);
    var Id = Params["ids"];
    var action = Form.action;
    var headers = new Array();
    headers['Content-Type'] = 'application/x-www-form-urlencoded';
    buildBlanckPreviewBar("<b style='text-decoration: blink;'>Revision delete : <span style='color:red'>"+Page+" id="+Id+"</span>...</b>")
    var ParamsInURL = new Array();
    for(var P in Params){
        if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
    }
    wpajax.http({ url: action,
                  method: "POST",
                  headers: headers,
                  data: ParamsInURL.join("&")+"&wpSubmit=1",
                  onSuccess:doneRevisiondelete,
                  mpage:Page,
                  mid:Id
                });
}

function doneRevisiondelete(xmlreq, data){
    var Page = data.mpage;
    var Id = data.mid;
    var bC  = getPageContent(xmlreq);
    var PreviewWindow = document.getElementById("livePreview");
    PreviewWindow.innerHTML = bC.innerHTML;
    buildPreviewBar({
      "Mode"            : "Revisiondelete",
      "Url"             : lrcGetPageURL(Page),
      "Page"            : Page,
      "Oldid"           : Id,
      "User1"           : "",
      "User2"           : "",
      "patrolledDiff"   : true,
      "RevisiondeleteOK": true
    });
    getRevisiondelete_ModifyInputs();
}

/* 

 LiveWhatLinkshere 

 */

function liveWhatlinkshere(page , params) {
  var URLParams = "";
  var HistoryParams = new Array();
  for(var param in params){
    if(params[param]){
      URLParams += "&"+ param + "=" + encodeURIComponent(params[param]);
      HistoryParams.push(param + ":" + lrcEscapeStr(""+params[param]));
    }
  }
  lrcAddToHistory("liveWhatlinkshere", new Array(lrcEscapeStr(page), "{"+HistoryParams.join(",")+"}"),
lrcGetUglyPageURL('Special:Whatlinkshere/'+page, URLParams), page + " : " + HistoryParams.join(", "));
  buildBlanckPreviewBar("<b style='text-decoration: blink;'>Whatlinkshere <span style='color:red'>"+page+"</span>...</b>");
  wpajax.http({url:lrcGetUglyPageURL('Special:Whatlinkshere/'+page, URLParams), onSuccess: getWhatlinkshere, page:page });
}

function getWhatlinkshere(xmlreq, data) {
  var bC  = getPageContent(xmlreq);
  var c = data.page;
  var LP = document.getElementById( 'livePreview' );
  var dLP = document.getElementById( 'divLivePreview' );
  dLP.div='rtl';
  LP.div='rtl';
  LP.innerHTML = bC.innerHTML;
  if (LP.innerHTML == "undefined") LP.innerHTML = bC.xml;
  lrcCloseAll();
  addClass(document.body, "LiveRCPreviewDisplayed");
  buildBlanckPreviewBar('<b><a href="'+lrcGetPageURL(c)+'" target="_new">'+c+'</a></b>', true);
  modifyWhatlinkshereInput(data.url);
  LiveRC_RunHooks("AfterPreviewWhatlinkshere");
}

function modifyWhatlinkshereInput(url){
  var LP = document.getElementById( 'livePreview' );
  var Form = LP.getElementsByTagName('form')[0];
  var Inputs = Form.getElementsByTagName('input');
  for(var a=0,l=Inputs.length;a<l;a++){
    if(Inputs[a].type && Inputs[a].type === "submit"){
      var Input = Inputs[a];
      var NewInput = document.createElement('input');
      NewInput.type = "button";
      NewInput.value = Input.value + " (live)";
      NewInput.onclick = function(){ processWhatlinkshere(this)}
      NewInput.onselect = function(){ processWhatlinkshere(this)}
      Input.parentNode.insertBefore(NewInput, Input);
      Input.style.display = "none";
    }
  }
  var NewFiltersContainer = document.createElement('p');
  Form.getElementsByTagName('fieldset')[0].appendChild(NewFiltersContainer);
  var FilterFieldset = LP.getElementsByTagName('fieldset')[1];
  if(FilterFieldset){
    var FilterLegend = FilterFieldset.getElementsByTagName('legend')[0];
    NewFiltersContainer.appendChild(document.createTextNode(lrcMediawikiMessages["whatlinkshere-filters"]+' : '));
    FilterLegend.parentNode.removeChild(FilterLegend);
    var FilterLinks = FilterFieldset.getElementsByTagName('a');
    var FiltersTexts = getTextContent(FilterFieldset).split('|');
    var params = {
      "hidetrans"  : "whatlinkshere-hidetrans"  ,
      "hidelinks"  : "whatlinkshere-hidelinks" ,
      "hideredirs" : "whatlinkshere-hideredirs"  ,
      "hideimages" : "whatlinkshere-hideimages"
    };
    for(var param in params){
      var ThisParam = param;
      var ThisParamChecked = ( (lrcGetArgFromURL(url, ThisParam) === '1') ? true : false );
      var NewInput = document.createElement('input');
      NewInput.type = "checkbox";
      NewInput.id = ThisParam;
      NewInput.name = ThisParam;
      NewInput.value = 1;
      if(ThisParamChecked) NewInput.checked = "checked";
      var NewLabel = document.createElement('label')
      NewLabel.setAttribute('for', ThisParam);
      NewLabel.innerHTML = lrcMediawikiMessages[params[param]].split("$1").join(lrcMediawikiMessages["hide"]);
      NewFiltersContainer.appendChild(NewInput);
      NewFiltersContainer.appendChild(NewLabel);
      NewFiltersContainer.appendChild(document.createTextNode(" • "));
    }
    FilterFieldset.parentNode.removeChild(FilterFieldset);
  }
  updatePreviewWindowAttributes(NewLabel);
}

function processWhatlinkshere(Input){
  var Form = getFormFromThisInput(Input);
  var Params = getFormParams(Form);
  var page = Params["target"];
  liveWhatlinkshere(page, Params);
}

/*  */