/*
 * jQuery scrub plugin 0.1
 *
 * http://stucktogetherwithtape.com/code
 *
 * Copyright (c) 2010 Jim Wardlaw
 */
(function($)
{
	$.fn.scrub = function(options)
	{
		// Set the options.
		options = $.extend({}, $.fn.scrub.defaults, options);

		// Go through the matched elements and return the jQuery object.
		return this.each(function()
		{
			// get trigger width
			// (scrubber width / number of children)
			var trigger = $(this).width()/$(this).children().length;
			
			// bind event when mouse moves over scrubber
			$(this)
				.mousemove(function(e){
					// get x mouse co-ord
					var x = e.pageX - $(this).offset().left;
					
					// get the index of image to display on top
					var index = Math.ceil(x/trigger);
					
					// move all other children to back
					$(this).find(':not(:nth-child('+index+'))').css('z-index', 0);					
					
					// move selected child to front
					$(this).find(':nth-child('+index+')').css('z-index', 1);
				});
		});
	};
	// Public defaults.
	$.fn.scrub.defaults = {
		property: 'value'
	};
	// Private functions.
	function func()
	{
		return;
	};
	// Public functions.
	$.fn.scrub.func = function()
	{
		return;
	};
})(jQuery);
