
jQuery(document).ready(function($) {
	
	var slideshow = $('.tw-slideshow-wrap');
	
	slideshow.each(function() {
		var wrap = $(this);
		var prev = wrap.find('.tw-slideshow-nav .s-prev');
		var next = wrap.find('.tw-slideshow-nav .s-next');
		wrap.find('.tw-slideshow').cycle({
					  speed:1500,
					  /*timeout:$(this).attr('data-timeout'),*/
					  timeout:0,
					  fx:$(this).attr('data-effect'),
					  prev:prev,
					  next:next,
					  before:function(currSlideElement, nextSlideElement, options, forwardFlag) {
						  var i = $(nextSlideElement);
						  i.css({marginLeft: 450-($(this).width()/2), marginTop: 300-($(this).height()/2)});
					  }
					  });
				
		//hover
		prev.hover(function() {
			//on over
			prev.click();
			slideshow.everyTime(1500, 'previous', function() { prev.click(); });
		}, function() {
			//on out
			slideshow.stopTime('previous');
		});
		
		next.hover(function() {
			//on over
			next.click();
			slideshow.everyTime(1500, 'next', function() { next.click(); });
		}, function() {
			//on out
			slideshow.stopTime('next');
		});
		
		slideshow.removeAttr('data-speed').removeAttr('data-effect').removeAttr('data-timeout');
		
	});
		
});
