
function fetch_object(idname)
{
        if (document.getElementById)
        {
                return document.getElementById(idname);
        }
        else if (document.all)
        {
                return document.all[idname];
        }
        else if (document.layers)
        {
                return document.layers[idname];
        }
        else
        {
                return null;
        }
}

function toggle_collapse(objz)
{

        obj = fetch_object('forum' + objz);
        img = fetch_object('img' + objz);

        if (obj.style.display == 'none')
        {
                obj.style.display = '';
                img.src='themes/light/images/collapse_tcat.gif';
        }else{
                obj.style.display = 'none';
                img.src='themes/light/images/collapse_ncat.gif';
        }
        return false;
}

        //-----------------------
function fetch_offset(obj)
        {
        var left_offset = obj.offsetLeft;
        var top_offset = obj.offsetTop;

        while ((obj = obj.offsetParent) != null)
        {
                left_offset += obj.offsetLeft;
                top_offset += obj.offsetTop;
        }

return { 'left' : left_offset, 'top' : top_offset };
};
//--------------------
function toggle_menu(objz)
{
      window.event.cancelBubble=1;
      document.onclick=hidemenu;

        obj = fetch_object(objz+'_menu');
        objL = fetch_object(objz);
        obj.style.position='absolute';



      this.pos = this.fetch_offset(objL);
        this.leftpx = this.pos['left']-10;
        this.toppx = this.pos['top'] + objL.offsetHeight;

        if ((this.leftpx + objL.offsetWidth) >= document.body.clientWidth && (this.leftpx + objL.offsetWidth - objL.offsetWidth) > 0)
        {
                this.leftpx = this.leftpx + objL.offsetWidth - objL.offsetWidth;
                this.direction = 'right';
        }
        else
        {
                this.direction = 'left';
        }

      obj.style.left = this.leftpx + 'px';
        obj.style.top  = this.toppx + 'px';

        if (obj.style.display == 'none')
        {
         obj.style.filter = "progid:DXImageTransform.Microsoft.alpha(enabled=1,opacity=90); progid:DXImageTransform.Microsoft.shadow(direction=135,color=#8E8E8E,strength=3)";
         obj.style.display = '';


      }else{
                obj.style.display = 'none';
        }

        return false;
}

function hidemenu()
{
 obj.style.display = 'none';
}
