i want to have animate effect with jquery

i have a animate script

```
$(popupID).animate({
    left: $(window).width() / 2 + popupMarginLeft
}, 500);

```

now i want to make changes in it like this

```
$(popupID).animate({left: $(window).width() / 2 + popupMarginLeft}, 
                         function() 
                             {
                                   $(popupID).fadeOut();
                             }, 500);

```

but then the script doesnt run, that means it has some error,

how can i solve it so that while the div slides towards right, it gradualy fades away