      var display_supported = (document.getElementById && document.createElement);


      function imgLoadHandler(evt) {
          pic_ready = 1;
          if (pic_ready && html_ready) shrinkAll();
      }

      function shrinkIt(el) {
          if (document.getElementById("body" + el).innerHTML) {
              document.getElementById("body" + el).style.display = "none";
          }
      }

      function expandIt(el) {
          document.getElementById("body" + el).style.display = "block";
      }

      function flipIt(el) {
          if (display_supported) {
              if (document.getElementById("body" + el).style.display != "block") {
                  expandIt(el);
              }  else {
                  shrinkIt(el);
              }
          }
      }


      function flipTree(el) {
          if (display_supported) {
              var i = el;
              var operation;
              var imgstr = document.getElementById("threadimg" + el).src;
			  var pattern = /margin-left: (\d+)px/i;
			  var arr = new Array();
			  var startShift, currShift;
              if ((imgstr).substring(imgstr.length-imgleft.length) == imgleft) {
                  operation = "shrinkIt";
              } else {
                  operation = "expandIt";
              }
			  //popUpProperties(document.getElementById("div"+el).style);
			  arr = pattern.exec(document.getElementById("body"+el).style.cssText);
			  startShift = parseInt(arr[1], 10);
              do {
                  eval(operation + "(i)");
                  i++;
				  if (document.getElementById("body"+i)) {
					  arr = pattern.exec(document.getElementById("body"+i).style.cssText);
					  currShift = parseInt(arr[1], 10);
				  }
              //} while (document.getElementById("div"+i) && document.getElementById("div"+i).forumlevel > document.getElementById("div"+el).forumlevel);
              } while (document.getElementById("body"+i) && currShift > startShift);
          }
      }

      function flipAll() {
          if (display_supported) {
              var i = 0;
              var operation;
              var treeimg;
              var imgstr = document.getElementById("totalimg").src;
              if ((imgstr).substring(imgstr.length-imgleft.length) == imgleft) {
                  operation = "shrinkIt";
                  treeimg = imgright;
                  document.getElementById("totalimg").src = imgright;
              } else {
                  operation = "expandIt";
                  treeimg = imgleft;
              }
              do {
                  eval(operation + "(i)");
                  if (document.getElementById("threadimg" + i)) {
                      document.getElementById("threadimg" + i).src = treeimg;
                  }
                  i++;
              } while (document.getElementById("body"+i));
          }
      }

      function shrinkAll() {
          if (display_supported) {
              var i = 0;
			  if(document.getElementById("body"+i)) {
              do {
                  shrinkIt(i++);
              } while (document.getElementById("body"+i));
			  };
          }
      }

      function reply(parent) {
          mreplywin = window.open('','mreplywin','width=490,height=390,scrollbars=1,status=0,resizeable=1');
          mreplywin.location.href = '/forum/newmessage.php?parent=' + parent;
          mreplywin.focus(); // bring our subwindow to the front
          if (mreplywin.opener == null) mreplywin.opener = window;
      }

      function reply_from_place(parent, place, sub_place) {
          mreplywin = window.open('','mreplywin','width=490,height=390,scrollbars=1,status=0,resizeable=1');
          mreplywin.location.href = '/forum/newmessage.php?parent=' + parent + '&place=' + place + '&sub_place=' + sub_place;
          mreplywin.focus(); // bring our subwindow to the front
          if (mreplywin.opener == null) mreplywin.opener = window;
      }

      function openwin(url) {
          mreplywin = window.open('','mreplywin','width=600,height=510,scrollbars=1,status=0,resizeable=1');
          mreplywin.location.href = url;
          mreplywin.focus(); // bring our subwindow to the front
          if (mreplywin.opener == null) mreplywin.opener = window;
      }

      function openlink (url, w, h) {
          open(url, "", 'menubar=no, directories=no, scrollbars=yes location=no, resizable=no, scrollbars=1, width=' + w + ', height=' + h );
      }

