$(document).ready(function(){

/*
	$('.slideshow img').each(function(i, e) {
		alert($(e).height());
		$(e).css({ marginTop: -$(e).height()/2 });
	});

*/

	$('.slideshow').cycle({
		fx:    'fade',
		speed:  2500,
		// random: true,
		easing: 'easeInOutBack',
		fastOnEvent: 1000,
		before: function(currSlideElement, nextSlideElement, options, forwardFlag){
			setTimeout(function(){
				var id = $(nextSlideElement).attr('id').replace('image-', '');
				$('#sidebar #product-' + id).addClass('current').siblings('li').removeClass('current');
			}, 100);
		}
	});

	var current_slide;

	$('#sidebar .for-slideshow a').hover(function(e){

		var slide_index = $(this).parent().attr('id').replace('product-', '')*1;
		if(current_slide == slide_index) return;
		$('.slideshow').cycle(slide_index-1);
		// return false;
		current_slide = slide_index;
	})

});

