/*
 *
 * http://www.systemagic.co.uk
 *
 */

$.slideshow = 0;

jQuery.fn.extend({
	slideshow: function(value){
		if(value == null){
			$(this).find("> *").not(":first").css("opacity", 0);
			if($(this).find(">*").length > 1) setTimeout("$('."+$(this).attr("class")+"').slideshow('change')", 5000);
		}else{
			$(this).find("> *").eq($.slideshow).animate({ 'opacity':0 }, 500);
			$.slideshow += 1;
			if($.slideshow >= $(this).children().length) $.slideshow = 0;

			$(this).find("> *").eq($.slideshow).animate({ 'opacity':1 }, 500, function(){
				setTimeout("$('."+$(this).parent().attr("class")+"').slideshow('change')", 5000);
			});
		}
		return this;
	}
});