(function($) {
	$.fn.myImageFader = function(options) {
		
	var defaults = {			
		container: '.slider',
		slides: '.slides',
		pagination: '.pagination',
		containerClick: true, // Click container for next slide
		autoStart: 3000, // Set to positive number for auto start and interval time
		restart: 0, // Set to positive number for restart and restart time
		slidespeed: 300, // Speed of slide animation
		fadespeed: 300, // Speed of fade animation
		autoHeight: false // Set to positive number for auto height and animation speed
	};
	
	this.each(function() {
		var obj = $(this);
		var o = $.extend(defaults, options);
		var s = $(o.slides,obj).children().size();
		var u = false;
		var t = 0;

		$(o.slides,obj).children().each(function(){
			$(this).css({position:'absolute',left:0,display:'none'});
		});

		$(o.slides,obj).children(":eq("+t+")").show();
		if (s > 1) sliderIntervalID = setInterval(function(){if(u===false){fadeaway();}}, o.autoStart);
		
		$(o.container).hoverIntent({
			timeout: 100,
			over: function(){
				if (u === false){
					if (s > 1)clearInterval(sliderIntervalID);
					$(o.slides,obj).children(":eq("+t+")").children("span").slideDown(400);
					mover = 1;
					}
			}, out: function(){
				if (u === false){
					$(o.slides,obj).children(":eq("+t+")").children("span").slideUp(400);
					$(o.slides,obj).children(":eq("+t+")").children("span").hide();
					if (s > 1) sliderIntervalID = setInterval(function(){fadeaway();}, o.autoStart);
					mover = 0;
					}
				}
			});
			
		function fadeaway(){
			//clearInterval(sliderIntervalID);
			c = t;
			t = t +1;
			if (t == (s)) t = 0;
			
			$(o.slides,obj).children(":eq("+c+")").fadeOut(400,function(){
						$(o.slides,obj).children(":eq("+c+")").hide();
						});
			$(o.slides,obj).children(":eq("+t+")").fadeIn(400);
			
			}

		});
	};	
})(jQuery);