jQuery(window).load(function() {
	var f = function(index, el) {
		var t = $(this);
		var title = '';
		var width = this.width || this.naturalWidth;
		var maxWidth = parseInt(t.css('max-width'));
		width = (width>maxWidth)? maxWidth : width;
		$(this).css('float', 'none').css('width', width+'px').css('max-width', width+'px');
		var img = jQuery("<p>").append($(this).eq(0).clone()).html();
		if($(this).attr('title')) {
			title = $(this).attr('title');
		} else {
			var pathname = $(this).attr('src');
			title = pathname.substr(pathname.lastIndexOf("/")+1, pathname.lastIndexOf(".") - pathname.lastIndexOf("/")-1);
		}
		if (title.indexOf('notitle') != -1) title = '';
		$(this).replaceWith('<div class="clear"></div><div class="img-title" style="max-width: '+width+'px; width: '+width+'px;">' + img + '<span>' + decodeURI(title) + '</span></div>');
	};
	$('.news-show-intro, .news-show-text, .article-text').find('img').add('img.inserted').each(f);
	$('.news-show-intro, .news-show-text, .article-text').each(function() {
		$(this).addClass('fleft');
	})
});

