;(function($) {
	
$.fn.inverisImageCycle = function(options) {
	var defaults = {
		speed : 1500,
		interval : 4000
	},
	settings = $.extend({}, defaults, options),
	$self = this;

	if($self.find('a').length == 0)
	{
		$self.find('img').css({
			position: 'absolute',
			top : 0
		});
	
		$self.find('img:first')
			.addClass('active')
			.css({
				top : 0,
				zIndex : 1  
			})
		;
	}
	else
	{
		$self.find('a').css({
			position: 'absolute',
			top : 0
		});
	
		$self.find('a:first')
			.addClass('active')
			.css({
				top : 0,
				zIndex : 1  
			})
		;
	}
	
	cycle = function() {
		if($self.find('a').length == 0)
		{
			var $current = $self.find('img.active');
			var $next = $current.next('img');
			if($next.length == 0)
			{
				$next = $self.find('img:first');
			}
		}
		else
		{
			var $current = $self.find('a.active');
			var $next = $current.parent().parent().parent().next().find('a');
			if($next.length == 0)
			{
				$next = $self.find('a:first');
			}
		}
		
		$next.hide();
		$next.css({ zIndex : 2 });
		
		$next.fadeIn(settings.speed, function(){
			$current.hide();
			$next.css({ zIndex : 1 });
			$next.addClass('active');
			$current.removeClass('active');
		});
	};

	if($self.find('a').length > 1)
	{
		playing = setInterval(cycle, settings.interval);
	}
	else
	{
		if($self.find('img').length > 1)
		{
			playing = setInterval(cycle, settings.interval);
		}
	}
}; // inverisImageCycle

})(jQuery);
