
//functions and arrays needed for showing and hiding the menu on the db websites
ids = new Array( "all", "info", "info2", "stat", "fail", "cal", "star", "limits", "ranges", "showquery");
statarr = new Array( 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);

function setdisplays ()
{
    var blub="";
    for (var i = 0 ; i < ids.length ; i++)
    {
        var d = document.getElementById(ids[i]);
        if (d)
            d.style.display == 'none' ? statarr[i]=0 : statarr[i]=1;
        if (i==0)
            statarr[i]=0;
        blub=blub+statarr[i];
    }
    return blub;
}

function hide(el,img)
{
    el.style.display="none";
    if (img)
    {
        img.src='plus.png';
        img.alt='+';
    }
}

function show(el,img)
{
    el.style.display="block";
    if (img)
    {
        img.src='minus.png';
        img.alt='-';
    }
}

function showhide (id)
{
    var el = document.getElementById(id);
    var img = document.getElementById(id+"button");
    if (el.style.display == 'block')
        hide(el,img);
    else
    {
        show(el,img);
        if (id!="showquery")
        {
            var el2 = document.getElementById("all");
            var img2 = document.getElementById("allbutton");
            show(el2,img2);
        }
    }

    var soso = document.getElementById("sh");
    soso.value = setdisplays();
}

function getdisplay()
{
    var stat = document.getElementById("sh");
    statvalue=stat.value;
    for (var i = 0 ; i < ids.length ; i++)
    {
        var status = statvalue.slice(i,i+1);
        var el = document.getElementById(ids[i]);
        var img = document.getElementById(ids[i]+"button");
        if (!el)
            continue;
        status==0 ? hide(el,img) : show(el,img);
    }
}

//functions and arrays needed for the function for plotdb.php
primaries = new Array( "fSequenceFirst", "fRunNumber", "fDataSetNumber");

function showpulldown (id2)
{
    var el = document.getElementById(id2);
    el.style.display="inline";
    for (var i = 0 ; i < primaries.length ; i++)
    {
        if (primaries[i]==id2)
            continue;
        var el2 = document.getElementById(primaries[i]);
        el2.style.display="none";
        var el3 = document.getElementById(primaries[i]+"2");
        if (el3.style.display=='inline')
            var add=id2;
        el3.style.display="none";
    }
    if (add)
    {
        var el4 = document.getElementById(id2+"2");
        el4.style.display="inline";
    }
}

function showpulldown2 ()
{
    count=0;
    for (var i = 0 ; i < primaries.length ; i++)
    {
        var el = document.getElementById(primaries[i]);
        if (el.style.display=='inline')
        {
            var el2 = document.getElementById(primaries[i]+"2");
            el2.style.display="inline";
        }
        else
            count++;
    }
    if (count==3)
        for (var i = 0 ; i < primaries.length ; i++)
        {
            var el2 = document.getElementById(primaries[i]+"2");
            el2.style.display="inline";
        }
}

function hidepulldown2 ()
{
    for (var i = 0 ; i < primaries.length ; i++)
    {
        var el2 = document.getElementById(primaries[i]+"2");
        el2.style.display="none";
    }
}

