$(document).ready(function(){	
	$("#splashxx").easySlider({
		auto: true,
		continuous: true,
		controlsShow: false,
		pause: 4500,
		speed:1800
	});

	/*
		## Where to buy - country drop down
	*/
	
	$("#thechoices").change(function(){
		$("#" + this.value).show().siblings().hide();
	});
	
	$("#thechoices").change();
	
	$('.countries .customers:nth-child(3n)').css({'margin-left': '12px', 'margin-right':'12px'});



	// Product colour slideshow
	$('#the-product-images li:first').addClass('active');
	
	//Next Slide by calling the function
	$('#btn-next').click(function () {
		scroller(0);	
		return false;
	});	

	//Previous slide by passing prev=1
	$('#btn-prev').click(function () {
		scroller(1);	
		return false;
	});	
	

	$('#fb3 ol').makeacolumnlists({cols:3,colWidth:105,equalHeight:false,startN:1});
	
	
	$("#fb3 li").mouseover(function () {
	var $this = $(this);
		$("#corner_logo div").hide();
		$("#slide" + $this.attr("id").replace(/category/, "")).show();
	});
	$("#fb3 li").mouseout(function () {
	var $this = $(this);
		$("#corner_logo div").hide();
		$("#slide_initial").show();
	});


	$('#splash2 ul').innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 4500,
		type: 'sequence',
		containerheight: 'auto'
	});

	$('#article-slideshow ul').innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 4500,
		type: 'sequence',
		containerheight: 'auto'
	});

});	


function scroller(prev) {

	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#the-product-images li.active').length ? $('#the-product-images li.active') : $('#the-product-images li:first');

	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#the-product-images li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#the-product-images li:first');
	}

	//clear the selected class
	$('#the-product-images li').removeClass('active');
	
	//reassign the selected class to current items
	next_image.addClass('active');

	//Scroll the items
	$('#mask-gallery').scrollTo(next_image, 200);		
	
}


