function toggle(id) {
    var latestAttachmentVersionBlock = document.getElementById("attachment_" + id);
    var oldAttachmentVersionRows = document.getElementsByClassName('history_' + id);
    for (var i = 0; i < oldAttachmentVersionRows.length; i++)
    {
        var oldAttachmentVersionRow =  oldAttachmentVersionRows[i];

        if (oldAttachmentVersionRow.className.indexOf(' hidden') != -1)
        {
            oldAttachmentVersionRow.className = oldAttachmentVersionRow.className.replace(' hidden', '');
        }
        else
        {
            oldAttachmentVersionRow.className += ' hidden';
        }
    }

    var arrowIcon = document.getElementById('arrow' + id);
    var contextPath = document.getElementById('contextPath').value;
    with (arrowIcon)
    {
        if (src != null && (src.indexOf(contextPath + '/images/icons/arrow_closed_active_16.gif') != -1 || src.indexOf(contextPath + '/images/icons/arrow_closing_active_16.gif') != -1))
        {
            src = contextPath + '/images/icons/arrow_opening_active_16.gif';
        }
        else
        {
            src = contextPath + '/images/icons/arrow_closing_active_16.gif';
        }
    }
}

function toggleFilesForm()
{
    var uploadAttachmentRows = document.getElementsByClassName('uploadAttachmentRow');

    for (var i = 0; i < uploadAttachmentRows.length; i++)
    {
        var uploadAttachmentRow = uploadAttachmentRows[i];
        if (uploadAttachmentRow.className.indexOf(' hidden') != -1)
        {
            uploadAttachmentRow.className = uploadAttachmentRow.className.replace(' hidden', '');
        }
        else
        {
            uploadAttachmentRow.className += ' hidden';
        }
    }

    document.getElementById("moreFilesLink").className += ' hidden';
}