jQuery.fn.dynamicSlideshow = function(attr) {
	attr = attr || {};
	attr.duration = attr.duration || 3000;
	attr.fadeup = attr.fadeup || 1000;
	attr.fadedn = attr.fadedn || 1000;
	attr.offAdd = attr.offAdd || 0 ;
	
	function initSlider(container, img) {
		var curr = 1;
		setInterval( function(){
			if (curr == img.length) {
				curr = 0;
			}
			var i = new Image() ;
			
			$(i).load(function(){
				
				var offset = $(container).find('img:first').height() ;
				offset += attr.offAdd ;
				offsetCss = '-' + offset + 'px' ;
				//alert(offset) ;
				
				$(this).addClass(attr.imgClass) ;
				$(this).css({position:'relative', top:offsetCss, opacity: 0.0, 'z-index': 2}) ;
				$(container).append('<br>') ;
				$(container).append(this);
				$(container).find('img:first').css({'z-index': 1});
				$(container).find('img:first').animate({opacity:0},attr.fadedn) ;
				$(this).animate({opacity: 1.0}, attr.fadeup, function() {
						$(container).find('img:first').remove();
						$(container).find('br').remove() ;
						$(this).css({top:0}) ;
					})
			}).attr('src', img[curr++]).css({'z-index':8});
		}, attr.duration );
	};

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

