cycle - getting two images to change in onAfter function

cycle - getting two images to change in onAfter function

I have 24 items I am cycling through.  As each one is displayed, I have another that I want to change an icon corresponding to that item to a hover icon, and the item before back to a non-hover icon.

I have the hover icon coming up as needed, but cannot get the prior item icon to change back.

  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  2. <script type="text/javascript" src="http://malsup.github.com/chili-1.7.pack.js"></script>
  3. <script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
  4. <script type="text/javascript" src="http://malsup.github.com/jquery.easing.1.3.js"></script>
  5. <script>
  6. $('#slideshow').cycle({ 
  7.     fx:     'fade', 
  8.     timeout: 2000, 
  9.     after:   onAfter 
  10. });

  11. function onAfter() {
  12.     $('#producttitle').html("<a href=\"" + this.href + "\"><b>" + this.title + "</b>")
  13.     $('#productdescription').html($(this).attr('alt'))
  14. var currentItem = new String(this.id.substring(3, 5));
  15. var previousItem = new String((this.id.substring(3, 5))-1);
  16. //alert(previousItem);
  17. if (previousItem = "-1")
  18. {
  19. previousItem = "23";
  20. }
  21. document.getElementById(currentItem).style.background="url(../images/number_icon_hover.gif) no-repeat 0 0 #C4CBA9";
  22. //this is not working
  23.         document.getElementById(previousItem).style.background="url(../images/number_icon.gif) no-repeat 0 0 #C4CBA9";
  24. };

  25. function changeitem(itemnumber) {
  26. $('#slideshow').cycle(itemnumber);
  27. document.getElementById(itemnumber).style.background="url(../images/number_icon_hover.gif) no-repeat 0 0 #C4CBA9";
  28.         return false; 
  29. }

  30. </script>