function addToCount(Value) {
    oValue = document.getElementById("NewForumCounter").title;
    var oCounter = new Array;
    var mCounter = new Array;
    var vCounter = new Array;
    var i;
    var k=0;
    var m=3;
   
    while((i=Value.indexOf(';'))!=-1) {
       oCounter[k] = Value.substring(0, i);
       Value=Value.substring(i + 1);
       k++;
     }

    k=0;
    while((i=oValue.indexOf(';'))!=-1) {
       mCounter[k] = oValue.substring(0, i);
       oValue=oValue.substring(i + 1);
       k++;
     }

    document.getElementById("NewForumCounter").title = "";

    for (i=0; i < m; i++) {
      document.getElementById("NewForumCounter").title = document.getElementById("NewForumCounter").title + (parseInt(oCounter[i]) + parseInt(mCounter[i])) + ";"      
     }
}

function getCount() {
    var vCount = new Array;
    var Value = document.getElementById("NewForumCounter").title;
    var i;
    var k=0;
    var m=3;   
     
    while((i=Value.indexOf(';'))!=-1) {
       vCount[k] = Value.substring(0, i);
       Value=Value.substring(i + 1);
       k++;
    }
    
    document.write('На форуме: <b>',vCount[2],'</b> тем')
}

var ns6=document.getElementById&&!document.all?1:0

var head="display:''"
var folder=''

function expandit(curobj){
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
if (folder.display=="none")
folder.display=""
else
folder.display="none"
}

function buddy_pop() { window.open('index.{ibf.vars.php_ext}?act=buddy&s={ibf.session_id}','BrowserBuddy','width=300,height=380,resizable=yes,scrollbars=yes'); }
function chat_pop(cw,ch)  { window.open('index.{ibf.vars.php_ext}?s={ibf.session_id}&act=chat&pop=1','Chat','width='+cw+',height='+ch+',resizable=yes,scrollbars=yes'); }
function multi_page_jump( url_bit, total_posts, per_page )
{
pages = 1; cur_st = parseInt("{$ibforums->input['st']}"); cur_page  = 1;
if ( total_posts % per_page == 0 ) { pages = total_posts / per_page; }
 else { pages = Math.ceil( total_posts / per_page ); }
msg = "Введите номер страницы, к которой хотите перейти" + "Количество страниц - " + pages;
if ( cur_st > 0 ) { cur_page = cur_st / per_page; cur_page = cur_page -1; }
show_page = 1;
if ( cur_page < pages )  { show_page = cur_page + 1; }
if ( cur_page >= pages ) { show_page = cur_page - 1; }
 else { show_page = cur_page + 1; }
userPage = prompt( msg, show_page );
if ( userPage > 0  ) {
        if ( userPage < 1 )     {    userPage = 1;  }
        if ( userPage > pages ) { userPage = pages; }
        if ( userPage == 1 )    {     start = 0;    }
        else { start = (userPage - 1) * per_page; }
        window.location = url_bit + "&st=" + start;
}
}

var mem_Guest = "{ibf.member.name}";


function getPostObj(id) {
itm = null;
if (document.getElementById) {
   itm = document.getElementById(id);
}
else if (document.all) {
   itm = document.all[id];
}
else if (document.layers) {
   itm = document.layers[id];
}
return itm;
}
function layer(layer_id) {
  var full_head = " <b>СКРЫТАЯ ИНФОРМАЦИЯ:</b></td><td align='right'><input type='button' class='codebuttons' style='font-weight:bold;float:center;width:80px;height:20px' value='СКРЫТЬ' /></td></tr></table>";
  var short_head = " <b>СКРЫТАЯ ИНФОРМАЦИЯ:</b></td><td align='right'><input type='button' class='codebuttons' style='font-weight:bold;float:center;width:80px;height:20px' value='ПОКАЗАТЬ' /></td></tr></table>";
  var id = document.getElementById("layer_" + layer_id);
  var head = document.getElementById("a_layer_" + layer_id);
  if (id.style.display == "none") {
   head.innerHTML = "<table width='100%'><tr><td align='left'><img src=\"http://imtw.ru/graf/sminus.gif\" /> " + full_head;
   id.style.display = "";
  }
  else {
   head.innerHTML = "<table width='100%'><tr><td align='left'><img src=\"http://imtw.ru/graf/splus.gif\" /> " + short_head;
   id.style.display = "none";
  }
}
   function changePost(id, author) {
      var PostValue = getPostObj(id).innerHTML;
  var PostTableOld_ie = '<TABLE cellSpacing=1 cellPadding=3 width="95%" align=center >';
  var PostTableOld_opera = '<TABLE align="center" width="95%" cellpadding="3" cellspacing="1">';
      var PostTableNew = "<table class='posttable' align='center' width='95%' cellpadding='3' cellspacing='1'>";      
  var quoteOld = "<TD><B>QUOTE</B>";
      var quoteNew = "<td class='quotetitle' ><b>   Цитата</b>";
      var codeOld = "<TD><B>CODE</B>";
      var codeNew = "<td class='codetitle'><b>   Код</b>";
      var htmlOld = "<TD><B>HTML</B>";
      var htmlNew = "<td class='htmltitle'><b>   HTML-Код</b>";
      var sqlOld = "<TD><B>SQL</B>";
      var sqlNew = "<td class='sqltitle'><b>   SQL-Код</b>";
   while(PostValue.indexOf(PostTableOld_ie) != -1) {
        PostValue = PostValue.replace(PostTableOld_ie,PostTableNew);
      }
   while(PostValue.indexOf(PostTableOld_opera) != -1) {
        PostValue = PostValue.replace(PostTableOld_opera,PostTableNew);
      }
      while(PostValue.indexOf(quoteOld) != -1) {
        PostValue = PostValue.replace(quoteOld,quoteNew);
      }          
      while(PostValue.indexOf(codeOld) != -1) {
        PostValue = PostValue.replace(codeOld,codeNew);
      } 
      while(PostValue.indexOf(htmlOld) != -1) {
        PostValue = PostValue.replace(htmlOld,htmlNew);
      } 
      while(PostValue.indexOf(sqlOld) != -1) {
        PostValue = PostValue.replace(sqlOld,sqlNew);
      }
   var date = new Date();
   while(PostValue.indexOf("[SPOILER]")!=-1 && PostValue.indexOf("[/SPOILER]")!=-1 ) {
      if (PostValue.indexOf("[SPOILER]") > PostValue.indexOf("[/SPOILER]")) { 
        PostValue = PostValue.replace("[/SPOILER]","[плохой тег]");
      } else {
     var i = date.getTime() + "" + Math.round(Math.random() * 1000) + 1;
        PostValue = PostValue.replace("[SPOILER]", '<table width="100%"><tr><td align="center"><div class="sp-top"><b>  Спойлер</b></div><div class="sp-wrap" id="a_layer_' + i + '" onclick="layer(\'' + i + '\'); return false;"><table width="100%"><tr><td align="left"><img src="http://imtw.ru/graf/splus.gif"/>  <b>СКРЫТАЯ ИНФОРМАЦИЯ:</b></td><td align="right"><input type="button" class="codebuttons" style="font-weight:bold;float:center;width:80px;height:20px" value="ПОКАЗАТЬ" /></td></tr></table></div><div class="sp-body"id="layer_' + i + '" style="display: none"><div>');
        PostValue = PostValue.replace("[/SPOILER]", "</div></div></td></tr></table>");
      }
   }
   getPostObj(id).innerHTML = PostValue;
}


function Online() {
var USER_online = frames.us_on.document.getElementById('user_on').innerText;
var data = document.getElementsByTagName("div");    
 for (var i = 0; i < data.length; i++) {
  if (!data[i].getAttribute("user")) continue; {
  var name = data[i].getAttribute("user");
  var on_i = USER_online.indexOf('~%' + name + '%~');
   if ((name == mem_Guest) || (on_i >= 0)) {        
   data[i].innerHTML = "<img src='http://imtw.ru/graf/on.gif' title='Пользователь на форуме'>";
   } else {
   USER_online = USER_online.replace(name,'~%' + name + '%~');
   var on = USER_online.indexOf('~%' + name + '%~');
    if (on >= 0) {      
    data[i].innerHTML = "<img src='http://imtw.ru/graf/on.gif' title='Пользователь на форуме'>";
    } else {
    data[i].innerHTML = "<img src='http://imtw.ru/graf/off.gif' title='Пользователь вне форума'>";
    }
   } 
  }
 
 }
}