
var bar_open = false;
var active_bar = null;
var timer = null;

function Bar_Click(obj)
{
    var bar = document.getElementById("first_bar");
    if (bar==null || obj==null) return;
    bar = bar.nextSibling;
    while (bar)
    {
        if (bar.extend!="MenuBar") bar.style.display="none";
        bar = bar.nextSibling;
    }
    active_bar = obj;
    obj.nextSibling.style.display='block';
    ScrollButton_MoveTo(obj.nextSibling);
}

function Item_Click(obj)
{
    if (obj==null) return;
    mainfrm = document.getElementById("content");
    mainfrm.src = obj.href;
}

function Item_MouseDown(obj)
{
    obj.style.borderWidth=1;
    obj.style.borderTopColor="#666666";
    obj.style.borderBottomColor="#FFFFFF";
    obj.style.borderLeftColor="#666666";
    obj.style.borderRightColor="#FFFFFF";
}

function Item_MouseUp(obj)
{
    Item_MouseOver(obj);
}

function Item_MouseOver(obj)
{
    if (obj==null) return;
    obj.style.borderWidth=1;
    obj.style.borderTopColor="#FFFFFF";
    obj.style.borderBottomColor="#666666";
    obj.style.borderLeftColor="#FFFFFF";
    obj.style.borderRightColor="#666666";
}

function Item_MouseOut(obj)
{
    if (obj==null) return;
    obj.style.borderWidth=0;
}

function ScrollButton_MoveTo(obj)
{
    var scroll_btn_up = document.getElementById("scroll_btn_up");
    var scroll_btn_dn = document.getElementById("scroll_btn_dn");
    if (obj==null || scroll_btn_up==null || scroll_btn_dn==null) return;
    scroll_btn_up.style.pixelLeft = obj.offsetParent.offsetWidth-19;//scroll_btn_up.offsetWidth;
    scroll_btn_up.style.pixelTop = obj.offsetTop+25;//scroll_btn_up.offsetHeight+6;
    scroll_btn_dn.style.pixelLeft = obj.offsetParent.offsetWidth-19;//scroll_btn_up.offsetWidth;
    scroll_btn_dn.style.pixelTop = obj.offsetTop+obj.offsetHeight;
    var client = obj.children[0].children[0];
    if (client.offsetHeight==client.children[0].offsetHeight)
    {
        scroll_btn_up.style.display="none";
        scroll_btn_dn.style.display="none";
    }
    else
    {
        if (client.scrollTop<=0)
            scroll_btn_up.style.display="none";
        else
            scroll_btn_up.style.display="block";
        if (client.offsetHeight+client.scrollTop>=client.children[0].offsetHeight)
            scroll_btn_dn.style.display="none";
        else
            scroll_btn_dn.style.display="block";
    }
}

function setScrollBtn() {if (active_bar) ScrollButton_MoveTo(active_bar.nextSibling);}

function scrollStart(step)
{
    if (active_bar==null) return;
    var obj = active_bar.nextSibling.children[0].children[0];
    if (obj==null) return;
    obj.scrollTop+=step;
    if (obj.scrollTop>0 && obj.scrollTop+obj.offsetHeight<obj.children[0].offsetHeight)
        timer = setTimeout("scrollStart("+step+")", 100);
    else
        setScrollBtn();
}

function scrollStop()
{
    clearTimeout(timer);
}

function addBar(caption)
{
    if (bar_open) barEnd();
    bar_open = true;
    document.write("<tr onclick=\"Bar_Click(this)\" height=19 extend=\"MenuBar\" style=\"cursor: hand; font-size: 9pt;\">\n"
                 + " <td valign=middle width=130 align=center background=\"images/buttonD1.bmp\">"+caption+"</td>\n"
                 + "</tr><tr style=\"display:none\"><td colspan=3 valign=top>\n"
                 + " <div style='height:100%;width:100%;overflow:hidden;' onresize='setScrollBtn();';>"
                 + "<table width=100% border=0 align=center valign=top>");
}

function barEnd()
{
    document.write("</table></div></td></tr>\n");
    bar_open = false;
}

function addItem(caption, href)
{
    if (caption==null || href==null) return;
    
    if (caption=="--------------------")
    document.write("<tr height=10><td valign=middle style=\"border:0 solid; BORDER-LEFT-COLOR: #FFFFF; BORDER-BOTTOM-COLOR: #666666; BORDER-TOP-COLOR: #FFFFF; BORDER-RIGHT-COLOR: #666666;cursor: hand\">"+caption+"</td></tr>\n");
    else
    document.write("<tr height=20><td valign=middle onmousedown=\"Item_MouseDown(this)\" onmouseup=\"Item_MouseUp(this)\" onmouseenter=\"Item_MouseOver(this)\" onmouseout=\"Item_MouseOut(this)\"  style=\"border:0 solid; font-size: 9pt; BORDER-LEFT-COLOR: #FFFFF; BORDER-BOTTOM-COLOR: #666666; BORDER-TOP-COLOR: #FFFFF; BORDER-RIGHT-COLOR: #666666;cursor: hand\"><a href='"+href+"' target=content>"+caption+"</a></td></tr>\n");

}

function showFirst()
{
    var bar = document.getElementById("first_bar");
    if (bar==null) return;
    bar = bar.nextSibling;
    while (bar && bar.extend!="MenuBar") bar = bar.nextSibling;
    if (bar.extend=="MenuBar") Bar_Click(bar);
}

function showOutlookBar()
{
    document.write("<table width=100% height=100% border=0 cellspacing=0 cellpadding=0 align=center valign=top>\n"
                 + "<tr height=0 style=\"display:none\" id=\"first_bar\"><td></td></tr>\n");
    showItems();
    if (bar_open) barEnd();
    document.write("</table>\n"
                 + "<input id=\"scroll_btn_up\" type=image src=\"images/scrlbtnup.gif\" style='z-index:3;position:absolute;width:19px;height:19px;left:0;top:0;display:none;' onmousedown='scrollStart(-20);' onmouseup='scrollStop();' onclick='return false;'>\n"
                 + "<input id=\"scroll_btn_dn\" type=image src=\"images/scrlbtndn.gif\" style='z-index:3;position:absolute;width:19px;height:19px;left:0;top:0;display:none;' onmousedown='scrollStart(20);' onmouseup='scrollStop();' onclick='return false;'>\n");
    showFirst();
}