(function($) {
$.fn.innerfade = function(options) {
	this.each(function(){ 			
		var settings = {
			speed: 'normal',
			timeout: 100000,			
			runningclass: 'innerfade'
		};		
		if(options)
			$.extend(settings, options);		
		var elements = $("table#image_rotate tr").children();	
		alert(elements)
		if (elements.length > 1) {		
			$(this).css('position', 'relative');	
			$(this).css('height', settings.containerheight);
			$(this).addClass(settings.runningclass);			
			for ( var i = 0; i < elements.length; i++ ) {
				$(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute');
				$(elements[i]).hide();
			};
				setTimeout(function(){do {
					current = Math.floor ( Math.random ( ) * ( elements.length ) );} 
					
					while ( current == 0 )
					$.innerfade.next(elements, settings, current, settings.shofirst);
					
				}, settings.timeout);
				$(elements[settings.shofirst]).show();	
				$("table#image_rotate tr").css('height', $(elements[settings.shofirst]).height());
		}		
	});
};

$.innerfade = function() {}
$.innerfade.next = function (elements, settings, current, last) {
		$(elements[last]).fadeOut(settings.speed);
		$(elements[current]).fadeIn(settings.speed);
		$(elements[current]).next().fadeIn(settings.speed);
		$("table#image_rotate tr").css('height', $(elements[current]).height());		
		$(elements[last]).slideUp(settings.speed, $(elements[current]).slideDown(settings.speed));
      last = current;
		while (	current == last ) {
			current = Math.floor ( Math.random ( ) * ( elements.length ) );
		};
	setTimeout((function(){$.innerfade.next(elements, settings, current, last);}), settings.timeout);
};
})(jQuery);

