jQuery(document).ready(function(){
	var j = jQuery.noConflict();
	
	/*
		This code handles the homepage slider.
		
		For more info, see http://nivo.dev7studios.com/#usage
	*/
	if(j('.cms-home').length){
		j('#slider').nivoSlider({
			effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
			slices:15, // For slice animations
			boxCols: 8, // For box animations
			boxRows: 4, // For box animations
			animSpeed:500, // Slide transition speed
			pauseTime:4000, // How long each slide will show
			startSlide:0, // Set starting Slide (0 index)
			directionNav:false, // Next & Prev navigation
			controlNav:false, // 1,2,3... navigation
			controlNavThumbs:false, // Use thumbnails for Control Nav
			keyboardNav:true, // Use left & right arrows
			pauseOnHover:true, // Stop animation while hovering
			manualAdvance:false // Force manual transitions
		});
	}
	
	/*
		This code handles each products coloured swatches, and making them change the image
	*/
	if(j('.swatch').length){
		j('li.item div.more-views a').click(function(){
			var item = j(this).parent().parent().parent().parent().parent();
			
			if(j('.swatch',item).length == 1) return false;
			
			var url = j(this).attr('href');
			j('.product_image',item).attr('src',url);
			j('.swatch_title',item).text(j(this).attr('title'));
			
			return false;
		}).click(function(){return false;});
	}
});
