Advertisement
baivong

[OldEditor] lang_vi

Feb 23rd, 2014
1,384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var imageTag = false;
  2. var theSelection = false;
  3. var bbcodeEnabled = true;
  4. var clientPC = navigator.userAgent.toLowerCase();
  5. var clientVer = parseInt(navigator.appVersion);
  6. var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
  7. var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
  8. var baseHeight;
  9.  
  10. var form_name = 'post',
  11.     text_name = 'message',
  12.     load_draft = false,
  13.     upload = false,
  14.     bbcode = [],
  15.     bbtags = ["[b]", "[/b]", "[i]", "[/i]", "[u]", "[/u]", "[strike]", "[/strike]", "[left]", "[/left]", "[center]", "[/center]", "[right]", "[/right]", "[justify]", "[/justify]", "[quote]", "[/quote]", "[code]", "[/code]", "[spoiler]", "[/spoiler]", "[hide]", "[/hide]", "[list][*]", "[/list]", "[list=1][*]", "[/list]", "[fade]", "[/fade]", "[blur]", "[/blur]", "[flipv]", "[/flipv]", "[fliph]", "[/fliph]", "[scroll]", "[/scroll]", "[updown]", "[/updown]", "[sub]", "[/sub]", "[sup]", "[/sup]", "[table]", "[/table]", "[tr]", "[/tr]", "[td]", "[/td]"],
  16.     imageTag = false,
  17.     help_line = {
  18.         "b": "Văn bản in đậm: [b]văn bản[/b]",
  19.         "i": "Văn bản in nghiêng: [i]văn bản[/i]",
  20.         "u": "Văn bản gạch chân: [u]văn bản[/u]",
  21.         "x": "Văn bản gạch bỏ: [strike]văn bản[/strike]",
  22.         "le": "Căn trái văn bản: [left]văn bản[/left]",
  23.         "ri": "Căn phải văn bản: [left]văn bản[/left]",
  24.         "ce": "Căn giữa văn bản: [center]văn bản[/center]",
  25.         "ju": "Căn đều văn bản: [justify]văn bản[/justify]",
  26.         "q": "Trích dẫn văn bản: [quote]văn bản[/quote]",
  27.         "c": "Hiển thị mã: [code]mã[/code]",
  28.         "sp": "Văn bản ẩn hiện khi click: [spoiler]văn bản[/spoiler]",
  29.         "hi": "Văn bản ẩn yêu cầu trả lời: [hidden]văn bản[/hidden]",
  30.         "l": "Tạo danh sách: [list]danh mục[/list]",
  31.         "o": "Tạo danh sách có thứ tự: [list=1]danh mục[/list]",
  32.         "a": "Thêm mục trong danh sách: [*]",
  33.         "hr": "Dấu phân cách văn bản: [hr]",
  34.         "p": "Chèn hình: [img]URL hình ảnh[/img]",
  35.         "w": "Chèn địa chỉ URL: hoặc [url=Địa chỉ URL ảnh]Tên URL[/url]",
  36.         "h": "Màu chữ: [color=red]văn bản muốn tô màu[/color]. Có thể dùng mã hex",
  37.         "f": "Kích thước văn bản: [size=12]văn bản[/size]",
  38.         "fo": "Chọn font chữ cho văn bản: [font=Tên font]văn bản[/font]",
  39.         "tab": "Chèn bảng: [table][tr][td]văn bản[/td][/tr][/table]",
  40.         "fl": "Chèn Flash: [flash=chiều rộng,chiều cao]Địa chỉ URL flash[/flash]",
  41.         "vd": "Chèn video từ Youtube hoặc Dailymotion",
  42.         "up": "Công cụ Upload ảnh",
  43.         "hlh": "Các BBcode định dạng văn bản khác",
  44.         "sub": "Văn bản nhỏ dưới dòng: [sub]văn bản[/sub]",
  45.         "sup": "Văn bản nhỏ trên dòng: [sup]văn bản[/sup]",
  46.         "k": "Văn bản di chuyển từ phải qua trái: [scroll]văn bản[/scroll]",
  47.         "d": "Văn bản di chuyển từ dưới lên trên: [updown]văn bản[/updown]",
  48.         "v": "Văn bản xoay dọc: [flipv]văn bản[/flipv]",
  49.         "j": "Văn bản xoay ngang: [flipv]văn bản[/flipv]",
  50.         "e": "Văn bản tối dần: [fade]văn bản[/fade]",
  51.         "r": "Văn bản sương mờ: [blur]văn bản[/blur]",
  52.         "ats": "Chức năng tự động lưu trữ nội dung",
  53.         "em" : "Chọn biểu tượng cảm xúc"
  54.     };
  55.  
  56. function helpline(help) {
  57.     if (help.length < 5) {
  58.         $('#helpbox').html(help_line[help]);
  59.     } else {
  60.         $('#helpbox').html(help);
  61.     }
  62. }
  63.  
  64. function bbstyle(bbnumber) {
  65.     if (bbnumber != -1) {
  66.         bbfontstyle(bbtags[bbnumber], bbtags[bbnumber + 1])
  67.     } else {
  68.         insert_text('[*]');
  69.         document.forms[form_name].elements[text_name].focus()
  70.     }
  71. }
  72.  
  73. function bbfontstyle(bbopen, bbclose) {
  74.     theSelection = false;
  75.     var textarea = document.forms[form_name].elements[text_name];
  76.     textarea.focus();
  77.     if ((clientVer >= 4) && is_ie && is_win) {
  78.         theSelection = document.selection.createRange().text;
  79.         if (theSelection) {
  80.             document.selection.createRange().text = bbopen + theSelection + bbclose;
  81.             document.forms[form_name].elements[text_name].focus();
  82.             theSelection = '';
  83.             return
  84.         }
  85.     } else if (document.forms[form_name].elements[text_name].selectionEnd && (document.forms[form_name].elements[text_name].selectionEnd - document.forms[form_name].elements[text_name].selectionStart > 0)) {
  86.         mozWrap(document.forms[form_name].elements[text_name], bbopen, bbclose);
  87.         document.forms[form_name].elements[text_name].focus();
  88.         theSelection = '';
  89.         return
  90.     }
  91.     var caret_pos = getCaretPosition(textarea).start;
  92.     var new_pos = caret_pos + bbopen.length;
  93.     insert_text(bbopen + bbclose);
  94.     if (!isNaN(textarea.selectionStart)) {
  95.         textarea.selectionStart = new_pos;
  96.         textarea.selectionEnd = new_pos
  97.     } else if (document.selection) {
  98.         var range = textarea.createTextRange();
  99.         range.move("character", new_pos);
  100.         range.select();
  101.         storeCaret(textarea)
  102.     }
  103.     textarea.focus();
  104.     return
  105. }
  106.  
  107. function insert_text(text, spaces, popup) {
  108.     var textarea;
  109.     if (!popup) {
  110.         textarea = document.forms[form_name].elements[text_name]
  111.     } else {
  112.         textarea = opener.document.forms[form_name].elements[text_name]
  113.     }
  114.     if (spaces) {
  115.         text = ' ' + text + ' '
  116.     }
  117.     if (!isNaN(textarea.selectionStart)) {
  118.         var sel_start = textarea.selectionStart;
  119.         var sel_end = textarea.selectionEnd;
  120.         mozWrap(textarea, text, '');
  121.         textarea.selectionStart = sel_start + text.length;
  122.         textarea.selectionEnd = sel_end + text.length
  123.     } else if (textarea.createTextRange && textarea.caretPos) {
  124.         if (baseHeight != textarea.caretPos.boundingHeight) {
  125.             textarea.focus();
  126.             storeCaret(textarea)
  127.         }
  128.         var caret_pos = textarea.caretPos;
  129.         caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text
  130.     } else {
  131.         textarea.value = textarea.value + text
  132.     }
  133.     if (!popup) {
  134.         textarea.focus()
  135.     }
  136. }
  137.  
  138. function mozWrap(txtarea, open, close) {
  139.     var selLength = (typeof (txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
  140.     var selStart = txtarea.selectionStart;
  141.     var selEnd = txtarea.selectionEnd;
  142.     var scrollTop = txtarea.scrollTop;
  143.     if (selEnd == 1 || selEnd == 2) {
  144.         selEnd = selLength
  145.     }
  146.     var s1 = (txtarea.value).substring(0, selStart);
  147.     var s2 = (txtarea.value).substring(selStart, selEnd);
  148.     var s3 = (txtarea.value).substring(selEnd, selLength);
  149.     txtarea.value = s1 + open + s2 + close + s3;
  150.     txtarea.selectionStart = selStart + open.length;
  151.     txtarea.selectionEnd = selEnd + open.length;
  152.     txtarea.focus();
  153.     txtarea.scrollTop = scrollTop;
  154.     return
  155. }
  156.  
  157. function storeCaret(textEl) {
  158.     if (textEl.createTextRange) {
  159.         textEl.caretPos = document.selection.createRange().duplicate()
  160.     }
  161. }
  162.  
  163. function caretPosition() {
  164.     var start = null;
  165.     var end = null
  166. }
  167.  
  168. function getCaretPosition(txtarea) {
  169.     var caretPos = new caretPosition();
  170.     if (txtarea.selectionStart || txtarea.selectionStart == 0) {
  171.         caretPos.start = txtarea.selectionStart;
  172.         caretPos.end = txtarea.selectionEnd
  173.     } else if (document.selection) {
  174.         var range = document.selection.createRange();
  175.         var range_all = document.body.createTextRange();
  176.         range_all.moveToElementText(txtarea);
  177.         var sel_start;
  178.         for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
  179.             range_all.moveStart('character', 1)
  180.         }
  181.         txtarea.sel_start = sel_start;
  182.         caretPos.start = txtarea.sel_start;
  183.         caretPos.end = txtarea.sel_start
  184.     }
  185.     return caretPos
  186. }
  187.  
  188. function selectWysiwyg(button, div) {
  189.     var div = document.getElementById(div);
  190.     var visible = div.style.visibility;
  191.     if (visible == 'hidden') {
  192.         var cd = FindXY(button);
  193.         var h = button.offsetHeight;
  194.         var i = 0;
  195.         $('#text_editor_select_controls .select').css('visibility', 'hidden');
  196.         div.style.visibility = 'visible';
  197.         if (div.id != 'sel_smilies' && div.id != 'wsel_smilies') {
  198.             div.style.width = 'auto'
  199.         } else {
  200.             if (!document.getElementById('sel_smilies_content')) {
  201.                 var smilies_content = '<div id="sel_smilies_content" align="center">';
  202.                 for (var smilieid in smilieoptions) {
  203.                     smilies_content += '<button onclick="emoticonp(\'' + smilieoptions[smilieid][2] + '\');selectWysiwyg(this, \'sel_smilies\');return false;"><img alt="' + smilieoptions[smilieid][1] + '" title="' + smilieoptions[smilieid][1] + '" src="' + smilieoptions[smilieid][0] + '" /></button> '
  204.                 }
  205.                 smilies_content += '</div>';
  206.                 div.innerHTML = smilies_content
  207.             }
  208.         }
  209.         overFlowX = cd['x'] + div.offsetWidth - document.body.offsetWidth;
  210.         cd['x'] = overFlowX > 0 ? cd['x'] - overFlowX : cd['x'];
  211.         div.style.left = cd['x'] + 'px';
  212.         div.style.top = (cd['y'] + h) + 'px'
  213.     } else {
  214.         div.style.visibility = 'hidden'
  215.     }
  216. }
  217.  
  218. function BBcodeVideo(id) {
  219.     var matches, url = document.getElementById(id).value;
  220.     var span = document.getElementById('inv_url');
  221.     if (url.indexOf('youtube') != '-1' || url.indexOf('youtu.be') != '-1') {
  222.         if (url != "" && url != null) {
  223.             matches = url.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/);
  224.             if (matches) {
  225.                 url = matches[1]
  226.             }
  227.             if (/^[a-zA-Z0-9_\-]{11}$/.test(url)) {
  228.                 insert_text('[youtube]' + url + '[/youtube]');
  229.                 selectWysiwyg(this, 'video')
  230.             } else {
  231.                 span.innerHTML = "Định dạng video YouTube không hợp lệ"
  232.             }
  233.         }
  234.     } else if (url.indexOf('dailymotion') != '-1') {
  235.         if (url != "" && url != null) {
  236.             matches = url.match(/(http:\/\/)?([a-z]+\.)?(dailymotion\.com\/)([a-zA-Z0-9]+\/)*([a-zA-Z0-9]+)_(.*)/);
  237.             if (matches) {
  238.                 url = matches[5]
  239.             } else {
  240.                 matches = url.match(/(http:\/\/)?([a-z]+\.)?(dailymotion\.com\/)([a-zA-Z0-9\+]+\/)*(.*=)([a-zA-Z0-9]+)/);
  241.                 if (matches) {
  242.                     url = matches[6]
  243.                 }
  244.             }
  245.             if (/^[a-zA-Z0-9]+$/.test(url)) {
  246.                 insert_text('[dailymotion]' + url + '[/dailymotion]');
  247.                 selectWysiwyg(this, 'video')
  248.             } else {
  249.                 span.innerHTML = "Định dạng video Dailymotion không hợp lệ"
  250.             }
  251.         }
  252.     } else {
  253.         span.innerHTML = "URL đã cung cấp không hợp lệ"
  254.     }
  255.     document.getElementById(id).value = ''
  256. }
  257.  
  258. function constructBBcode(bbcode, args, content) {
  259.     var textarea = document.post.message;
  260.     var i = 0;
  261.     var tmp_args = '';
  262.     var tmp_content = '';
  263.     if (bbcode == 'flash' || bbcode == 'img' || (bbcode == 'url' && document.getElementById(content).value != '')) {
  264.         tmp_content += document.getElementById(content).value
  265.     } else {
  266.         tmp_content += document.getElementById(args[0]).value
  267.     }
  268.     if (bbcode == 'flash') {
  269.         if (document.getElementById(args[0]).value > 0 && document.getElementById(args[1]).value > 0) {
  270.             tmp_args += '(' + document.getElementById(args[0]).value + ',' + document.getElementById(args[1]).value + ')'
  271.         }
  272.     } else {
  273.         if (bbcode == 'url' && document.getElementById(args[0]).value != '') {
  274.             tmp_args += '=';
  275.             if (document.getElementById(args[0]).value.indexOf('www.') == 0) {
  276.                 document.getElementById(args[0]).value = 'http://' + document.getElementById(args[0]).value
  277.             }
  278.         }
  279.         while (i < args.length) {
  280.             tmp_args += document.getElementById(args[i]).value;
  281.             document.getElementById(args[i]).value = '';
  282.             if (i != args.length - 1) {
  283.                 tmp_args += ','
  284.             }
  285.             i++
  286.         }
  287.     }
  288.     insert_text('[' + bbcode + tmp_args + ']' + tmp_content + '[/' + bbcode + ']');
  289.     document.getElementById(content).value = ''
  290. }
  291.  
  292. function FindXY(obj) {
  293.     var x = 0,
  294.         y = 0;
  295.     while (obj != null) {
  296.         x += obj.offsetLeft;
  297.         y += obj.offsetTop;
  298.         obj = obj.offsetParent
  299.     }
  300.     return {
  301.         'x': x,
  302.         'y': y
  303.     }
  304. }
  305.  
  306. var mouse_y = 0;
  307. var mouse_x = 0;
  308.  
  309. function get_mouseX(evt) {
  310.     if (!evt) {
  311.         evt = window.event
  312.     }
  313.     if (evt.pageX) {
  314.         return evt.pageX
  315.     } else if (evt.clientX) {
  316.         var offset_temp = 0;
  317.         if (document.documentElement) {
  318.             if (document.documentElement.scrollLeft) {
  319.                 offset_temp = document.documentElement.scrollLeft
  320.             } else {
  321.                 offset_temp = 0
  322.             }
  323.         } else {
  324.             offset_temp = document.body.scrollLeft
  325.         }
  326.         return evt.clientX + offset_temp
  327.     } else {
  328.         return 0
  329.     }
  330. }
  331.  
  332. function get_mouseY(evt) {
  333.     if (!evt) {
  334.         evt = window.event
  335.     }
  336.     if (evt.pageY) {
  337.         return evt.pageY
  338.     } else if (evt.clientY) {
  339.         var offset_temp = 0;
  340.         if (document.documentElement) {
  341.             if (document.documentElement.scrollTop) {
  342.                 offset_temp = document.documentElement.scrollTop
  343.             } else {
  344.                 offset_temp = 0
  345.             }
  346.         } else {
  347.             offset_temp = document.body.scrollTop
  348.         }
  349.         return evt.clientY + offset_temp
  350.     } else {
  351.         return 0
  352.     }
  353. }
  354.  
  355. function get_mouse_pos(evt) {
  356.     if (document.getElementById) {
  357.         mouse_y = (parseInt(get_mouseY(evt)) + 15) + 'px';
  358.         mouse_x = (parseInt(get_mouseX(evt)) + 15) + 'px'
  359.     }
  360. }
  361. if (document.all) {
  362.     document.attachEvent("onmousemove", get_mouse_pos)
  363. } else {
  364.     document.addEventListener("mousemove", get_mouse_pos, true)
  365. }
  366.  
  367. function showhide(vari) {
  368.     var window_width = 0;
  369.     if (document.getElementById('content')) {
  370.         window_width = document.getElementById('content').offsetWidth
  371.     } else {
  372.         window_width = (document.body) ? document.body.clientWidth : window.innerWidth
  373.     }
  374.     if (vari != document.getElementById('plus_menu')) {
  375.         vari.style.top = mouse_y;
  376.         window_width = (document.body) ? document.body.clientWidth : window.innerWidth
  377.     }
  378.     vari.style.display = (vari.style.display == "none") ? '' : 'none';
  379.     var vari_style_width = parseInt(vari.style.width);
  380.     vari_style_width = (!isNaN(vari_style_width)) ? vari_style_width : vari.offsetWidth;
  381.     var element_vari = vari;
  382.     while (vari_style_width == 0 && element_vari.firstChild.offsetWidth) {
  383.         element_vari = element_vari.firstChild;
  384.         vari_style_width = element_vari.offsetWidth
  385.     }
  386.     mouse_x = parseInt(mouse_x);
  387.     while (vari_style_width + mouse_x >= window_width) {
  388.         mouse_x -= 10
  389.     }
  390.     vari.style.left = mouse_x + 'px'
  391. }
  392.  
  393. function insert_search_menu_new(session_id) {
  394.     var session_id = null
  395. }
  396.  
  397. function insert_plus_menu_new(search_where, session_id, add_favourite, watch_topic) {
  398.     var watch = '';
  399.     if (watch_topic) {
  400.         watch = watch_topic + '<br />'
  401.     }
  402.     var favourite = '';
  403.     session_id = (session_id ? '&sid=' + session_id : '');
  404.     if (add_favourite) {
  405.         favourite = search_where.replace(new RegExp("f([0-9]*)(&|&)t=([0-9]*)", "g"), '$3');
  406.         url_favourite = window.url_favourite || ('/search.forum?search_id=favouritesearch&add_favourite=' + favourite + session_id);
  407.         favourite = '<a rel="nofollow" href="' + url_favourite + '">Add to your favourites</a><br />'
  408.     }
  409.     search_where = '&search_where=' + search_where;
  410.     url_newposts = window.url_newposts || ('/search.forum?search_id=newposts' + search_where + session_id);
  411.     url_egosearch = window.url_egosearch || ('/search.forum?search_id=egosearch' + search_where + session_id);
  412.     url_unanswered = window.url_unanswered || ('/search.forum?search_id=unanswered' + search_where + session_id);
  413.     url_watchsearch = window.url_watchsearch || ('/search.forum?search_id=watchsearch' + search_where + session_id);
  414.     url_tellfriend = window.url_tellfriend || ('/tell_friend.forum?f=' + search_where + session_id);
  415.     document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;width:400px;margin-top:8px;z-index:1;"><p class="title-overview row2"><strong>Actions</strong></p><p class="left-overview"><strong><a rel="nofollow" href="' + url_newposts + '">Xem bài mới từ lần truy cập trước</a><br /><a rel="nofollow" href="' + url_egosearch + '">Xem bài của bạn</a><br /><a rel="nofollow" href="' + url_unanswered + '">Xem bài chưa có ai trả lời</a><br /><a rel="nofollow" href="' + url_watchsearch + '">Topic(s) being watched</a></strong></p><hr class="dashed" /><p class="left-overview"><strong>' + watch + favourite + '<a rel="nofollow" href="' + url_tellfriend + '">Send to a friend</a><br /><a rel="nofollow" href="' + self.location.href + '" onclick="link_bbcode();return false">Copy BBCode URL</a><br /><a rel="nofollow" href="javascript:void(0);" onclick="window.print();return false">Print this page</a></strong></p></div>')
  416. }
  417.  
  418. function insert_plus_album_new(search_where, session_id) {
  419.     session_id = (session_id ? '&sid=' + session_id : '');
  420.     document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;margin: 8px 20px 0px 0px;position:absolute;right:20px;width:200px;z-index:1;"><p class="title-overview row2">Actions</p><p class="left-overview"><strong><a rel="nofollow" href="/tell_friend.forum?album=' + search_where + session_id + '">Send to a friend</a></strong></p></div>')
  421. }
  422.  
  423. function insert_plus_pic_new(search_where, session_id) {
  424.     session_id = (session_id ? '&sid=' + session_id : '');
  425.     document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;right:20px;margin-top:20px;z-index:1;"><p class="title-overview row2">Actions</p><p class="left-overview"><strong><a rel="nofollow" href="/tell_friend.forum?pic=' + search_where + session_id + '">Send to a friend</a></strong></p></div>')
  426. }
  427.  
  428. function link_bbcode() {
  429.     intext = "[url=" + self.location.href + "]" + window.document.title + "[/url]";
  430.     if (document.all && !window.opera) {
  431.         window.clipboardData.setData('Text', intext)
  432.     } else {
  433.         prompt('', intext)
  434.     }
  435. }
  436.  
  437. function ShowHideLayer(layer_open, layer_close) {
  438.     if (layer_open != '') {
  439.         expandLayer(layer_open)
  440.     }
  441.     if (layer_close != '') {
  442.         expandLayer(layer_close)
  443.     }
  444. }
  445.  
  446. function ShowHideMenu(layer_open, layer_close, page_id, new_class) {
  447.     if (layer_open != '') {
  448.         expandLayer(layer_open)
  449.     }
  450.     if (layer_close != '') {
  451.         expandLayer(layer_close)
  452.     }
  453.     if (document.getElementById(page_id).className == new_class) {
  454.         document.getElementById(page_id).className = ''
  455.     } else {
  456.         document.getElementById(page_id).className = new_class
  457.     }
  458. }
  459.  
  460. function expandLayer(name) {
  461.     var itm = null;
  462.     if (document.getElementById) {
  463.         itm = document.getElementById(name)
  464.     } else if (document.all) {
  465.         itm = document.all[name]
  466.     } else if (document.layers) {
  467.         itm = document.layers[name]
  468.     }
  469.     if (!itm) {} else if (itm.style) {
  470.         if (itm.style.display == "none") {
  471.             itm.style.display = ""
  472.         } else {
  473.             itm.style.display = "none"
  474.         }
  475.     } else {
  476.         itm.visibility = "show"
  477.     }
  478. }
  479.  
  480. function fa_endpage() {
  481.     if (parent.wbo1_ferme) wbo1_ferme()
  482. }
  483.  
  484. function hdr_ref(object) {
  485.     if (document.getElementById) {
  486.         return document.getElementById(object)
  487.     } else if (document.all) {
  488.         return eval('document.all.' + object)
  489.     } else {
  490.         return false
  491.     }
  492. }
  493.  
  494. function hdr_expand(object) {
  495.     var object = hdr_ref(object);
  496.     if (!object.style) {
  497.         return false
  498.     } else {
  499.         object.style.display = ''
  500.     }
  501.     if (window.event) {
  502.         window.event.cancelBubble = true
  503.     }
  504. }
  505.  
  506. function hdr_contract(object) {
  507.     var object = hdr_ref(object);
  508.     if (!object.style) {
  509.         return false
  510.     } else {
  511.         object.style.display = 'none'
  512.     }
  513.     if (window.event) {
  514.         window.event.cancelBubble = true
  515.     }
  516. }
  517.  
  518. function hdr_toggle(object, open_close, open_icon, close_icon) {
  519.     var object = hdr_ref(object);
  520.     var icone = hdr_ref(open_close);
  521.     if (!object.style) {
  522.         return false
  523.     }
  524.     if (object.style.display == 'none') {
  525.         object.style.display = '';
  526.         icone.src = close_icon
  527.     } else {
  528.         object.style.display = 'none';
  529.         icone.src = open_icon
  530.     }
  531. }
  532.  
  533. function select_switch_col(nomchamp) {
  534.     for (i = 0; i < document.post.length; i++) {
  535.         if (document.post.elements[i].name && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp && document.post.elements[i].disabled != true) {
  536.             document.post.elements[i].checked = !document.post.elements[i].checked
  537.         }
  538.     }
  539. }
  540.  
  541. function disabled1(choix, nomchamp) {
  542.     var formulaire = document.getElementById(choix);
  543.     for (i = 0; i < document.post.length; i++) {
  544.         if (document.post.elements[i].type == 'checkbox' && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp) {
  545.             document.post.elements[i].disabled = ((formulaire.selectedIndex != 2) ? 'disabled' : '')
  546.         }
  547.     }
  548. }
  549.  
  550. function disabled2(choix, nomchamp) {
  551.     var formulaire = document.getElementById(choix);
  552.     for (i = 0; i < document.post.length; i++) {
  553.         if (document.post.elements[i].type == 'checkbox' && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp) {
  554.             document.post.elements[i].disabled = ((formulaire.selectedIndex != 1) ? 'disabled' : '')
  555.         }
  556.     }
  557. }
  558. var agt = navigator.userAgent.toLowerCase();
  559. var originalFirstChild;
  560.  
  561. function createTitle(which, string, x, y) {
  562.     if (typeof (originalFirstChild) == 'undefined') {
  563.         originalFirstChild = document.body.firstChild
  564.     }
  565.     x = parseInt(mouse_x);
  566.     y = parseInt(mouse_y);
  567.     element = document.createElement('div');
  568.     element.style.position = 'absolute';
  569.     element.style.zIndex = 1000;
  570.     element.style.visibility = 'hidden';
  571.     excessWidth = 0;
  572.     if (document.all) {
  573.         excessWidth = 50
  574.     }
  575.     excessHeight = 20;
  576.     element.innerHTML = '<div class="bodyline" style="max-width:400px;"><table cellspacing="0" cellpadding="0" border="0"><tr><td><span class="gen">' + string + '</span></td></tr></table></div>';
  577.     renderedElement = document.body.insertBefore(element, document.body.firstChild);
  578.     renderedWidth = renderedElement.offsetWidth;
  579.     renderedHeight = renderedElement.offsetHeight;
  580.     renderedElement.style.top = (y + 10) + 'px';
  581.     renderedElement.style.left = (x + 10) + 'px';
  582.     var window_width = document.getElementById('content') ? document.getElementById('content').offsetWidth : ((document.body) ? document.body.clientWidth : window.innerWidth);
  583.     while (parseInt(renderedElement.style.left) + renderedElement.offsetWidth >= window_width) {
  584.         renderedElement.style.left = (parseInt(renderedElement.style.left) - 10) + 'px'
  585.     }
  586.     if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1) {
  587.         setTimeout("renderedElement.style.visibility = 'visible'", 1)
  588.     } else {
  589.         renderedElement.style.visibility = 'visible'
  590.     }
  591. }
  592.  
  593. function destroyTitle() {
  594.     if (document.body.firstChild != originalFirstChild) {
  595.         document.body.removeChild(document.body.firstChild)
  596.     }
  597. }
  598.  
  599. function my_getcookie(name) {
  600.     cname = name + '=';
  601.     cpos = document.cookie.indexOf(cname);
  602.     if (cpos != -1) {
  603.         cstart = cpos + cname.length;
  604.         cend = document.cookie.indexOf(";", cstart);
  605.         if (cend == -1) {
  606.             cend = document.cookie.length
  607.         }
  608.         return unescape(document.cookie.substring(cstart, cend))
  609.     }
  610.     return null
  611. }
  612.  
  613. function my_setcookie(name, value, sticky, path) {
  614.     expires = "";
  615.     domain = "";
  616.     if (sticky) {
  617.         expires = "; expires=Wed, 1 Jan 2020 00:00:00 GMT"
  618.     }
  619.     if (!path) {
  620.         path = "/"
  621.     }
  622.     document.cookie = name + "=" + value + "; path=" + path + expires + domain + ';'
  623. }
  624.  
  625. function expandAllLayer(name, open_close, layer_open_close) {
  626.     var itm = null;
  627.     if (document.getElementById) {
  628.         itm = document.getElementById(name)
  629.     } else if (document.all) {
  630.         itm = document.all[name]
  631.     } else if (document.layers) {
  632.         itm = document.layers[name]
  633.     }
  634.     if (!itm) {} else if (itm.style) {
  635.         if (itm.style.display == "none") {
  636.             if ((open_close == "open" && layer_open_close == "open") || (open_close == "close" && layer_open_close == "close")) {
  637.                 itm.style.display = ""
  638.             }
  639.         } else {
  640.             if ((open_close == "close" && layer_open_close == "open") || (open_close == "open" && layer_open_close == "close")) {
  641.                 itm.style.display = "none"
  642.             }
  643.         }
  644.     } else {
  645.         itm.visibility = "show"
  646.     }
  647. }
  648.  
  649. function check(action, formname) {
  650.     var formnamevalue = document.forms[arguments[1]];
  651.     field = formnamevalue.elements.length;
  652.     switch (action) {
  653.     case "select":
  654.         for (i = 0; i < field; i++) {
  655.             formnamevalue.elements[i].checked = true
  656.         }
  657.         break;
  658.     case "unselect":
  659.         for (i = 0; i < field; i++) {
  660.             formnamevalue.elements[i].checked = false
  661.         }
  662.         break
  663.     }
  664. }
  665.  
  666. function refresh_username(selected_username) {
  667.     if ((opener.document.forms['post'].username.value) && (opener.document.forms['post'].ismp)) {
  668.         opener.document.forms['post'].username.value = opener.document.forms['post'].username.value + ';' + selected_username
  669.     } else {
  670.         opener.document.forms['post'].username.value = selected_username
  671.     }
  672.     opener.focus();
  673.     window.close()
  674. }
  675.  
  676. function refresh_username_new(username, fieldname) {
  677.     $('input[name^=' + (fieldname || 'username') + ']:last').val(username);
  678.     if ($.add_username) {
  679.         $.add_username()
  680.     }
  681. }
  682.  
  683. function timestamp() {
  684.     return Math.floor((new Date()).getTime() / 1000)
  685. }
  686.  
  687. function insertChatBoxNew(chatbox_id, chatbox_url) {
  688.     document.getElementById(chatbox_id).innerHTML = '<object data="' + chatbox_url + '" id="frame_chatbox" scrolling="yes" width="100%" height="100%" type="text/html"></object>'
  689. }
  690.  
  691. function insertChatBoxPopup(chatbox_url, l_chatbox_join) {
  692.     document.getElementById('chatbox_popup').innerHTML = '[ <a href="' + chatbox_url + '" target="ChatBox">' + l_chatbox_join + '</a> ]'
  693. }
  694.  
  695. function js_urlencode(text) {
  696.     text = text.toString();
  697.     var matches = text.match(/[\x90-\xFF]/g);
  698.     if (matches) {
  699.         for (var matchid = 0; matchid < matches.length; matchid++) {
  700.             var char_code = matches[matchid].charCodeAt(0);
  701.             text = text.replace(matches[matchid], '%u00' + (char_code & 0xFF).toString(16).toUpperCase())
  702.         }
  703.     }
  704.     return escape(text).replace(/\+/g, "%2B")
  705. }
  706.  
  707. function change_display_by_icon(element, element_id, content_more, content_less, display_special) {
  708.     element.className = (element.className == "icon_less") ? "icon_more" : "icon_less";
  709.     element.style.background = 'url(\'' + ((element.className == "icon_less") ? 'http://illiweb.com/fa/i/tabs_less.gif' : 'http://illiweb.com/fa/i/tabs_more.gif') + '\') no-repeat';
  710.     if (content_more || content_less) {
  711.         element.innerHTML = (element.className == "icon_less") ? content_less : content_more
  712.     }
  713.     if (!display_special) {
  714.         display_special = 'block'
  715.     }
  716.     document.getElementById(element_id).style.display = ((element.className == "icon_more") ? 'none' : display_special);
  717.     my_setcookie('display_sql_info', element.className)
  718. }
  719.  
  720. function switchuploadaddress(file) {
  721.     if (file) {
  722.         document.getElementById('upfile').style.display = 'inline';
  723.         document.getElementById('upurl').style.display = 'none'
  724.     } else {
  725.         document.getElementById('upfile').style.display = 'none';
  726.         document.getElementById('upurl').style.display = 'inline'
  727.     }
  728. }
  729.  
  730. function do_mark(mode, type) {
  731.     if (type == 2) {
  732.         if (mode == 7) {
  733.             for (i = 0; i < form.elements["mark[]"].length; ++i) {
  734.                 radio_box = form.elements["mark[]"][i];
  735.                 if (radio_box.checked == true) {
  736.                     radio_box.checked = false
  737.                 } else {
  738.                     radio_box.checked = true
  739.                 }
  740.             }
  741.         } else {
  742.             if (special_mark_modes[mode] == '') {
  743.                 return
  744.             }
  745.             for (i = 0; i < special_mark_modes[mode].length; ++i) {
  746.                 radio_box = form.elements["mark[]"][special_mark_modes[mode][i]];
  747.                 if (radio_box.checked == true) {
  748.                     radio_box.checked = false
  749.                 } else {
  750.                     radio_box.checked = true
  751.                 }
  752.             }
  753.         }
  754.     } else {
  755.         if (type == 1) {
  756.             var value = false
  757.         } else {
  758.             var value = true
  759.         }
  760.         if (mode == 7) {
  761.             for (i = 0; i < form.elements["mark[]"].length; ++i) {
  762.                 form.elements["mark[]"][i].checked = value
  763.             }
  764.         } else {
  765.             if (special_mark_modes[mode] == '') {
  766.                 return
  767.             }
  768.             for (i = 0; i < special_mark_modes[mode].length; ++i) {
  769.                 form.elements["mark[]"][special_mark_modes[mode][i]].checked = value
  770.             }
  771.         }
  772.     }
  773. }
  774.  
  775. function checkreport() {
  776.     checked = false;
  777.     if (form.elements["mark[]"].length) {
  778.         for (i = 0; i < form.elements["mark[]"].length; ++i) {
  779.             if (form.elements["mark[]"][i].checked == true) {
  780.                 checked = true;
  781.                 break
  782.             }
  783.         }
  784.     } else {
  785.         if (form.elements["mark[]"].checked == true) {
  786.             checked = true
  787.         }
  788.     }
  789.     if (!checked) {
  790.         alert('No report selected!');
  791.         return false
  792.     }
  793.     if (delete_mode) {
  794.         delete_mode = false;
  795.         if (confirm("Are you sure you want to delete this/these report(s)?") == true) {
  796.             form.confirm.value = 1
  797.         } else {
  798.             return false
  799.         }
  800.     }
  801.     return true
  802. }
  803.  
  804. function insert_smilie(smiliepath, smilieid, smilie_code) {
  805.     if (parent.document.getElementById('vB_Editor_001_mode').value == 1) {
  806.         parent.vB_Editor['vB_Editor_001'].insert_text('<img src="' + smiliepath + '" smilieid="' + smilieid + '" /> ', false)
  807.     } else {
  808.         parent.vB_Editor['vB_Editor_001'].insert_text(smilie_code + ' ', false)
  809.     }
  810. }
  811.  
  812. function unban_user(user, id) {
  813.     opener.fetch_object('message').value = '/unban ' + user;
  814.     opener.submitmsg();
  815.     document.getElementById(id).style.display = 'none'
  816. }
  817.  
  818. function checkmodcp(action) {
  819.     field = document.modcp.elements.length;
  820.     switch (action) {
  821.     case "select":
  822.         for (i = 0; i < field; i++) {
  823.             document.modcp.elements[i].checked = true
  824.         }
  825.         break;
  826.     case "unselect":
  827.         for (i = 0; i < field; i++) {
  828.             document.modcp.elements[i].checked = false
  829.         }
  830.         break
  831.     }
  832. }
  833.  
  834. function check_rotation_radiobuttons() {
  835.     if (document.nuffimage_form.elements["nuff_rotation.checked"] == false) document.nuffimage_form.elements["nuff_rotation_d"].checked = false
  836. }
  837.  
  838. function select_switch_search(status) {
  839.     for (i = 0; i < document.post.length; i++) {
  840.         document.post.elements[i].checked = status
  841.     }
  842. }
  843.  
  844. function verify_select() {
  845.     selectedfields = 0;
  846.     for (i = 0; i < document.post.length; i++) {
  847.         if (document.post.elements[i].checked == true) {
  848.             selectedfields++
  849.         }
  850.     }
  851.     if (selectedfields == 0) {
  852.         msg_error = "Please select one subject";
  853.         alert(msg_error);
  854.         return false
  855.     } else {
  856.         return true
  857.     }
  858. }
  859.  
  860. function select_switch_line(numchamp) {
  861.     for (i = (numchamp - 1); i < (numchamp - 1) + 7; i++) {
  862.         if (document.post.elements[i + 6].disabled != true) {
  863.             document.post.elements[i + 6].checked = !document.post.elements[i + 6].checked
  864.         }
  865.     }
  866. }
  867.  
  868. function select_switch_privmsg(status) {
  869.     for (i = 0; i < document.privmsg_list.length; i++) {
  870.         document.privmsg_list.elements[i].checked = status
  871.     }
  872. }
  873.  
  874. function GetParam(name) {
  875.     var match = new RegExp(name + "=([^&]+)", "i").exec(location.search);
  876.     if (match == null) {
  877.         match = new RegExp(name + "=(.+)", "i").exec(location.search)
  878.     }
  879.     if (match == null) {
  880.         return null
  881.     }
  882.     match = match + "";
  883.     result = match.split(",");
  884.     return result[1]
  885. }
  886.  
  887. function set_solved(input, str) {
  888.     if (input) {
  889.         var title = input.value;
  890.         var reg = new RegExp("\\" + str, "g");
  891.         input.value = (reg.test(title)) ? title.replace(reg, '') : str + title
  892.     }
  893. }
  894.  
  895. function bbstyle_table() {
  896.     var nb_row = document.getElementById('table_gui_lines').value;
  897.     var nb_cols = document.getElementById('table_gui_cols').value;
  898.     if (nb_row > 0 && nb_cols > 0) {
  899.         var txtarea = document.post.message;
  900.         if (nb_row > 100) {
  901.             nb_row = 100
  902.         }
  903.         if (nb_cols > 100) {
  904.             nb_cols = 100
  905.         }
  906.         var content = "[table border=\"1\"]\n";
  907.         for (var i = 0; i < nb_row; i++) {
  908.             content += "[tr]\n";
  909.             for (var j = 0; j < nb_cols; j++) {
  910.                 content += "[td] [/td]"
  911.             }
  912.             content += "\n[/tr]"
  913.         }
  914.         content += "\n[/table]";
  915.         if ((clientVer >= 4) && is_ie && is_win) {
  916.             theSelection = document.selection.createRange().text;
  917.             if (theSelection) {
  918.                 document.selection.createRange().text = content;
  919.                 txtarea.focus();
  920.                 theSelection = '';
  921.                 return
  922.             } else {
  923.                 txtarea.value += content
  924.             }
  925.         } else {
  926.             var selLength = txtarea.textLength;
  927.             var selStart = txtarea.selectionStart;
  928.             var selEnd = txtarea.selectionEnd;
  929.             if (selEnd == 1 || selEnd == 2) selEnd = selLength;
  930.             var s1 = (txtarea.value).substring(0, selStart);
  931.             var s2 = (txtarea.value).substring(selStart, selEnd);
  932.             var s3 = (txtarea.value).substring(selEnd, selLength);
  933.             txtarea.value = s1 + content + s3
  934.         }
  935.         txtarea.focus();
  936.         document.getElementById('table_gui_lines').value = '';
  937.         document.getElementById('table_gui_cols').value = '';
  938.         return
  939.     }
  940. }
  941.  
  942. var elem;
  943. var divHeight;
  944. var mouseX;
  945. var mouseY;
  946.  
  947. function returnNumber(str) {
  948.     var result = '';
  949.     for (i = 0; i < str.length; i++) {
  950.         if ((str.charAt(i) * 1) >= 0 && (str.charAt(i) * 1) <= 9) result += str.charAt(i);
  951.         else return result * 1
  952.     }
  953.     return result * 1
  954. }
  955.  
  956. function resizeElement(event, id) {
  957.     var el;
  958.     var x, y;
  959.     elem = document.getElementById(id);
  960.     if (document.all) {
  961.         mouseX = window.event.clientX + document.body.scrollLeft;
  962.         mouseY = window.event.clientY + document.body.scrollTop
  963.     } else {
  964.         mouseX = event.clientX + window.scrollX;
  965.         mouseY = event.clientY + window.scrollY
  966.     }
  967.     divHeight = elem.style.height;
  968.     if (isNaN(divHeight)) divHeight = returnNumber(divHeight);
  969.     if (document.all) {
  970.         document.attachEvent("onmousemove", resize);
  971.         document.attachEvent("onmouseup", stopResize);
  972.         window.event.cancelBubble = true;
  973.         window.event.returnValue = false
  974.     } else {
  975.         document.addEventListener("mousemove", resize, true);
  976.         document.addEventListener("mouseup", stopResize, true);
  977.         event.preventDefault()
  978.     }
  979. }
  980.  
  981. function resize(event) {
  982.     var x, y;
  983.     var minHeight = 100;
  984.     if (document.all) {
  985.         x = window.event.clientX + document.body.scrollLeft;
  986.         y = window.event.clientY + document.body.scrollTop
  987.     } else {
  988.         x = event.clientX + window.scrollX;
  989.         y = event.clientY + window.scrollY
  990.     }
  991.     if (divHeight + y - mouseY < minHeight) elem.style.height = minHeight + "px";
  992.     else elem.style.height = (divHeight + y - mouseY) + "px";
  993.     if (document.all) {
  994.         window.event.cancelBubble = true;
  995.         window.event.returnValue = false
  996.     } else event.preventDefault()
  997. }
  998.  
  999. function stopResize(event) {
  1000.     if (document.all) {
  1001.         document.detachEvent("onmousemove", resize);
  1002.         document.detachEvent("onmouseup", stopResize)
  1003.     } else {
  1004.         document.removeEventListener("mousemove", resize, true);
  1005.         document.removeEventListener("mouseup", stopResize, true)
  1006.     }
  1007. }
  1008.  
  1009. function update_dst(user_gmt, user_dst, session_id) {
  1010.     var params = '';
  1011.     var time_diff = new Date().getTimezoneOffset() / 60;
  1012.     time_diff = time_diff * -1;
  1013.     if (user_dst == 1) {
  1014.         user_gmt++
  1015.     }
  1016.     if (time_diff == user_gmt + 1 || time_diff == user_gmt - 1) {
  1017.         if (time_diff == user_gmt - 1 && user_dst == 0) {
  1018.             params = 'action=gmt&do=-1'
  1019.         } else if (time_diff == user_gmt + 1 && user_dst == 1) {
  1020.             params = 'action=gmt&do=1'
  1021.         } else {
  1022.             params = 'action=dst'
  1023.         }
  1024.         params += '&sid=' + session_id;
  1025.         ajax_exec('updatedst.forum?' + params)
  1026.     }
  1027. }
  1028.  
  1029. function ajax_exec(url) {
  1030.     if (window.XMLHttpRequest) {
  1031.         var http_request_list = new XMLHttpRequest()
  1032.     } else if (window.ActiveXObject) {
  1033.         var http_request_list = new ActiveXObject("Microsoft.XMLHTTP")
  1034.     }
  1035.     http_request_list.onreadystatechange = function () {
  1036.         if (http_request_list.readyState == 4 && http_request_list.status == 200) {
  1037.             var parsed_text = http_request_list.responseText
  1038.         }
  1039.     };
  1040.     http_request_list.open('GET', url, true);
  1041.     http_request_list.send(null)
  1042. }
  1043.  
  1044. function div_marquee(div_id, marquee_id, direction, amount, delay, height, css) {
  1045.     div_id = '#' + div_id;
  1046.     var html = $(div_id).html();
  1047.     var width = $(div_id).empty().width();
  1048.     $(div_id).html('<marquee id="' + marquee_id + '" direction="' + direction + '" scrollamount="' + amount + '" scrolldelay="' + delay + '"' + (isNaN(width) ? '' : ' width="' + width + '"') + ' height="' + height + '"' + (css ? ' class="' + css + '"' : '') + '>' + html + '</marquee>')
  1049. }
  1050.  
  1051. function togglePostMultiQuote(obj) {
  1052.     var toggle = obj.src == multiquote_img_on;
  1053.     obj.src = toggle ? multiquote_img_off : multiquote_img_on;
  1054.     my_setcookie(obj.id, toggle ? '' : '1', true);
  1055.     return false
  1056. }
  1057.  
  1058. function initPostMultiQuote() {
  1059.     var cookie;
  1060.     var obj;
  1061.     cookies = document.cookie.split('; ');
  1062.     for (i = 0, j = cookies.length; i < j; ++i) {
  1063.         if (cookies[i].substring(0, 7) == 'post_mq') {
  1064.             cookie = cookies[i].split('=');
  1065.             if (cookie[1] == '1' && (obj = document.getElementById(cookie[0]))) {
  1066.                 obj.src = multiquote_img_on
  1067.             }
  1068.         }
  1069.     }
  1070. }
  1071.  
  1072. function initSetFunction(f) {
  1073.     if (window.addEventListener) {
  1074.         window.addEventListener('load', f, false)
  1075.     } else if (window.attachEvent) {
  1076.         window.attachEvent('onload', f)
  1077.     }
  1078. }
  1079. initSetFunction(initPostMultiQuote);
  1080.  
  1081. function runLogInPopUp() {
  1082.     var logInPopUpOffsetTop = parseInt($('#login_popup').css('top'));
  1083.     $('#login_popup').css('top', (logInPopUpOffsetTop + ($(document).scrollTop() + logInPopUpTop - logInPopUpOffsetTop) / 8) + 'px');
  1084.     if (my_getcookie('login_popup_closed') != '1') {
  1085.         setTimeout('runLogInPopUp()', 8)
  1086.     }
  1087. }
  1088.  
  1089. function privmsg_add_username(url, after) {
  1090.     $.add_username = function () {
  1091.         if ($('select[name=userfriend]').val() || $('select[name=usergroup]').val()) {
  1092.             $('input[name^=username]:last').after(after).attr('disabled', 'disabled')
  1093.         } else {
  1094.             $('input[name^=username]:last').after(after)
  1095.         }
  1096.     };
  1097.  
  1098.     function find_username(fieldname) {
  1099.         $.get(url + '&fieldname=' + fieldname + '&time=' + timestamp(), '', function (data) {
  1100.             $('#find_username').html(data).jqmShow();
  1101.             $('.jqmOverlay').bgiframe();
  1102.             $('#find_username').bgiframe()
  1103.         });
  1104.         return false
  1105.     }
  1106.  
  1107.     function total_username() {
  1108.         var total = '';
  1109.         $('input[name^=username]').each(function () {
  1110.             total += $(this).val()
  1111.         });
  1112.         return total
  1113.     }
  1114.     $('input[name^=username]').on('change', function () {
  1115.         if (total_username()) {
  1116.             $('select[name=userfriend],select[name=usergroup]').attr('disabled', 'disabled')
  1117.         } else {
  1118.             $('select[name=userfriend],select[name=usergroup]').removeAttr('disabled')
  1119.         }
  1120.     });
  1121.     $('select[name=userfriend]').change(function () {
  1122.         if ($('select[name=userfriend]').val()) {
  1123.             $('input[name^=username],#find_user,select[name=usergroup]').attr('disabled', 'disabled')
  1124.         } else {
  1125.             $('input[name^=username],#find_user,select[name=usergroup]').removeAttr('disabled')
  1126.         }
  1127.     });
  1128.     $('select[name=usergroup]').change(function () {
  1129.         if ($('select[name=usergroup]').val()) {
  1130.             $('select[name=userfriend],select[name=usergroup]').removeAttr('disabled');
  1131.             $('input[name^=username]').val("");
  1132.             $('input[name^=username],#find_user,select[name=userfriend]').attr('disabled', 'disabled')
  1133.         } else {
  1134.             $('input[name^=username],#find_user,select[name=userfriend]').removeAttr('disabled')
  1135.         }
  1136.     });
  1137.     $('#find_user').click(function () {
  1138.         return find_username('username')
  1139.     });
  1140.     $('#add_username').click(function () {
  1141.         if (!$('input[name^=username]:last').attr('disabled')) {
  1142.             $.add_username()
  1143.         }
  1144.     });
  1145.     if (total_username()) {
  1146.         $('select[name=userfriend],select[name=usergroup]').attr('disabled', 'disabled')
  1147.     } else if ($('select[name=userfriend]').val()) {
  1148.         $('input[name^=username],#find_user,select[name=usergroup]').attr('disabled', 'disabled')
  1149.     } else if ($('select[name=usergroup]').val()) {
  1150.         $('input[name^=username],#find_user,select[name=userfriend]').attr('disabled', 'disabled')
  1151.     }
  1152.     $('#find_username').jqm({
  1153.         toTop: true
  1154.     })
  1155. }
  1156. $(function () {
  1157.     if (my_getcookie('login_popup_closed') != '1' && $('#login_popup').length > 0) {
  1158.         logInPopUpLeft = Math.round(($(window).width() - logInPopUpWidth - 16) / 2);
  1159.         logInPopUpTop = Math.round(($(window).height() - logInPopUpHeight - 16) / 2);
  1160.         $('#login_popup').css({
  1161.             left: logInPopUpLeft + 'px',
  1162.             top: logInPopUpTop + 'px',
  1163.             width: logInPopUpWidth + 'px',
  1164.             height: logInPopUpHeight + 'px'
  1165.         });
  1166.         if (logInBackgroundClass) {
  1167.             $('#login_popup_background').addClass(logInBackgroundClass).css('padding', 0)
  1168.         }
  1169.         var logInBackgroundPadding = parseInt($('#login_popup_background').css('padding-top') || $('#login_popup').css('padding-top')) * 2;
  1170.         $('#login_popup_background').css({
  1171.             width: (logInPopUpWidth - logInBackgroundPadding) + 'px',
  1172.             height: (logInPopUpHeight - logInBackgroundPadding) + 'px'
  1173.         });
  1174.         $('#login_popup_iframe').css('display', 'none');
  1175.         $('#login_popup_content').css('display', 'block');
  1176.         $('#login_popup_close').click(function () {
  1177.             my_setcookie('login_popup_closed', '1', true);
  1178.             $('#login_popup').fadeOut('normal');
  1179.             return false
  1180.         });
  1181.         $('#login_popup').fadeIn('slow');
  1182.         runLogInPopUp()
  1183.     }
  1184. });
  1185.  
  1186. $(function () {
  1187.     $(document).on('click', function (e) {
  1188.         $(e.target).closest('.spoiler,.spoiler_content').filter('.spoiler').find('.spoiler_content:first,.spoiler_closed:first').toggleClass('hidden')
  1189.     })
  1190. });
  1191.  
  1192. function FM_widget_share() {
  1193.     var urlpage = document.location.href;
  1194.     if (document.location.href.match(/^(http:\/\/[^\/]*\/t[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/)) {
  1195.         urlpage = document.location.href.replace(/^(http:\/\/[^\/]*\/t[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/, "$1-")
  1196.     } else if (document.location.href.match(/^(http:\/\/[^\/]*\/f[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/)) {
  1197.         urlpage = document.location.href.replace(/^(http:\/\/[^\/]*\/f[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/, "$1-")
  1198.     }
  1199.     if (navigator.language) {
  1200.         var languageinfo = navigator.language.toLowerCase()
  1201.     } else if (navigator.userLanguage) {
  1202.         var languageinfo = navigator.userLanguage.toLowerCase()
  1203.     } else if (navigator.browserLanguage) {
  1204.         var languageinfo = navigator.browserLanguage.toLowerCase()
  1205.     }
  1206.     var fblang = 'locale=en_GB&amp;';
  1207.     var gpluslang = '';
  1208.     if (languageinfo.substr(0, 2) == "ar") {
  1209.         gpluslang = "{lang: 'ar'}"
  1210.     } else if (languageinfo.substr(0, 2) == "en") {
  1211.         if (languageinfo.substr(3, 2) == "gb") {
  1212.             fblang = 'locale=en_GB&amp;';
  1213.             gpluslang = "{lang: 'en-GB'}"
  1214.         }
  1215.     } else if (languageinfo.substr(0, 2) == "es") {
  1216.         gpluslang = "{lang: 'es'}"
  1217.     } else if (languageinfo.substr(0, 2) == "fr") {
  1218.         fblang = 'locale=fr_FR&amp;';
  1219.         gpluslang = "{lang: 'fr'}"
  1220.     } else if (languageinfo.substr(0, 2) == "pt") {
  1221.         if (languageinfo.substr(3, 2) == "br") {
  1222.             fblang = 'locale=pt_BR&amp;';
  1223.             gpluslang = "{lang: 'pt-BR'}"
  1224.         } else {
  1225.             fblang = 'locale=pt_PT&amp;';
  1226.             gpluslang = "{lang: 'pt-PT'}"
  1227.         }
  1228.     } else if (languageinfo.substr(0, 2) == "ru") {
  1229.         gpluslang = "{lang: 'ru'}"
  1230.     }
  1231.     var content = '';
  1232.     var gscript = document.createElement('script');
  1233.     gscript.type = 'text/javascript';
  1234.     gscript.src = 'https://apis.google.com/js/plusone.js';
  1235.     if (gpluslang != '') {
  1236.         if (gscript.canHaveChildren == null || gscript.canHaveChildren) {
  1237.             var gpt = document.createTextNode(gpluslang);
  1238.             gscript.appendChild(gpt)
  1239.         } else {
  1240.             gscript.text = gpluslang
  1241.         }
  1242.     }
  1243.     document.getElementById('FM_widget_share').appendChild(gscript);
  1244.     content += '<div class="g-plusone" data-size="tall" data-count="true" href="' + urlpage + '"></div>';
  1245.     content += '<a href="http://twitter.com/share" class="twitter-share-button" data-url="' + urlpage + '" data-count="vertical">Tweet</a><scr' + 'ipt type="text/javascript" src="http://platform.twitter.com/widgets.js"></scr' + 'ipt>';
  1246.     content += '<iframe src="http://www.facebook.com/plugins/like.php?' + fblang + 'href=' + encodeURIComponent(urlpage) + '&amp;send=false&amp;layout=box_count&amp;width=60&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=60" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:60px; height:60px;" allowTransparency="true"></iframe>';
  1247.     $("#FM_widget_share").append(content)
  1248. }
  1249.  
  1250. $(function () {
  1251.     $('.blank a').attr('target', '_blank');
  1252.     if (document.getElementById("FM_widget_partners") != null) {
  1253.         var content = '';
  1254.         content += "";
  1255.         if (content != '') {
  1256.             $("#FM_widget_partners").append(content)
  1257.         }
  1258.     }
  1259.     if (document.getElementById("FM_widget_share") != null) {
  1260.         FM_widget_share()
  1261.     }
  1262. });
  1263.  
  1264. var FA = (function (FA) {
  1265.     FA.Lang = {
  1266.         'Image_enlarge': "Enlarge this image",
  1267.         'Click_to_resize': "Reduce this image",
  1268.         'Click_to_see_fullsize': "Click to see fullsize"
  1269.     };
  1270.     return FA
  1271. }(FA || {}));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement