Problem with a variable
<p>I'm working on a simple <code>if/else</code> statement to show a next or previous link, but somehow my checkup don't work. Here's the code</p>

<pre><code>
var newPosition = currPosition;
$(".imageNavLink").click(function(event){
 event.preventDefault();
 newPosition = (this.rel == "next") ? newPosition + 1 : newPosition - 1;
 var newImageLink = this.title;
 var clickAction = this.rel;
 var newImage = new Image();
 $(newImage).load(function(){
  newWidth = this.width, newHeight = this.height+35;
  if(newPosition == totalItems){
   [.. Show 'previous' link ..]
  }else if(newPosition == 1){
   [.. Show 'next' link ..]
  }else{
   [.. Show 'previous' and 'next' link ..]
  }
 });
 newImage.src = this.title;
});
</code></pre>

<ul>
<li><code>currPosition</code> holds the current position (numeric) of the element to keep on track with the count</li>
<li><code>totalItems</code> is the numeric value of the total associated images</li>
</ul>

<p>If i click on the first image i constantly see the previous link, when i start with the second image i constantly see both links and when i start with the last image i constantly see the previous link..</p>
