var saveID = 0;

function showComments(id) {
    //Unslide saved slide

    if (saveID != 0) {
        if (saveID != id) {
            hideDiv(saveID)
        }
    }

    doSlide(id);
    saveID = id;
}

function hideDiv(id) {
    obj.style.display = "none";
    obj.style.height = "0px";
}

function doSlide(id) {
    timeToSlide = 35; // in milliseconds
    obj = document.getElementById(id);
    if (obj.style.display == "none" || obj.style.display == '') { // si c hidden on fait le slide
        obj.style.visibility = "hidden";
        obj.style.display = "block";
        height = obj.offsetHeight;
        obj.style.height = "0px";
        obj.style.visibility = "visible";
        pxPerLoop = height / timeToSlide;
        slide(obj, 0, height, pxPerLoop, 'down');
    } else {
        height = obj.offsetHeight;
        pxPerLoop = height / timeToSlide;
        slide(obj, height, height, pxPerLoop, 'up');
    }
}

function slide(obj, offset, full, px, direction) {
    if (direction == 'down') {
        if (offset < full) {
            obj.style.height = offset + "px";
            offset = offset + px;
            setTimeout((function () { slide(obj, offset, full, px, 'down'); }), 1);
        } else {
            obj.style.height = "auto"; //Can be usefull in updated divs otherwise
            //just use full+"px"
        }
    } else if (direction == 'up') {
        if (offset > 5) {
            obj.style.height = offset + "px";
            offset = offset - px;
            setTimeout((function () { slide(obj, offset, full, px, 'up'); }), 1);
        } else {
            obj.style.display = "none";
            obj.style.height = height + "px";
        }
    }
}
