Syntax or logical error in jquery/javascript
<p>I have a variable number of promotional items (<code>panels</code>) that are in a sliding belt, that should be set to the width of a panel (<code>300px</code>) multiplied with the amount of panels.</p>

<p>It alerts the correct beltsize. With fixed numbers the slider works too. I suspect the error to be in the <code>if/else if</code> part. I am not even sure this is valid Javascript Syntax.</p>

<p>Any hint is appreciated.</p>

<pre><code>   $(window).ready(function(){  
        var whichpanel = 1;
        var panels = $(".panel").length;
        var beltsize = panels*300;
        $('.belt').css({'width':beltsize});
    });

    $(window).ready(function promoslider(){
        if (panels&gt;whichpanel){
            $('.belt').delay(7000).animate({'left':'-=300'}, 500);
            whichpanel += 1;    
        }
        else if (panels=whichpanel){
            $('.belt').delay(7000).animate({'left':'0'}, 500);
            whichpanel = 1;
        }   
        setTimeout(promoslider, 0);

    });
    promoslider;
</code></pre>

<p>UPDATE! Here is the code that works for me now (<a href="http://jsfiddle.net/zr5Nd/10/" rel="nofollow">http://jsfiddle.net/zr5Nd/10/</a>):</p>

<pre><code>$(window).ready(function () {
var whichpanel = 1;
var panels = $(".panel").length;
var beltsize = panels * 300;
$('.belt').css({
    'width': beltsize
});

function movingdiv() {
    if (panels &gt; whichpanel) {
        //alert('Panels:' + panels + '/whichpanel:' + whichpanel);
        $('.belt').delay(1000).animate({
            'margin-left': '-=300px'
        }, 500);
        whichpanel += 1;

    } else if (panels == whichpanel) {
        //alert('Panels:' + panels + '/whichpanel:' + whichpanel);
        $('.belt').delay(1000).animate({
            'margin-left': '0'
        }, 500*panels);
        whichpanel = 1;

    } else {
        alert('3');
    }
    setTimeout(movingdiv, 0);
}

setTimeout(movingdiv, 0);
</code></pre>

<p>});</p>
