  
  var loopTimer = 6;
  
  jQuery(document).ready(function() {
    
    
    newsLoop = initNewsLoop();
    initHighlightLoop();
    
      $('#news_container/div').hide();
      $('#button_container/div.button:first').css('background-image','url(fileadmin/templates/img/ccf/flex_news_button_active.gif)');
      $('#news_container/div:first').show();
    
    $('#button_container .button').hover(function(){
      $('#news_container/div:visible').hide();
      $('#button_container/div.button').css('background-image','url(fileadmin/templates/img/ccf/flex_news_button.gif)');
      $(this).css('background-image','url(fileadmin/templates/img/ccf/flex_news_button_active.gif)');
      $('#news_container').find('div.' + $(this).attr('id')).show();
    },function(){
      $(this).css('background-image','url(fileadmin/templates/img/ccf/flex_news_button.gif)');
    }); 
    
    $('#button_container').hover( function() {
        clearInterval(newsLoop);
      }, function() {
        newsLoop = initNewsLoop();
    });
    

  });
  
    function initNewsLoop() {           
      var intervalID = setInterval(function() {      
        var test = $('#news_container/div:first').remove();
        $('#news_container').append(test);
        $('#news_container/div:visible').hide();
        $('#news_container/div:first').show();
        
        $('#button_container/div.button').css('background-image','url(fileadmin/templates/img/ccf/flex_news_button.gif)');
        $('#button_container/div#' + $('#news_container/div:first').attr('class')).css('background-image','url(fileadmin/templates/img/ccf/flex_news_button_active.gif)');
      },1000*loopTimer);
      return intervalID;
    }
    
    function initHighlightLoop() {   
      $('#ccf_highlights/div.button').hide();
      $('#ccf_highlights/div:first').show();    
      
      var intervalID = setInterval(function() {      
        var test = $('#ccf_highlights/div:first').remove();
        $('#ccf_highlights').append(test);
        $('#ccf_highlights/div:visible').hide();
        $('#ccf_highlights/div:first').show();
      },1000*loopTimer);
      return intervalID;
    }        
