title: jQuery Responsive Tabs to start new slideshow/replace existing slideshow upon tab selection?
body: <p>New to jQuery/javascript, but not <em>too</em> afraid... Friend helped me out with the slideshow script below, and I've pulled jellekralt's Responsive Tabs jQuery script from github...</p>
  
  <p>I have the javascript, auto-playing, crossfading slideshow that loops images (specified in each page's html file (in js-determined random order, FWIW)). </p>
  
  <p>I had main section pages linking out to subpages, with different images than the main pages' in each subpage. </p>
  
  <p>But now I've chosen to use the Responsive Tabs jQuery code (<a href="https://github.com/jellekralt/Responsive-Tabs" rel="nofollow">https://github.com/jellekralt/Responsive-Tabs</a>) to only have main section pages, and tabs to open panels that show (what was) the subpages' text instead. (Keeping each main section and subsections in the same html file provides the responsive change from tabs to accordion based on a media query breakpoint, allowing for clearer navigation and presentation on both desktop and mobile... and fewer pages, of course!</p>
  
  <p>I'd like the tabs (or accordion headings after breakpoint) to trigger a change in the specified image files in the slideshow, as would have happened if going to a new/separate subsection's page, but I want this to happen while staying on the same page.</p>
  
  <p>The image slideshow is not/can not be IN each tab.</p>
  
  <p>My basic html structure/div order is:</p>
  
  <pre><code>head
      body
          wrapper
              content container
                  logo
                  *[script] - slideshow
                  main section info text
                  main section nav (to other main section pages)
                  *[script] - Responsive Tabs (subsection text displayed in div/panel triggered by tabs)
              [close content container]
          ([script]) (sticky) footer
          [close wrapper]
      [close body]
  </code></pre>
  
  <p>html of the slideshow area (very simple! - "fadein" class triggers the slideshow upon page load):</p>
  
  <pre><code>&lt;div class="imagearea"&gt;
      &lt;div class="fadein"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>slideshow script:</p>
  
  <pre><code>&lt;script&gt;
  $(function () {
     var randomize = function (array) {
         for (var i = array.length - 1; i &gt; 0; i--) {
             var j = Math.floor(Math.random() * (i + 1));
             var temp = array[i];
             array[i] = array[j];
             array[j] = temp;
         }
         return array;
     };
  
     var assets = [{
          url: "images/image_01.jpg"
      }, {
          url: "images/image_02.jpg"
      }, {
          url: "images/image_03.jpg"
      }, {
          url: "images/image_04.jpg"
      }, {
          url: "images/image_05.jpg"
     }];
  
     var preload = function (assets) {
         var num = assets.length,
             pointer = 0;
         dom = $('.preload img'),
         getNextUrl = function (assets) {
  
             if (pointer &lt; (num - 1)) {
                 pointer++;
             } else {
                 return false;
             }
             dom.attr('src', assets[pointer].url);
             dom.onload = getNextUrl(assets);
         };
  
         dom.onload = getNextUrl(assets);
         dom.attr('src', assets[0].url);
  
     };
     var it = 0; //holding position of assets array
     var img = $('&lt;img/&gt;');
     assets = randomize(assets);
     preload(assets);
  
     for(var x = 0; x &lt; assets.length; x++){
         img = $('&lt;img/&gt;').attr('src',assets[x].url);
         $('.fadein').append(img);
     }
     $('.fadein img:gt(0)').hide(); 
     setInterval(function(){
         $('.fadein :first-child').addClass('dropback')
             .fadeOut(2500).next('img').removeClass('dropback')
                 .fadeIn(2500).end().appendTo('.fadein');
     }, 7500); 
  
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>html of Responsive Tabs section:
      
          <ul>
              <li>item1</li>
              <li>item2</li>
              <li>item3</li>
              <li>item4</li>
          </ul></p>
  
  <pre><code>    &lt;div id="tab-1"&gt;
          &lt;p&gt;blah blah blah. Lorem ipsum and so forth...&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div id="tab-2"&gt;
          &lt;p&gt;yadda yadda more text and such&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div id="tab-3"&gt;
          &lt;p&gt;something else the client wants to say&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div id="tab-4"&gt;
          &lt;p&gt;oh yeah, and another thing...&lt;/p&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Responsive Tabs script (included in html doc - for full jquery.responsiveTabs.js script (too long to post here) please check out <a href="https://github.com/jellekralt/Responsive-Tabs" rel="nofollow">https://github.com/jellekralt/Responsive-Tabs</a>):</p>
  
  <pre><code>    &lt;!-- jQuery with fallback to the 1.* for old IE --&gt;
      &lt;!--[if lt IE 9]&gt;
  &lt;script src="js/jquery-1.11.0.min.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
      &lt;!--[if gte IE 9]&gt;&lt;!--&gt;
          &lt;script src="js/jquery-2.1.0.min.js"&gt;&lt;/script&gt;
      &lt;!--&lt;![endif]--&gt;
  
      &lt;!-- Responsive Tabs JS --&gt;
      &lt;script src="js/jquery.responsiveTabs.js" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              $('#horizontalTab').responsiveTabs({
                  rotate: false,
                  startCollapsed: true,
                  animation: 'break',
                  collapsible: 'accordion',
                  setHash: true,
                  disabled: []
              });
  
              $('#start-rotation').on('click', function() {
                  $('#horizontalTab').responsiveTabs('active');
              });
              $('#stop-rotation').on('click', function() {
                  $('#horizontalTab').responsiveTabs('stopRotation');
              });
              $('#start-rotation').on('click', function() {
                  $('#horizontalTab').responsiveTabs('active');
              });
              $('.select-tab').on('click', function() {
                  $('#horizontalTab').responsiveTabs('activate', $(this).val());
              });
  
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>I want the Responsive Tabs list items #tab-1, #tab-2, #tab-3, and #tab-4 (in addition to opening the related text panel) to allow me to specify different images (could include in either the existing slideshow script, or to trigger a different/replacement to the original/existing slideshow, in the same "imagearea" div - whichever makes it work! </p>
  
  <p>So in a nutshell, what I'm looking for is:</p>
  
  <p>upon page load:
  image_01, image_02, image_03, ...04, ...05</p>
  
  <p>upon clicking #tab-1:
  (tab-1 panel/text and) image_06, ...07, ...08</p>
  
  <p>upon clicking #tab-2:
  (tab-2 panel/text and) images 09, 10, 11...</p>
  
  <p>upon clicking #tab-3:
  (tab-3 panel/text and) images 12, 13, 14...</p>
  
  <p>upon clicking #tab-4:
  (tab-4 panel/text and) images 15, 16, 17...</p>
  
  <p>Possible? Triggering multiple events like this?: <a href="http://css-tricks.com/forums/topic/trigger-multiple-events-on-click-with-javascriptjquery/" rel="nofollow">http://css-tricks.com/forums/topic/trigger-multiple-events-on-click-with-javascriptjquery/</a>
  As I said, I'm new to js/jq, so please be as detailed as you think I'll need.</p>
  
  <p>Please and Thank You,
  AK</p>