var Renderers = {
	list:function(item, rendercount, config){
		var _date = item.date.getDate() + '-' + (item.date.getMonth()+1) + '-' + item.date.getFullYear();

		if(item.tip.indexOf('<') && config.usehtml) { // is html
			var _tip = item.tip.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&quot;/g,'"');
			var _htip = jQuery('<div>' + _tip + '</div>');
			if(jQuery('img:not([src*=rss.feedsportal.com]):not([src*=feeds.feedburner.com])',_htip).size() > 0) {
				_tip = '';
				jQuery('img:not([src*=rss.feedsportal.com]):not([src*=feeds.feedburner.com])',_htip).each(function() {
					if(this.width || this.height) {
						var width = this.width, height = this.height, ratio = width / height;
						if(width > jQuery('#rss_' + rendercount + ' .news_section').width()) {
							width = jQuery('#rss_' + rendercount + ' .news_section').width();
							height = width / ratio;
						}

						_tip += '<img src="' + this.src + '" width="' + width + '" height="' + height + '" />';
					} else {
						_tip += '<img src="' + this.src + '" />';
					}
				});
			} else {
				_tip = _htip.text();
				if(_tip.length > config.max && config.max > 0) {
					_tip = _tip.substr(0,config.max);
					_tip += '...';
				}
			}
		} else {
			if(item.tip.indexOf('<')) {
				item.tip = jQuery('<div>' + item.tip + '</div>').text();
			}
			var _tip = (config.max > 0) ? item.tip.substr(0,config.max) : item.tip;
			if(item.tip.length > config.max && config.max > 0) { _tip += '...'; }
		}

		if(item.title.indexOf('<') > -1) {
			item.title = jQuery('<div>' + item.title + '</div>').text();
		}

		var _title = (config.max > 0) ? item.title.substr(0,config.titlemax) : item.title;
		if(item.title.length > config.titlemax && config.titlemax > 0) { _title += '...'; }

		if(typeof(item.url)!=='undefined' && item.url !== ''){
			return '<li class="news_section"><p><a href="' + item.url+ '" title="' + item.title + '" target="_blank">' + _title + '</a></p></li>';
		} else {
			return '<li class="news_section"><p>' + _title + '</p></li>';
		}
	},
	div:function(item, rendercount, config){
		var _date = item.date.getDate() + '-' + (item.date.getMonth()+1) + '-' + item.date.getFullYear();
		if(item.tip) {
			if(item.tip.indexOf('<') && config.usehtml) { // is html
				var _tip = item.tip.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&quot;/g,'"');
				var _htip = jQuery('<div>' + _tip + '</div>');
				if(jQuery('img:not([src*=rss.feedsportal.com]):not([src*=feeds.feedburner.com])',_htip).size() > 0) {
					_tip = '';
					jQuery('img:not([src*=rss.feedsportal.com]):not([src*=feeds.feedburner.com])',_htip).each(function() {
						if(this.width || this.height) {
							var width = this.width, height = this.height, ratio = width / height;
							if(width > jQuery('#rss_' + rendercount + ' .news_section').width()) {
								width = jQuery('#rss_' + rendercount + ' .news_section').width();
								height = width / ratio;
							}

							_tip += '<img src="' + this.src + '" width="' + width + '" height="' + height + '" />';
						} else {
							_tip += '<img src="' + this.src + '" />';
						}
					});
				} else {
					_tip = _htip.text();
					if(_tip.length > config.max && config.max > 0) {
						_tip = _tip.substr(0,config.max);
						_tip += '...';
					}
				}
			} else {
				if(item.tip.indexOf('<') > -1) {
					item.tip = jQuery('<div>' + item.tip + '</div>').text();
				}
				var _tip = (config.max > 0) ? item.tip.substr(0,config.max) : item.tip;
				if(item.tip.length > config.max && config.max > 0) { _tip += '...'; }
			}
		} else { var _tip = ''; }

		if(item.title.indexOf('<') > -1) {
			item.title = jQuery('<div>' + item.title + '</div>').text();
		}

		var _title = (config.titlemax > 0) ? item.title.substr(0,config.titlemax) : item.title;
		if(item.title.length > config.titlemax && config.titlemax > 0) { _title += '...'; }

		if(typeof(item.url)!=='undefined' && item.url !== ''){
			return '<div class="news_section"><p class="title"><a href="' + item.url+ '" title="' + item.title + '" target="_blank">' + _title + '</a></p><p class="tip">' + _tip + '</p><p class="date">' + _date + ' <a href="' + item.url+ '" target="_blank">Lees verder</a></p></div>';
		} else {
			return '<div class="news_section"><p class="title">' + _title + '</p><p class="tip">' + _tip + '</p><p class="date">' + _date + '</p></div>';
		}
	},
	create:function(type, count, config) {
		switch(type) {
			case 'div':
				return function(item) {
					return Renderers.div(item, count, config);
				}
				break;
			case 'list':
			default:
				return function(item) {
					return Renderers.list(item, count, config);
				}
				break;
		}
	}
}
