/* 
  Accordion on the homepage
*/

var beat;
var scrollTime = 3500;

function nextAccordion(){
  var nextActive = $("#accordion").accordion( "option", "active" ) + 1;

  //check amount of accordion elements if == n, then reset.
  var amountDiv = $('#accordion div').size();
  
  if(amountDiv == nextActive){
    nextActive = 0;
  }
  $('#accordion').accordion({ active: nextActive });
  hearthbeat();
}

function hearthbeat(){
  beat = setTimeout(nextAccordion, scrollTime);
}


$(document).ready(function(){
  $('#accordion').accordion({ icons : false });
  $(".banner").height($("#accordion").height());
  hearthbeat();  
  

  // when the user hovers over the accordion, it shouldn't change.
  $('#accordion').hover(
        function(){
        clearTimeout(beat);
  }, 
        function(){
        hearthbeat();
  });

});






