window.addEvent('domready', function() {
  $$('.accordionelement').each(function(elem) {
    var dir = 'top' ;
    if ($('accordion').hasClass('horizontal')) dir = 'left' ;
    
    elem.addEvent('click',function(e) {
      // transition all other elements to closed and 
      // this element to open...
      
      var dist = 0 ;
      var size = 250 ;
      if (dir == 'left') size = 160 ;
      
      $$('.accordionelement').each(function(el,i) {
        el.set('tween',{wait:false,duration:500}) ;
        el.tween(dir,dist) ;
        if (el == elem) {
          dist += size ;
        } else {
          dist += 30 ;
        }
      }) ;
    }) ;
  }) ;   
}) ;

function startRotator(divid,imgname,maximg,repeat,delayby)
{
  var next = 2 ;
  // kick off the first rotator
  $$('#'+divid+' img').each(function(obj,idx) { 
    var rotate = function(){ 
      obj.setProperty('src','/images/film-boxes-right/'+imgname+next+'.jpg') ;
      next++ ;
      if (next > maximg) next = 1 ;
    }
    
    var starter = function() { rotate.periodical(repeat); }
              
    starter.delay(delayby) ; 
  });
}