jQuery.fn.efade = function()
{
	this.each( function()
	{
		//get current object
		var t = jQuery( this );
		
		//setup the items
		var items = [];
		var current_item = -1;
		var pause = false;
		var counter = 4000;
			
		//setup the class
		t.addClass( 'efade' );
		
		//get content
		var t_content = $( '> *', t );
		
		$( t_content ).each( function() {
		
			var c = $( this );
			c.addClass( 'efade_item' );
			
			var item = [ c ];
			
			items.push( item );
		} );
		
		showImage = function() {
		
			if( ! items.length ) {
				t.remove();
				return;
			}
			
			var active = current_item;
			
			//use this to pull the images in the order they appear in the markup
			var next =  current_item + 1;
			if( next >= items.length ) next = 0;
			
			if( active >= 0 ) { 
				items[active][0].animate({opacity: 0.0}, 1000 );
			}
			items[next][0].animate({opacity: 1.0}, 1000 );
			
			current_item = next;
			if( items.length > 1 ) {
				setTimeout( "this.showImage()", counter );
			}
		}
		
		showImage();
						
	});
}

