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

      var imgup = "/images/mfclosed.gif";
      var imgdown = "/images/mfopen.gif";
      var imgleft = "/images/arrowleft.gif";
      var imgright = "/images/arrowright.gif";

      var pic_ready = 0;
      var html_ready = 0;

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

      var imgup_load = new Image();
      imgup_load.src = imgup;
      imgup_load.onload = imgLoadHandler;

      var imgdown_load = new Image();
      imgdown_load.src = imgdown;

      var imgleft_load = new Image();
      imgleft_load.src = imgleft;

      var imgright_load = new Image();
      imgright_load.src = imgright;

      function shrinkIt(el) {
	      if(document.getElementById("body" + el))
		  {
            if (document.getElementById("body" + el).innerHTML.length > 0) 
		  	  {
              	document.getElementById("body" + el).style.display = "none"; 
              	document.getElementById("img" + el).src = imgup_load.src; 
              	document.getElementById("sign" + el).innerHTML = "(+)"; 
			  } else {
              	document.getElementById("sign" + el).innerHTML = "(--)"; 
			  };
		  };	  
      }

      function expandIt(el) {
	  	 if (document.getElementById("body" + el).innerHTML.length > 0)
		  {
          	document.getElementById("body" + el).style.display = "block";
          	document.getElementById("img" + el).src = imgdown_load.src;
          	document.getElementById("sign" + el).innerHTML = "(-)";
		  };	
      }

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

	function popUpProperties(inobj) {
		op = window.open();
		op.document.open('text/plain');
		for (objprop in inobj) {
		op.document.write(objprop + ' => ' + inobj[objprop] + '<br>\n');
		}
		op.document.close();
	}

      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";
                  document.getElementById("threadimg" + el).src = imgright;
              } else {
                  operation = "expandIt";
                  document.getElementById("threadimg" + el).src = imgleft;
              }
			  //popUpProperties(document.getElementById("div"+el).style);
			  arr = pattern.exec(document.getElementById("div"+el).style.cssText);
			  startShift = parseInt(arr[1], 10);
              do {
                  eval(operation + "(i)");
                  i++;
				  if (document.getElementById("div"+i)) {
					  arr = pattern.exec(document.getElementById("div"+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("div"+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;
                  document.getElementById("totalimg").src = imgleft;
              }
              do {
                  eval(operation + "(i)");
                  if (document.getElementById("threadimg" + i)) {
                      document.getElementById("threadimg" + i).src = treeimg;
                  }
                  i++;
              } while (document.getElementById("div"+i));
          }
      }

      function shrinkAll() {
          if (display_supported) {
              var i = 0;
              do {
				  	shrinkIt(i++);
              } while (document.getElementById("div"+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 );
      }


