﻿// JScript File

function _mfShowHideParentThread(pintId)
{
  var objImg = document.getElementById('_threadimgid_' + pintId);
  var objRow = document.getElementById('_threadrowid_' + pintId);
  if (objImg.src.toLowerCase().indexOf('plus') != -1)
  {       
    objImg.src = objImg.src.toLowerCase().replace('plus', 'minus');
    objImg.title = 'Collapse this thread';
    objRow.className = objRow.className.replace('min', 'max');
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + pintId).innerHTML, 1);
  }
  else
  {
    objImg.src = objImg.src.toLowerCase().replace('minus', 'plus');
    objImg.title = 'Expand this thread';
    objRow.className = objRow.className.replace('max', 'min');
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + pintId).innerHTML, 0);
  }
}
function _mfShowHideChildThread(pintId)
{
  var objImg = document.getElementById('_threadimgid_' + pintId);
  var objRow = document.getElementById('_threadrowid_' + pintId);
  if (objImg.src.toLowerCase().indexOf('plus') != -1)
  {       
    objImg.src = objImg.src.toLowerCase().replace('plus', 'minus');
    objImg.title = 'Collapse this thread';
    objRow.style.display = '';
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + pintId).innerHTML, 1);
  }
  else
  {
    objImg.src = objImg.src.toLowerCase().replace('minus', 'plus');
    objImg.title = 'Expand this thread';
    objRow.style.display = 'none';
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + pintId).innerHTML, 0);
  }
}
function _mfExpandAll()
{
  var intLoop = 1;
  while (document.getElementById('_threadrowid_' + intLoop))
  {
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + intLoop).innerHTML, 1);
    if (document.getElementById('_threadrowid_' + intLoop).className != '')
    {
      document.getElementById('_threadimgid_' + intLoop).src = document.getElementById('_threadimgid_' + intLoop).src.toLowerCase().replace('plus', 'minus');
      document.getElementById('_threadimgid_' + intLoop).title = 'Collapse this thread';
      document.getElementById('_threadrowid_' + intLoop).className = document.getElementById('_threadrowid_' + intLoop).className.replace('min', 'max');
    }
    else
    {
      document.getElementById('_threadimgid_' + intLoop).src = document.getElementById('_threadimgid_' + intLoop).src.toLowerCase().replace('plus', 'minus');
      document.getElementById('_threadimgid_' + intLoop).title = 'Collapse this thread';
      document.getElementById('_threadrowid_' + intLoop).style.display = '';
    }          
    intLoop++;
  }
}
function _mfCollapseAll()
{
  var intLoop = 1;
  while (document.getElementById('_threadrowid_' + intLoop))
  {
    _mfSetShowHideCookie('_ThreadState_' + document.getElementById('_threadid_' + intLoop).innerHTML, 0);
    if (document.getElementById('_threadrowid_' + intLoop).className != '')
    {
      document.getElementById('_threadimgid_' + intLoop).src = document.getElementById('_threadimgid_' + intLoop).src.toLowerCase().replace('minus', 'plus');
      document.getElementById('_threadimgid_' + intLoop).title = 'Expand this thread';
      document.getElementById('_threadrowid_' + intLoop).className = document.getElementById('_threadrowid_' + intLoop).className.replace('max', 'min');
    }
    else
    {
      document.getElementById('_threadimgid_' + intLoop).src = document.getElementById('_threadimgid_' + intLoop).src.toLowerCase().replace('minus', 'plus');
      document.getElementById('_threadimgid_' + intLoop).title = 'Expand this thread';
      document.getElementById('_threadrowid_' + intLoop).style.display = 'none';
    }          
    intLoop++;
  }
}
function _mfSetShowHideCookie(pstrName, pstrValue)
{
  var cookiestring = pstrName + "=" + escape(pstrValue) + ";EXPIRES=31/12/2050;";
  document.cookie=cookiestring;
}
function _StartThread(pintTId)
{
  var AvailHeight=screen.availHeight;
  var AvailWidth=screen.availWidth;
  var PopupHeight=400;
  var PopupWidth=500;
  var PopupTop= (AvailHeight / 2) - (PopupHeight / 2);
  var PopupLeft=(AvailWidth / 2) - (PopupWidth / 2);
  window.open('/Modules/ICB/Forum/Property Pages/StartThread.aspx?TId=' + pintTId, 'StartTopic', 'width=' + PopupWidth + ', height=' + PopupHeight + ', Top=' + PopupTop + ', Left=' + PopupLeft + ', status=yes, resizable=yes')
}
function _WatchTopic(pintWId, pintTId)
{
  var AvailHeight=screen.availHeight;
  var AvailWidth=screen.availWidth;
  var PopupHeight=275;
  var PopupWidth=400;
  var PopupTop= (AvailHeight / 2) - (PopupHeight / 2);
  var PopupLeft=(AvailWidth / 2) - (PopupWidth / 2);
  window.open('/Modules/ICB/Forum/Property Pages/WatchTopic.aspx?WId=' + pintWId + '&TId=' + pintTId, 'WatchForum', 'width=' + PopupWidth + ', height=' + PopupHeight + ', Top=' + PopupTop + ', Left=' + PopupLeft + ', status=yes, resizable=yes')
}
function _StopWatchingTopic(pintWId, pintTId)
{
  var URL=window.location.href;
  if (confirm('Are you sure you want to stop watching this topic?'))
  {
    if (URL.toLowerCase().indexOf('?') == -1)
      URL = URL + '?SWTId=' + pintTId;
    else
      URL = URL + '&SWTId=' + pintTId;
    window.location.href=URL;
  }
}                      


