(function($){
	$.fn.rssReader=function(j){
		var k=$.extend({targeturl:"http://www.clashdesign.net/blog/index.php/feed/rss2",items:5,Maxlength:100,Maxlength2:40,loadingImg:'/themes/default/img/loader.gif'},j);
		
		if(!j.targeturl) 
			return false;
		
		var l=$.extend(k,j);
		var m=($.browser.msie);
		
		if(m){
			$('#newsfeed').ajaxStart(
				function(){
					$('<img id="loading" src="'+l.loadingImg+'" alt="Traitement en cours ..." />').css({'opacity':1}).appendTo('#newsfeed')
				});
			$("#newsfeed").ajaxError(
				function(){
					$(this).append("<strong>Error requesting page</strong>")
				});
			
			$.get(l.targeturl,function(f){
				$('#newsfeed img').remove();
				var i=0;
				var g=j.items;
				function h(e){
					$(f).find('item').each(function(i){
						if(i>e-1) return;
						var a=$(this).find('title').text();
						var b=$(this).find('pubDate').text();
						var c=$(this).find('link').text();
						var d=$(this).find('description').text();
						
						if (i==0) {
							$('<a class="targetblank" href="'+c+'">'+a+'</a>').html(a).appendTo('#newsfeedLeft');
							$('<div class="date">'+b+'</div>').html(b).appendTo('#newsfeedLeft');
							$('<div class="description"><a href="'+c+'">'+o(d,j.Maxlength)+'</a></div>').html(o(d,j.Maxlength)).appendTo('#newsfeedLeft');
						}else{
							$('<a class="targetblank" href="'+c+'">'+a+'</a>').html(a).appendTo('#newsfeedRight');
							$('<div class="date">'+b+'</div>').html(b).appendTo('#newsfeedRight');
							$('<div class="description"><a href="'+c+'">'+o(d,j.Maxlength2)+'</a></div>').html(o(d,j.Maxlength2)).appendTo('#newsfeedRight');
						}
						$('#newsfeedLeft .description p img').remove();
						$('#newsfeedRight .description p img').remove();
					})
				}
				return h(g)
			})
		
		}else{
			
			var n="xml";
			
			$.ajax({
				   type:"get",
				   url:l.targeturl,
				   dataType:n,
				   processData:false,
				   beforeSend:function(){
				   		$('<img id="loading" src="'+l.loadingImg+'" alt="Traitement en cours ..." />').css({'opacity':1}).appendTo('#newsfeed')},
				   success:function(f){
					    $('#newsfeed img').remove();
						var i=0;
						var g=j.items;
						
						function h(e){
							$(f).find('item').each(function(i){
								if(i>e-1) return;
								var a=$(this).find('title').text();
								var b=$(this).find('pubDate').text();
								var c=$(this).find('link').text();
								var d=$(this).find('description').text();
								
								if (i==0) {
									$('<a class="targetblank" href="'+c+'">'+a+'</a>').html(a).appendTo('#newsfeedLeft');
									$('<div class="date">'+b+'</div>').html(b).appendTo('#newsfeedLeft');
									$('<div class="description"><a href="'+c+'">'+o(d,j.Maxlength)+'</a></div>').html(o(d,j.Maxlength)).appendTo('#newsfeedLeft');
								}else{
									$('<a class="targetblank" href="'+c+'">'+a+'</a>').html(a).appendTo('#newsfeedRight');
									$('<div class="date">'+b+'</div>').html(b).appendTo('#newsfeedRight');
									$('<div class="description"><a href="'+c+'">'+o(d,j.Maxlength2)+'</a></div>').html(o(d,j.Maxlength2)).appendTo('#newsfeedRight');
								}
								$('#newsfeedLeft .description p img').remove();
								$('#newsfeedRight .description p img').remove();
							})
						}
						return h(g)
					}
				})
			}
	};
	
	function o(a,b){
		var c=a.split(/\s/);
		
		if(c.length<=b)return a;
		
		var d='';
		
		for(var i=0;i<b;i++){
			d+=c[i]+' ';
		}
		return d
	}
})
(jQuery);