How can I animate my div to slide out on button click
<p>Im having a problem, I have managed to get some code to make a div element slide up into view but how would I get it to slide down again if the close button has been clicked? so that I can keep pressing the link and it will play the animation again rather then just showing the div already in its final position.</p>

<p>heres the jquery code</p>

<pre><code>$(document).ready(function() { 

//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
    //Cancel the link behavior
    e.preventDefault();
    //Get the A tag
    var id = $(this).attr('href');

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set height and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});

    //transition effect    
    $('#mask').fadeIn(600);   

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('left', winW/2-$(id).width()/2);

    //Slide up Boxes Div transition effect
    $(id).css({display:'block'}).animate({marginTop:'0px', opacity:'1', },400);

});

//if close button is clicked
$('.window .close').click(function (e) {
    //Cancel the link behavior
    e.preventDefault();
    $('#mask, .window').hide();
});    

//if mask is clicked
$('#mask').click(function () {
    $(this).hide();
    $('.window').hide();
});        

});
</code></pre>

<p>thanks</p>
