(function($){

    $.fn.chi_gallery2 = function(vars) {

		var element		= this;
		var timeOut     = (vars.timeOut != undefined) ? vars.timeOut : 6000;

        var slideContent = function() {
			var current = ($("#" + element[0].id + " a.show") ? $("#" + element[0].id + " a.show") : $("#" + element[0].id + " a:first"));
			var next = ((current.next().length) ? current.next() : $("#" + element[0].id + " a:first"));
			next.css({opacity: 0.0})
				.addClass('show')
				.animate({opacity: 1.0}, 1000);
			current.animate({opacity: 0.0}, 1000)
				.removeClass('show');
		}

		$("#" + element[0].id + " a").css({opacity: 0.0});
		$("#" + element[0].id + " a:first").css({opacity: 1.0});
		setInterval(slideContent, timeOut);

    };

})(jQuery);

