﻿
//---------------------------------------------------------------------------------------
// VARIABLE DECLARATIONS
//---------------------------------------------------------------------------------------
var CurrentDiv = "";
var CurrentImage = "";

//---------------------------------------------------------------------------------------
// FUNCTION ToggleVisibility
//---------------------------------------------------------------------------------------
function ToggleVisibility(div, img)
{    
    if (CurrentDiv != div)
    {
        CurrentDiv = div;
        CurrentImage = img;
    }
    else
    {
        CurrentDiv = "";
        CurrentImage = "";
    }

    ShowAndHideDivs();
    SetArrows();
}

//---------------------------------------------------------------------------------------
// FUNCTION ShowAndHideDivs
//---------------------------------------------------------------------------------------
function ShowAndHideDivs()
{
    var Divs = jQuery(".SideMenuBox").each(function (i, e)
    {
        if (jQuery(this).attr('id') == CurrentDiv)
        {
            jQuery(this).slideDown();
        }
        else
        {
            jQuery(this).slideUp();
        }
    });
}

//---------------------------------------------------------------------------------------
// FUNCTION SetArrows
//---------------------------------------------------------------------------------------
function SetArrows()
{
    var Divs = jQuery(".ShowHideButton").each(function (i, e)
    {
        if (jQuery(this).attr('id') == CurrentImage)
        {
            if (jQuery(this).attr('src') == "images/show.png")
            {
                jQuery(this).attr('src', "images/hide.png");
            }
        }
        else
        {
            if (jQuery(this).attr('src') == "images/hide.png")
            {
                jQuery(this).attr('src', "images/show.png");
            }
        }
    });
}
