jQuery issue with fade actions doubling
<p>Bear with me, this might take a little explanation. I apologize in advance if I don't quite explain it clearly.</p>

<p>I am building a jQuery Slider (wordpress plugin) for a client project and involves the following functionality:</p>

<ul>
<li>Groups of slides are loaded a group at a time</li>
<li>Play/Pause </li>
<li>Next Slide/ Previous Slide</li>
<li>Next Group/ Previous Group</li>
<li>Autoplay</li>
</ul>

<p>It is slightly different in the fact that it has 'groups' of slides with only one Title/Description combo. You then navigate not only between the different slides of each group, but also the groups themselves.</p>

<p><strong>My problem is</strong> that after I pause the autorun for the slideshow and resume it again, the next_slide() action is taken twice (fades out/fades in fades out/fades in), almost as if the setTimeout() has doubled up on itself. </p>

<p><strong>Edit</strong>: Now it appears to be occurring whenever the next_slide() action is taken, and not only after play/pause as I had previously thought. The slide number doesn't advance, but rather fades the same image twice. I have had it stack the same image upwards to 4 times, and have no idea why. My apologies for the confusion.</p>

<p>Could it be that because my .live('click') event is simply calling next_slide() that it is stacking up?</p>

<p><strong>NOTE</strong> - I cleared away some code for readability such as .click events for triggering the functions with the frontend buttons and the set_information function. As far as I can tell, they are not the source of my problems.</p>

<p>Any help would be greatly appreciated. What would be causing the double action of the next_slide() function? Feel free to also critique my code in other aspects, I know that it is far from perfect:</p>

<pre><code>function build_slideshow(grouplist){

    var group_array = jQuery.parseJSON(grouplist); // parse AJAX returned JSON

    var n = 0; //group counter
    var x = 0; //slide counter
    var length = group_array.length - 1; //amount of groups
    var count; // number of slides in group
    var size; // size of window (to pull proper image sizes)
    var autorun = null;

    window_size(); // set size variable for later use
    slideshow_init(); //start the slideshow


    /* ------- FUNCTIONS  -------- */

    /*
    checks window.width for AJAX call
    */

    function window_size(){     
        window_size = $j(window).width();

        switch(true){
            case(window_size &gt; 980):
            size = 'large';
            break;

            case(window_size &gt; 480 &amp;&amp; window_size &lt; 980):
            size = 'med';
            break;

            case(window_size &lt; 480):
            size = 'small';
            break;
       }
    }

    function slideshow_init(){
        set_information(); //places Title, Desc, and Slider nav buttons
        get_slides(group_array[n].id); //builds slideshow for group
    }




    function get_slides(group_id){

        $j.post(myAjax.ajaxurl, {action:"get_slides_list", groupid:group_id, size:size}, function(result){

            slide_data = jQuery.parseJSON(result); 
            count = slide_data.length;
            if(autorun) clearTimeout(autorun); //resets the setTimeout from previous group
            x = 0; //resets the counter from previous group

           $j('.slideshow div').hide();
           $j('.slideshow div').html(slide_data[x]).fadeIn(700); //loads first slide

           if(play == true){ //possible that user paused the slideshow last group
               setTimeout(slideshow_autorun, 6000); //autoruns if not
           }
        });
     }


    function next_slide(){
        x++;

        (x == count) ? x = 0 : x = x; //loops to front if last slide

       $j('.slideshow div').fadeOut( 700 ,  function() {
       $j(this).html(slide_data[x]);
       }).fadeIn(700);
    }

    function previous_slide(){
        x--;

        (x &lt;  0) ? x = (count - 1) : x = x; // loops to back if first slide

        $j('.slideshow div').fadeOut( 700 ,  function() {
        $j(this).html(slide_data[x]);
        }).fadeIn(700);
    }

    function next_group(){
        n++;

        (n &gt; length) ? n = 0 : n = n; //loops to front if last group
        slideshow_init();
    }

    function previous_group(){
        n--;

        (n &lt; 0) ? n = length : n = n; //loops to back if first group
        slideshow_init();
    }

    function play_slideshow(){
         play = true;

         slideshow_autorun();
    } 

    function pause_slideshow(){
        if(autorun) clearTimeout(autorun);

        play = false;    
    }

    function slideshow_autorun(){
        if(play == true){
        next_slide();

        autorun = setTimeout(slideshow_autorun, 6000);

    }
}
}
</code></pre>
