title: Perform some function before calling another function
body: <p>I am making an image slider. When user clicks on an image:</p>
  
  <ol>
  <li>Image slides and comes in front</li>
  <li>On the next click the image is flipped and enlarged </li>
  <li>On the next click the image returns to its original size and position</li>
  </ol>
  
  <p>On selecting other images the same steps happen.  What I want to do is this: suppose I select an image and the image flips and enlarges. Then I directly click on another image, so I want to write function that before enlarging the new image, the first image should come back to its original size and place.</p>
  
  <p>How to do this?</p>
  
  <pre><code>    var status=1;
  function flipIt(obj){
  //$(obj).wrap("&lt;div class='centerImage'&gt;&lt;/div&gt;")
  
  
  
   console.log("value before Function status   "+status);
  
  if(status==1)
  {
  alert("i am From JS IF part");
      $(obj).animate({"left": "-=30px","opacity": "0.65"},"slow");
      $(obj).animate({"height":"400px","width":"350px"},30);
  
  
    // initial        w295   h354
   $(obj).css("-webkit-transform-style","preserve-3d");
   $(obj).css("-webkit-transition","all 1.0s linear");
   $(obj).css("transform-style","preserve-3d");
   $(obj).css("transition","all 1.0s linear");
  
   $(obj).css("-webkit-transform","rotateY(180deg)");
   $(obj).css("transform","rotateY(180deg)");
   //$(obj).css("box-shadow","-5px 5px 5px #aaa");
  
   status=0;
   console.log("after if value set status   "+status);
  }
  else
  {
  
  //alert("i am From JS Else part");
      $(obj).animate({"left": "+=30px","opacity": "0.99"},"slow");
      $(obj).animate({"height":"354px","width":"295px"},30);
  
   $(obj).css("-webkit-transform-style","preserve-3d");
   $(obj).css("-webkit-transition","all 1.0s linear");
   $(obj).css("transform-style","preserve-3d");
   $(obj).css("transition","all 1.0s linear");
  
  
   $(obj).css("-webkit-transform","rotateY(0deg)");
   $(obj).css("transform","rotateY(0deg)");
   //alert("apply css");
      status=1;
      Removecss();
  
   console.log("ater else value set status   "+status);
  
  }
  </code></pre>