﻿        var delta = 5;
        var curHeight = 0;
        var maxHeight;
        var timer;
        var myObject;
 
        function toggleView(id, collapse) {
 
            myObject = document.getElementById(id);

            if (collapse == true) {
                if (myObject.style.display == 'block') {
                    myObject.style.display = 'none';
                } else {
                    myObject.style.display = 'block';
                }

            }
            else {
                if (myObject.style.display == 'block') {
                    maxHeight = myObject.clientHeight;
                    curHeight = maxHeight;
                    timer = setInterval("close()", 30);
                } else {
                    curHeight = 0;
                    myObject.style.display = 'block';
                    maxHeight = myObject.clientHeight;
                    myObject.style.height = '0px';

                    timer = setInterval("open()", 30);
                }
            }
 
        }
 
        function open() {
            curHeight += delta;
            myObject.style.height = curHeight + 'px';
 
            if (curHeight >= maxHeight)
                clearInterval(timer);
        }
 
        function close() {
            curHeight -= delta;
            if (curHeight < 0)
                curHeight = 0;
                
            myObject.style.height = curHeight + 'px';
 
            if (curHeight == 0) {
                clearInterval(timer);
                myObject.style.display = 'none';
                myObject.style.height = maxHeight + 'px';
            }
        }