﻿
var leftmarginwidth=0;


function panelmoving(tgt)
{
    tgt.style.visibility="hidden";
    var container = getElementsByClassName(document, "container")[0];
    if (leftmarginwidth<20)
    {
        if (container.currentStyle)
        {
            leftmarginwidth=parseInt(container.currentStyle.marginLeft);
        }
        else if (window.getComputedStyle(container, "")) 
        {
            var compStyle = window.getComputedStyle(container, "");
            leftmarginwidth = parseInt(compStyle.getPropertyValue("margin-left"));
        }
    }
    if (tgt.title=="Hide Menu")
    {
        getElementsByClassName(document,"menu")[0].style.display="none";
        container.style.marginLeft="13px";
        tgt.title="Show Menu";
        tgt.alt = "Show Menu";
        tgt.src = "images/expand_blue.jpg";
        document.cookie="menuvisible=false";
    }
    else
    {
        tgt.title="Hide Menu";
        tgt.alt="Hide Menu";
        tgt.src = "images/collapse_blue.jpg";
        getElementsByClassName(document,"menu")[0].style.display="";
        container.style.marginLeft="";
        document.cookie="menuvisible=true";
    }
    setTimeout("updatebutton('"+tgt.id+"');",1);   
    return false;
}

function updatebutton(tgtid)
{
    document.getElementById("rightfloat").style.visibility="hidden";
    document.getElementById(tgtid).style.visibility="hidden";
    document.getElementById(tgtid).style.visibility="visible";
    document.getElementById("rightfloat").style.visibility="visible"; // force IE to rerender 
}

function getpos( oElement )
{
    var posx=posy= 0;
    while( oElement.offsetParent != null ) 
    {
        if (oElement.clientTop !=undefined || oElement.clientLeft!=undefined)
        {
            posy += oElement.clientTop;
            posx += oElement.clientLeft;
        }
        posy += oElement.offsetTop;
        posx += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return [posx,posy];
}

function getrightspace(oElement)
{
    var rightpixels=0;
    while(oElement.parentNode!= null)
    {
        if (oElement.currentStyle)
        {
            if (oElement.currentStyle.borderRightStyle!="none")
            {
                var borderwidth=parseInt(oElement.currentStyle.borderRightWidth);
                if (borderwidth>0) rightpixels += borderwidth;
            }
            var marginwidth=parseInt(oElement.currentStyle.marginRight);
            if (marginwidth>0) rightpixels += marginwidth;
            var paddingwidth=parseInt(oElement.currentStyle.paddingRight);
            if (paddingwidth>0) rightpixels += paddingwidth;
        }
        else if (window.getComputedStyle(oElement, "")) 
        {
            var compStyle = window.getComputedStyle(oElement, "");
            var csborderwidth=parseInt(compStyle.getPropertyValue("border-right-width"));
            if (csborderwidth>0) rightpixels += csborderwidth;
            var rightmargin = parseInt(compStyle.getPropertyValue("margin-right"));
            if (rightmargin>0) rightpixels += rightmargin;
            var rightpadding = parseInt(compStyle.getPropertyValue("padding-right"));
            if (rightpadding>0) rightpixels += rightpadding;
        }
        oElement = oElement.parentNode; 
    }
    return rightpixels;
}

function getElementsByClassName(node, classname)
{
    var a = [];
    if (node==null)return a;
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}