﻿
/* available options for animation type:
 *      collapsefade
 */
function HideElement(ElementID, AnimationType, AnimationSpeed){
    if (ElementID.toString().indexOf('#', 0) == -1){ElementID = '#' + ElementID;}
    if (AnimationType.toString().toLowerCase() == 'collapsefade'){
        var xCurrentHeight = 0;
        xCurrentHeight = $(ElementID).height();
        $(ElementID).animate({
            //opacity: 0,
            height: 0
            }, AnimationSpeed, function(){
                $(ElementID).css('display', 'none');
                $(ElementID).height(xCurrentHeight);
            });
        var CoverDiv = $('<div style="height:' + xCurrentHeight + 'px; width:500px; background-color:#fff; z-index:100; position:relative; top:-' + xCurrentHeight + 'px;"></div>');
        $(ElementID).append(CoverDiv);
        $(CoverDiv).css('opacity', '0');
        $(CoverDiv).css('filter', 'alpha(opacity=0)');
        $(CoverDiv).animate({
            opacity: 1,
            height: 0
            }, {duration: AnimationSpeed, queue: false, complete: function(){
                $(CoverDiv).stop();
                $(CoverDiv).remove();
            }});
    }
}

/* available options for animation type:
 *      expandfade
 */
function ShowElement(ElementID, AnimationType, AnimationSpeed){
    if (ElementID.toString().indexOf('#', 0) == -1){ElementID = '#' + ElementID;}
    if (AnimationType.toString().toLowerCase() == 'expandfade'){
        var xCurrentHeight = 0;
        xCurrentHeight = $(ElementID).height();
        $(ElementID).height(0);
        $(ElementID).css('opacity', '');
        $(ElementID).css('filter', '');
        $(ElementID).css('display', '');
        $(ElementID).animate({
            height: xCurrentHeight
            }, {duration: AnimationSpeed, queue: false, complete: function(){
                $(ElementID).css('filter', '');
                $(ElementID).css('opacity', '');
            }});
        var CoverDiv = $('<div style="height:5px; width:500px; background-color:#fff; z-index:100; position:relative; top:-' + xCurrentHeight + 'px;"></div>');
        $(ElementID).append(CoverDiv);
        $(CoverDiv).animate({
            opacity: 0,
            height: xCurrentHeight
            }, {duration: AnimationSpeed, queue: false, complete: function(){
                $(CoverDiv).stop();
                $(CoverDiv).remove();
            }});
    }
}
