How to clear interval and set it again?
<p>This is what i am trying to accomplish: when the last slide is reached fadeOut last slide and then fadeIn first slide, and then clearInterval <b><i>(everything works with this part)</i></b>. Now my problem is that i want to setInterval <b>again</b> if it doesn't exists but I don't know how to make it happen:( <br/>I have tried to solve this with if statment but then my script doesn't work at all! <br/>So how can I RESTART my interval again? THANK YOU!! <br/><b>Without</b> if statement like this it's working fine:</p>

<pre><code>if(!intervalID){
intervalID = setInterval(animate,5000);
}    
</code></pre>

<p>This is what I have s far: </p>

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

       /*check if intervalID don't exists messes UP!!*/

       if(!intervalID){
       intervalID = setInterval(animate,5000);
       }    

//Hide everything except first slide and controls

  $('.slidewrap div:not(.slidewrap div:first,.slidewrap .slide_controls)').hide();

  var animate=function(){       

/*if .pagination_active is last removeClass and addClass to .pagination_active 
 first li tag*/ 

    if($('.pagination_active').is($('.slide_controls ul li:last'))){
    $('.pagination_active').removeClass('pagination_active');   
    $('.slide_controls ul li:first').addClass('pagination_active');
    }

else{
    $('.pagination_active').removeClass('pagination_active').next().addClass('pagination_active');
    }

/*if div.active is last fadeOut and add .active class 
 to the first div and fadeIn FIRST div then CLEAR INTERVAL and set intervalID to zero */ 

    if($('.active').is($('.slidewrap div:last'))){
    $('.active').fadeOut(1000).removeClass('active');
    $('.slidewrap div:first').addClass('active').fadeIn(1000,function(){            
    clearInterval(intervalID);
    intervalID=0;

    });     
    }

//OR .active fadeOut and next div fadeIn
   else{
       $('.active').fadeOut(1000).next().fadeIn(1000,function(){
       $('.slidewrap div.active').removeClass('active').next('div').addClass('active');

       });
       }

}

var intervalID;
intervalID = setInterval(animate,3000);

});
</code></pre>
