
/*
 NHYOUTHCENTRE.ORG.UK
 Copyright (c) 2009, All Rights Reserved
*/



function startslideshow() {

   $$('#slideshow .panel').each(function(el, index) {
       if(index >0) { el.hide();
       } else { el.show();
       }
   });

   window.slideshow = new PeriodicalExecuter(function() {
       showpanel(-2);
   }, 5);
}

 function showpanel(pid) {
   if(pid <0) {

       if(pid == -1) {
           $$('#slideshow .panel').each(function(el, index) {
               if(el.visible()) {
                   pid = (index >0) ? index -1 : 2;
               }
           });
       } else
       if(pid == -2) {
           $$('#slideshow .panel').each(function(el, index) {
               if(el.visible()) {
                   pid = (index <2) ? index +1 : 0;
               }
           });
       }
   } else {
           if(window.slideshow) {
                   window.slideshow.stop();
           }
   }

   $$('#slideshow .panel').each(function(el, index) {
       if(index == pid) { el.show();
       } else { el.hide();
       }
   });

   $$('#slideshowindex img').each(function(el, index) {
       if((index) == pid) {
           el.src = el.src.replace('dot-off','dot-on');
       } else {
           el.src = el.src.replace('dot-on','dot-off');
       }
   });


 }

