change initiate time of slider

change initiate time of slider

Hello, I would like to build a navigation with 6 sublinks, each of them are images. The image of the sublink is supposed to change as in an autoplay slider every few seconds before starting again. At the moment I use two sliders, to create the effect based on a code I've found here. However I would like the second slider changing the image 5 seconds after the first slider has changed, so that the two sliders will never change the image at the same time. 

Thanks for your help,
Regards, 


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <style type="text/css">

  7. #menu-slider { float:left; }
  8. /* Required */

  9. #list-images, #list-images li { height: 298px; width: 730px; display: block; }
  10. #list-images { float: left; overflow: hidden; /* Required to hide the inactive slides */ padding:0px; }
  11. #list-images li { position: relative; }
  12. #list-images li img { background: #fff; position: absolute; top: 0; left: 0; }
  13. /* Image captions */


  14. #list-links { width: 238px; float:left; list-style: none; padding:0px; }
  15. #list-links li a { color: #333; background:#f00; padding: 17px 12px 17px 16px; border-bottom: 1px solid #ccc; font-weight: bold; font-size: 13px; display: block; cursor:pointer; }
  16. #list-links li.hover { background: #000; }
  17. #list-links li.hover a, #list-links li.hover a:hover { color: #fff; background: none; border-bottom: none; }
  18. #list-links li.last a { border-bottom: none; }
  19. .wrap { width: 100%; float:left; }
  20. #pagewrap { width:1000px; margin:0 auto; }

  21. #list-images1, #list-images1 li { height: 298px; width: 730px; display: block; }
  22. #list-images1 { float: left; overflow: hidden; /* Required to hide the inactive slides */ padding:0px; }
  23. #list-images1 li { position: relative; }
  24. #list-images1 li img { background: #fff; position: absolute; top: 0; left: 0; }
  25. /* Image captions */


  26. #list-linksm1 { width: 238px; float:left; list-style: none; padding:0px; }
  27. #list-linksm1 li a { color: #333; background:#f00; padding: 17px 12px 17px 16px; border-bottom: 1px solid #ccc; font-weight: bold; font-size: 13px; display: block; cursor:pointer; }
  28. #list-linksm1 li.hover { background: #000; }
  29. #list-linksm1 li.hover a, #list-linksm1 li.hover a:hover { color: #fff; background: none; border-bottom: none; }
  30. #list-linksm1 li.last a { border-bottom: none; }
  31. .wrap { width: 100%; float:left; }

  32. </style>

  33. <script type="text/JavaScript">

  34. $(document).ready(function() {

  35.   // Declare variables

  36.   var width = 730;

  37.   var slides = $('#list-images1 li');

  38.   var numSlides = slides.length;

  39.   

  40.   // Wrap the slides & set the wrap width - this will be used to animate the slider left/right

  41.   slides.wrapAll('<div id="slide-wrap1"></div>').css({'float' : 'left','width' : width});

  42.   $('#slide-wrap1').css({width: width * numSlides});



  43.   // Hover function - animate the slides based on index of links

  44.   $('#list-linksm1 li a').click(function(){

  45. $('#list-linksm1 li').removeClass('hover');

  46. var i = $(this).index('#list-linksm1 li a');

  47. $(this).parent().addClass('hover');

  48. $('#slide-wrap1').stop().animate({'marginLeft' : width*(-i)});

  49.   });
  50.   
  51. setInterval(function(){
  52. $('#list-linksm1 li.hover').next().find('a').trigger('click');
  53. }, 3000);




  54. });

  55. </script>

  56. <script type="text/JavaScript">

  57. $(document).ready(function() {

  58.   // Declare variables

  59.   var width = 730;

  60.   var slides = $('#list-images li');

  61.   var numSlides = slides.length;

  62.   

  63.   // Wrap the slides & set the wrap width - this will be used to animate the slider left/right

  64.   slides.wrapAll('<div id="slide-wrap"></div>').css({'float' : 'left','width' : width});

  65.   $('#slide-wrap').css({width: width * numSlides});



  66.   // Hover function - animate the slides based on index of links

  67.   $('#list-links li a').click(function(){

  68. $('#list-links li').removeClass('hover');

  69. var i = $(this).index('#list-links li a');

  70. $(this).parent().addClass('hover');

  71. $('#slide-wrap').stop().animate({'marginLeft' : width*(-i)});

  72.   });
  73.   
  74. setInterval(function(){
  75. $('#list-links li.hover').next().find('a').trigger('click');
  76. }, 3000);




  77. });

  78. </script>
  79. </head>

  80. <body>
  81. <div id="pagewrap">
  82.   <div class="wrap">
  83.     <div id="menu-slider">
  84.       <ul id="list-links">
  85.         <li class="hover"><a href="#">Link 1</a></li>
  86.         <li><a href="#">Link 2</a></li>
  87.         <li><a href="#">Link 3</a></li>
  88.         <li><a href="#">Link 4</a></li>
  89.         <li><a href="#">Link 5</a></li>
  90.         <li class="last"><a href="#">Link 6</a></li>
  91.       </ul>
  92.       <ul id="list-images">
  93.         <li style="background:#04ff62">Slide 1 </li>
  94.         <li style="background:#f00">Slide 2 </li>
  95.         <li style="background:#333">Slide 3 </li>
  96.         <li style="background:#000">Slide 4 </li>
  97.         <li style="background:#0e9815">Slide 5 </li>
  98.         <li style="background:#183bae">Slide 6 </li>
  99.         <li style="background:#8c26c6">Slide 7 </li>
  100.         <li style="background:#a6540a">Slide 8 </li>
  101.         <li style="background:#680404">Slide 9 </li>
  102.       </ul>
  103.     </div>
  104.     <div id="menu-slider">
  105.       <ul id="list-linksm1">
  106.         <li class="hover"><a href="#">Link 1</a></li>
  107.         <li><a href="#">Link 2</a></li>
  108.         <li><a href="#">Link 3</a></li>
  109.         <li><a href="#">Link 4</a></li>
  110.         <li><a href="#">Link 5</a></li>
  111.         <li class="last"><a href="#">Link 6</a></li>
  112.       </ul>
  113.       <ul id="list-images1">
  114.         <li style="background:#04ff62">Slide 1 </li>
  115.         <li style="background:#f00">Slide 2 </li>
  116.         <li style="background:#333">Slide 3 </li>
  117.         <li style="background:#000">Slide 4 </li>
  118.         <li style="background:#0e9815">Slide 5 </li>
  119.         <li style="background:#183bae">Slide 6 </li>
  120.         <li style="background:#8c26c6">Slide 7 </li>
  121.         <li style="background:#a6540a">Slide 8 </li>
  122.         <li style="background:#680404">Slide 9 </li>
  123.       </ul>
  124.     </div>
  125.   </div>
  126. </div>
  127. </body>
  128. </html>