$(function() {
   var containerWidth = $('.sns_header .component.view_line.lastalerts').outerWidth({margin: true});
   var positions = new Array();
   var curPos = containerWidth;
   $('.sns_header .component.view_line.lastalerts a').each(
      function() {
         var currentPos = curPos;
         positions.push(currentPos);
         curPos += $(this).outerWidth({margin: true}) + 300; // marge de 300px entre chaque élément
         $(this).css('left', currentPos + 'px');
      });
   var childrenWidth = curPos - 300 - containerWidth;

   function animateAlerts()
   {
      $('.sns_header .component.view_line.lastalerts a').each(
         function(index) {
            var current = $(this);
            $(this).animate(
               {left: (positions[index] - containerWidth - childrenWidth) + 'px'},
               30000, 'linear',
               function() {
                  current.css('left', positions[index] + 'px');
                  animateAlerts();
               });
         });
   }
   animateAlerts();
   
   $('ul.converttoselect,ol.converttoselect').each(function() {
      var select = $('<select class="converttoselect"></select>');
      var firstElt = $(':first', this);
      if ( firstElt.find('a').length != 0 )
         select.append('<option value="">-</option>');
         $(this).find('li').each(function() {
         if ( $(this).find('a').length == 0 )
            select.append('<option value="">' + $(this).text() + '</option>');
         else
         {
            var a = $(this).find('a').eq(0);
            select.append('<option value="' + a.attr('href') + '" target="'+a.attr('target')+'">' + a.text() + '</option>');
         }
      });
      $(this).after(select).remove();
   });
   $('select.converttoselect').change(function () {
      if ($(this).val() != '') {
        window.open($(this).val(), $(this).children( "option:selected" ).attr('target'));
      }
   });
});