jQuery(document).ready(function() {
  applyClickEvent();
});

applyClickEvent = function() {
/*
   jQuery("#ma_liste").wslide({
           width: 240,
           autolink: false,
           horiz: true
   });
*/
  jQuery('.mainNewsNavigation').click(function(e) {
    href = jQuery(this).attr('href');
    jQuery.get(href, function(data) {
        li = jQuery(data).find("li");
        if (href.match("previous")) {
          distance = -240;
          jQuery('.home_news').find('ul').find('li').after(li);
        } else {
          distance = 25;
          jQuery('.home_news').find('ul').css('left', '-240px');
          jQuery('.home_news').find('ul').find('li').before(li);
        }
        jQuery('.home_news').find('ul').animate({ left: distance+'px' }, 1500, 'swing', function() {

          if (href.match("previous")) {
            jQuery('.home_news').find('ul').find('li:not(:last)').remove();
          } else {
            jQuery('.home_news').find('ul').find('li:not(:first)').remove();
          }

          jQuery('.home_news').find('ul').css('left', '25px');
          applyClickEvent();
          tb_init('a.thickbox, area.thickbox, input.thickbox');
        });
        
        jQuery('.mainNewsNavigation.prev').hover(function() { 
          jQuery('.home_news span').css('background-position', 'left -16px'); 
        }, function() { 
          jQuery('.home_news span').css('background-position', 'left top'); 
        }); 
        jQuery('.mainNewsNavigation.next').hover(function() { 
          jQuery('.home_news span').css('background-position', 'left -32px'); 
        }, function() { 
         jQuery('.home_news span').css('background-position', 'left top'); 
        });
    });
    return false;
  });
  

  jQuery('.mainNewsNavigation.prev').hover(function() { 
    jQuery('.home_news span').css('background-position', 'left -16px'); 
  }, function() { 
    jQuery('.home_news span').css('background-position', 'left top'); 
  }); 
  jQuery('.mainNewsNavigation.next').hover(function() { 
    jQuery('.home_news span').css('background-position', 'left -32px'); 
  }, function() { 
   jQuery('.home_news span').css('background-position', 'left top'); 
  });
}

