jQuery.fn.dynamicSlideshow = function(attr) {
	attr = attr || {};
	attr.duration = attr.duration || 3000;
	function initSlider(container, img) {
		var curr = 1;
		setInterval( function(){
			if (curr == img.length) {
				curr = 0;
			}
			var i = new Image();
			jQuery(i).load(function(){
				jQuery(container).append(this);
				jQuery(container).find('img:first').css({'z-index': 1});
				jQuery(this).css({opacity: 0.0, 'z-index': 2}).animate({opacity: 1.0}, 1000, function() {
						jQuery(container).find('img:first').remove();
					})
			}).attr('src', img[curr++]).css({position:'absolute',top:0,left:0,'z-index':8});
		}, attr.duration );
	};

	jQuery(this).each(function(){
		var img = [];
		jQuery(this).find("a").each(function(){
			img.push(jQuery(this).attr("href"));		
		});
		var j = new Image();
		var container = this;
		jQuery(this).empty();
		jQuery(j).attr('src', img[0]).css({position:'absolute',top:0,left:0,'z-index':0}).load(function(){
			jQuery(container).append(this);
			initSlider(container, img);
		});
	});
}

