// JavaScript Document

$(document).ready(function() {
	
	//// INIT ////
	$(".scrubber").scrub();
	
	//// VARS ////
	var i = 1;
	
	// get number of children
	var children = $(".scrubber").children().length;

	// get width of scrubber
	var width = $(".scrubber").width();

	// get x axis trigger
	var trigger = width/children;
	
	//// SCRUBBER FUNCTIONS ////
	$("#scrubber").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);
	});
	
	//// CYCLE FUNCTIONS ////
	$('.slideshow').cycle({
			// fx: 'scrollLeft',
			fx:     'fade', 
		 	// speed:  'fast',
			timeout: 40000,
			next:   '#next_feature', 
			prev:   '#prev_feature'
		});
	
});
