

/**
 * Readmore * x
 * 
 * @author Marcin Gil <mg@ovos.at>
 */
(function($)
{
	$.fn.multireadmore = function(options)
	{
		var opts = $.extend({}, $.fn.multireadmore.defaults, options);
		
		return this.each
		(
			function()
			{
				var self = this;
				var $self = $(self);
				
				var items = $(opts.item, self);
				
				items.each(function()
				{
					var item = this;
					var readmore = $(opts.readmore, this);
					var more = $(opts.more, readmore);
					
					more.bind('click', function()
					{
						// Hide all other contents
						$('> ' + opts.readmore + ' > div', items).hide();
						$('> ' + opts.readmore + ' > ' + opts.more, items).show();
						
						// Show the one that we should show ;)
						$('> ' + opts.readmore + ' > '+ opts.more, item).hide();
						$('> ' + opts.readmore + ' > div', item).fadeIn();
						
						return false;
					});	
				});
			}
		);
	}
	
	$.fn.multireadmore.defaults =
	{
		item: 'div.item',
		more: 'a.more',
		readmore: 'div.readmore',
		content: 'div'
	};
})(jQuery);