title: jquery animate and make div center
body: <p>when the div is getting fadeout then i want to make it center. please review the code and tell me what to change to make it proper.</p>
  
  <p>here is the implementation url <a href="http://jsfiddle.net/Sj4eG/17/" rel="nofollow">http://jsfiddle.net/Sj4eG/17/</a>
  here is the code. </p>
  
  <pre><code>var grower = $('.grower');
  var flag=0;
  
  $('.click').click(function(){
      var windowWidth = $(window).width();
      var windowHeight = $(window).height();
  
      var left = windowWidth/2 - 150;
      var top = windowHeight/2 - 150;
      var w = 300;
      var h = 300;
  
      if(flag==0)
      {
          $('.grower').show()
          grower.css({left:windowWidth/2, top:windowHeight/2});
          grower.animate({width:w, height:h, left:left, top:top,opacity : 1},500);
          flag=1;
      }
      else if(flag==1)
      {
          grower.animate({width:h/2, height:w/2, left:(windowWidth/2 -
              $('#grower').width()), top:(windowHeight/2 -
              $('#grower').height())},function() {$('.grower').fadeOut("slow");flag=0;});
          flag=0;
      }
  });
  </code></pre>