Stuck: hide/show divs with next button, redirect last div
<p>Here's what I have so far, which allows the user to click an image to open a new window and go to a location. When that click occurs, the image in the parent window is replaced with the next div.</p>

<p>Example: <a href="http://jsfiddle.net/rzTHw/" rel="nofollow">http://jsfiddle.net/rzTHw/</a></p>

<p>Here's the working code so far...</p>

<pre><code>&lt;div class = "box"&gt;&lt;a href="link1.html" target="_blank"&gt;&lt;img src="http://placehold.it/300x150/cf5/&amp;text=img+1"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class = "box"&gt;&lt;a href="link2.html" target="_blank"&gt;&lt;img src="http://placehold.it/300x150/f0f/&amp;text=img+1"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class = "box"&gt;&lt;a href="link3.html" target="_blank"&gt;&lt;img src="http://placehold.it/300x150/fb1/&amp;text=img+1"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class = "box"&gt;&lt;a href="link4.html" target="_blank"&gt;&lt;img src="http://placehold.it/300x150/444/&amp;text=img+1"&gt;&lt;/a&gt;&lt;/div&gt;​
</code></pre>

<p>Jquery:</p>

<pre><code>$('.box').not(':first').hide();
$('.box a').click(
    function(e){
        e.preventDefault();
        var newWin = window.open(this.href,'newWindow'),
            that = $(this).closest('.box'),
            duration = 1200;
        if (that.next('.box').length){
            that.fadeOut(duration,
                         function(){
                             that.next('.box').fadeIn(duration);
                         });
        }
    });
</code></pre>

<p>What I am having trouble with is:</p>

<ol>
<li>Creating a "next" button so the user can cycle through to the next div without having the click the image, thus avoiding having to open a new window to get to the next image.</li>
<li>Having a click on the last div redirect the window location to a URL, while still doing the normal function of opening a new window to the <code>a href</code> location if the image is clicked. Otherwise if clicking the "next" button when the last div is shown, simply redirect the user.</li>
</ol>

<p>What's the best way to go about this? Thanks!</p>
