// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){
	
	$('.sliderPanel').find(".slidesWrap ul").css("width",($(this).find(".slidesWrap ul").children().size()*169));
	
	$('.sliderPanel').serialScroll({
		target:'.slidesWrap',
		items:'li',
		prev:'a.prev',
		next:'a.next',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:600,
		force:false,
		stop:true,
		lock:false,
		interval:3000,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false, //click on the images to scroll to them
		exclude:3
	});
});



jQuery(function( $ ){
	
	$('.sliderPanel_product_page').find(".slidesWrap_product_page ul").css("width",($(this).find(".slidesWrap_product_page ul").children().size()*95));
	
	$('.sliderPanel_product_page').serialScroll({
		target:'.slidesWrap_product_page',
		items:'li',
		prev:'a.prev',
		next:'a.next',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:600,
		force:false,
		stop:true,
		lock:true,
		interval:300000,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false, //click on the images to scroll to them
		exclude:3,
		onBefore: function(event, element, obj, coll, pos){
			var next_link = $('.sliderPanel_product_page .sliderNav').find('a.next');
			var prev_link = $('.sliderPanel_product_page .sliderNav').find('a.prev');
			var total = coll.length - 5;
			pos += 1;
			
			if(pos == total) {
				next_link.hide();
			} else {
				next_link.show();
			}
			if(pos > 1) {
				prev_link.show();
			} else {
				prev_link.hide();
			}
		}
	});
	
	var next_link = $('.sliderPanel_product_page .sliderNav').find('a.next');
	var prev_link = $('.sliderPanel_product_page .sliderNav').find('a.prev');
	prev_link.hide();
	if($('.slidesWrap_product_page ul li').length <= 6) {
		next_link.hide();
	} else {
		next_link.show();
		
	}
});


//on hover

function hoverElementSlider(element, hover_div_class) {
	element.hover(
	  function () {
		  $(this).find("." + hover_div_class).show();
		  
		  }, 
		  function () {
		    $(this).find("." + hover_div_class).hide();
		  }
	);
}
