Slider not showing image

Slider not showing image

Hi,

I created a slider that half way works. If I click on the left arrow then the images rotates nicely, but when I click on the right arrow that is where the problem comes in. When I click on it, it rotates to the second image but after that it goes wrong.

Here is the js
  1. $(".nav_arrows").click(function(){
  2. $direction1 = ($(this).hasClass("left-arrow") ? "left" : "right");
  3. var activeBanner1 = 100;



  4. if($direction1 == "right"){

  5. $(".inactive_banner").css("left","100%").show();
  6. activeBanner1 = -100;
  7. if($(".active_banner").next().length < 1){
  8. $(".banner_wrapper").eq(0).animate({"left":0+"%","opacity":1}, 500,function(){
  9. $(this).addClass("active_banner").removeClass("inactive_banner");
  10. });
  11. }else{
  12. $(".active_banner").next().animate({"left":0+"%","opacity":1}, 500,function(){
  13. $(this).addClass("active_banner").removeClass("inactive_banner");
  14. });
  15. }





  16. }else{ //left
  17. $(".inactive_banner").css("left","-100%").show().fadeTo(250, 0);
  18. if($(".active_banner").prev().length < 1){
  19. $(".banner_wrapper").eq($(".banner_wrapper").length-1).animate({"left":0+"%","opacity":1}, 500,function(){
  20. $(this).addClass("active_banner").removeClass("inactive_banner");
  21. });
  22. }else{
  23. $(".active_banner").prev().animate({"left":0+"%","opacity":1}, 500,function(){
  24. $(this).addClass("active_banner").removeClass("inactive_banner");
  25. });
  26. }
  27. }
  28. $(".active_banner").animate({"left":activeBanner1+"%","opacity":0}, 500,function(){
  29. $(this).addClass("inactive_banner").removeClass("active_banner");
  30. });

  31. });

My HTML
  1. <div class="slider-wrapper">
  2.     <div class="banner_wrapper active_banner" style="display: block; left: 0%; opacity: 1;">
  3.         <img class="bgwidth" src="http://s25.postimg.org/keaisiflb/mini_brown_fairy.jpg" />
  4.     </div>   
  5.     
  6.     <div class="banner_wrapper inactive_banner" style="left: 100%; opacity: 0;">
  7.         <img class="bgwidth" src="http://s25.postimg.org/xwhf4srqn/mini_blue_fairy.jpg" />
  8.     </div>      
  9.     
  10.     <a class="left-arrow nav_arrows" href="javascript:void(0);">
  11.         <img src="http://s25.postimg.org/3uhfk0for/left_arrow.png" />
  12.     </a>      
  13.     
  14.     <a class="right-arrow nav_arrows" href="javascript:void(0);">
  15.         <img src="http://s25.postimg.org/gzwxq49kb/right_arrow.png" />
  16.     </a>        
  17. </div>
My CSS
  1. .banner_wrapper img {
  2.      position: absolute; 
  3. }
  4. .banner_wrapper .relative {
  5.     width: 100%;
  6.     height: 100%;
  7.     position: relative;
  8. }
  9. .bgwidth {
  10.     /*  width: 100%; */
  11. }
  12. .bgheight {
  13.     display: block;
  14.     height: 100%;
  15.     margin: 0 auto;
  16. }

  17. .right-arrow {
  18.     background: none repeat scroll 0 0 black;
  19.     position: absolute;
  20.     right: 9%;
  21.     top: 37%;
  22. }

  23. .right-arrow img{
  24.     position: relative;
  25. }

  26. .left-arrow {
  27.     background: none repeat scroll 0 0 black;
  28.     left: 8%;
  29.     position: absolute;
  30.     top: 37%;
  31.     z-index: 1;
  32. }

  33. .left-arrow img{
  34.     position: relative;
  35. }
Here is a jsfiddle:  JSFIDDLE