(function($) {
    $.fn.imageslideshow = function(options) {
        var settings = {'speed': 1500,'interval': 5000,'width': 'auto','height': 'auto','active': '0'};
        return this.each(function() {
            if (options) {
                $.extend(settings, options);
            }
            var container = $(this);
			var list = container.children('ul');
            var tempcount = container.find('a').length;
            var items = container.find('a');
			var activeMe = settings.active;
			if(activeMe >= tempcount){
				activeMe = 0;
			}
            container.css('height', 'auto');
			if(settings.height != 'auto'){
				container.find('ul').height(settings.height);
			}
			else{
				container.find('ul').height(container.find('img').eq(0).height());
			}
            items.children('img').css({'width': settings.width,'height': settings.height});
			items.hide(0);
			items.eq(activeMe).fadeIn(settings.speed);
            function showMe(){
				window.clearInterval(timerId);
				items.eq(activeMe).fadeOut(settings.speed,function(){$(this).hide(0);}
				);
				activeMe++
				if(activeMe == tempcount){
					activeMe = 0;
				}
				items.eq(activeMe).fadeIn(settings.speed,function(){
					timerId = setInterval(function() {
						showMe()
					}, settings.interval);
				});				
			}
			var timerId = setInterval(function() {
				showMe()
			}, settings.interval);
        });
    };
})(jQuery);
