(function($) {
	$.fn.rw_slideset = function(options) {
		// set default options
		var defaults = {
			speed : 1000,
			pause : 10000,
			auto : 1
		},
		options = $.extend(defaults, options); // merge options
	
		// if pause is smaller than speed increases it to just about the options.speed.
		if(options.pause <= options.speed) { options.pause = options.speed + 100; }

		// for each item in the wrapped set
		return this.each(function() {
	
			// cache "this."
			var $this = $(this);
		
			$this.after('<input style="display: none;" id="'+$this.attr('id')+'-speed" value="'+options.speed+'" />');
			$this.after('<input style="display: none;" id="'+$this.attr('id')+'-pause" value="'+options.pause+'" />');
		
			// Wrap "this" in a div with a class of "slider-wrap."
			$this.wrap('<div class="slider-wrap"></div>');
		
			// Set the width to a really high number. Adjusting the "left" css values, so need to set positioning.
			$this.css({
				'width' : '99999px',
				'position' : 'relative',
				'padding' : 0
			});
		
			$('.slider-wrap').css({
				'width' : $this.children().width(),
				'overflow' : 'hidden'
			});
			var i = 1;
			$this.children().each(function(){
			
					$(this).addClass('rw-slide-'+i);
					i++;					   
			});
			//
			if(options.auto == 1 && $this.children().length > 1){
				setInterval(function() {
					// Animate to the left the width of the image/div
					$this.animate({'left' : '-' + $this.parent().width()}, options.speed, function() {
						// Return the "left" CSS back to 0, and append the first child to the very end of the list.
						$this
						   .css('left', 0)
						   .children(':first')
						   .appendTo($this); // move it to the end of the line.
						//$('#testthis').html($this.children(':first').attr('class'));
					})
				}, options.pause);
			}

		}); // end each	

	} // End plugin. Go eat cake.

})(jQuery);

(function($) {
	$.fn.rw_slide = function(slide) {

		if(slide == null){
			return false;
		}

		// for each item in the wrapped set
		return this.each(function() {
								  
			// cache "this."
			var $this = $(this);		
			var i = 0;
				
			while(!$this.children(':first').hasClass('rw-slide-'+slide)){i++;
				$this
					.css('left', 0)
					.children(':first')
					.appendTo($this);		
				if(1>100){break;}
			}
		
		}); // end each	

	} // End plugin. Go eat cake.

})(jQuery);