﻿function hide_getposts() {
req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
req.open('GET', '/index/8', false);
req.send(null);
curposts=parseInt($(req.responseText).find('#uposts').html());}

function hide_load(id) {
msg=$("#mpost"+id).html();
$("#mpost"+id).html('Загрузка..');
if(!window.hide_rq && !window.curposts) hide_getposts(); hide_rq=1;
msg_posts=parseInt(msg.match(/\[hide\=([0-9]+)\][\S\n\s]+\[\/hide\]/)[1]);
if(msg_posts>curposts) {
msg=msg.replace(/\[hide\=([0-9]+)\]([\S\n\s]+)\[\/hide\]/,'<div style="border:1px solid #A7A7A7; padding: 10px;color:red;"><b>Скрытый текст. Вам необходимо набрать <span style="color:blue">'+msg_posts+'</span> сообщений. Сейчас у вас <font color="#696969">'+curposts+'</font> сообщений.</b></div>');}else {msg=msg.replace('[hide='+msg_posts+']','<div style="border:1px solid #A7A7A7; padding: 10px;"><span style="color:black"><b><span style="color:red">Скрытый текст за <span style="color:blue">('+msg_posts+')</span> сообщений:</span></b><br><hr><br>').replace('[/hide]','</div>');}
$("#mpost"+id).html(msg);
if(msg.indexOf('[hide=')>-1) hide_load(id);}
