






$.fn.newsticker = function() {
    
    return this.each(function() {
    
        var $container = jQuery(this);
        var $news = $container.find("p");



        var $first_news = $news.filter(":first");
        
        $news.filter(":not(:first)").hide();
        
      /*  $container.height($first_image.height());
        $container.width($first_image.width());
		
		*/
        
        $news.css("position", "absolute");

        
        $news.filter(":not(:last)").each(function(index) {
            $(this).data("next", index + 1);
        });
        $news.filter(":last").data("next", 0);
        
        function fade_news() {
        
            var $current_news;
            var next_id;
            var $next_news;
            
            $current_news = $news.filter(":visible");
            next_id = $current_news.data("next");
            $next_news = $news.filter(":eq(" + next_id + ")");
            
            $current_news.fadeOut(1000).delay(1000);
            $next_news.delay(1000).fadeIn(1000);
        }
        
        window.setInterval(fade_news, 10000);
    });

}












$(document).ready(function() {
    $("div.topnews-container").newsticker();
});




