title: Slideshow code reusability
body: <p>I've created a Jquery slideshow and it is working without problem, but this thing is bugging me... As you can see I've created two <b>BIG</b> and <b>FAT</b> functions and they are <b>IDENTICAL</b> except second function is stored inside variable called <b>animirajLogo</b> and that variable is called inside <b>setInteval</b> function.</p>
  
  <p>First function logoSlide(); is executed on document load and it slides <b>ONCE</b> all the slides and then <b>setInteval</b> function comes into play and continues the loop.</p>
  
  <p>This is my question: Is it possible to somehow shorten my code and call function inside <b>animirajLogo</b> variable <b>(to execute once)</b> instead using two functions wich are almost IDENTICAL (only difference in second function is that it is stored inside variable and that variable is inside setInteval function).I tried naming second function and call it but it doesn't seem to work. Thank you for your answer!!</p>
  
  <pre><code>    var animirajLogo;
      function logoSlide()
      {
      $('.logo').delay(2000).animate({opacity:1},2000);
      $('.wordslider').delay(6000).animate({width:'451px'},2000,function(){
      $('.boost').delay(1000).stop().animate({marginLeft:'+=436'},2000);
      $('.logo').delay(9000).animate({opacity:0},2000,function(){
      $('.logo').addClass('logo2');
      $('.logo2').removeClass('logo');
      $('.wordslider').css({width:'0'})
      $('.boost').css({marginLeft:'-=436'})
      $('.logo2').delay(1000).animate({opacity:1},2000);
      $('.wordslider').delay(4000).animate({width:'451px'},2000,function(){
      $('.boostlevel').delay(1000).animate({marginLeft:'+=390'},2000,function(){
      $('.logo2').delay(5000).animate({opacity:0},2000,function(){
      $('.logo2').addClass('logo3');
      $('.logo3').removeClass('logo2');
      $('.wordslider').css({width:'0'})
      $('.boostlevel').css({marginLeft:'-=390'})
      $('.logo3').delay(2000).animate({opacity:1},2000);
  
      if ($('.logo3').is($('.logo3'))){
      $('.logo3').delay(10000).animate({opacity:0},2000,function(){
      $('.logo3').addClass('logo');
      $('.logo3').removeClass('logo3');
  
      });
  
      }
      });
  
      });
  
      });
      });
      });
  
      }
  
     animirajLogo=function()
     {
     $('.logo').delay(2000).animate({opacity:1},2000);
     $('.wordslider').delay(6000).animate({width:'451px'},2000,function(){
     $('.boost').delay(1000).stop().animate({marginLeft:'+=436'},2000);
     $('.logo').delay(9000).animate({opacity:0},2000,function(){
     $('.logo').addClass('logo2');
     $('.logo2').removeClass('logo');
     $('.wordslider').css({width:'0'})
     $('.boost').css({marginLeft:'-=436'})
     $('.logo2').delay(2000).animate({opacity:1},2000);
     $('.wordslider').delay(4000).animate({width:'451px'},2000,function(){
     $('.boostlevel').delay(1000).animate({marginLeft:'+=390'},2000,function(){
     $('.logo2').delay(5000).animate({opacity:0},2000,function(){
     $('.logo2').addClass('logo3');
     $('.logo3').removeClass('logo2');
     $('.wordslider').css({width:'0'})
     $('.boostlevel').css({marginLeft:'-=390'})
     $('.logo3').delay(2000).animate({opacity:1},2000);
  
     if ($('.logo3').is($('.logo3'))){
     $('.logo3').delay(10000).animate({opacity:0},2000,function(){
     $('.logo3').addClass('logo');
     $('.logo3').removeClass('logo3');
  
     });
  
     }
  
  
  
  
    });
  
    });
  
    });
    });
    });
  
    }
  
    $(document).ready(function(){
    logoSlide();
    setInterval(animirajLogo,51500)
    });
  </code></pre>