
$(document).ready(function () {
	$("a.nav-prev, a.nav-next, ul.dual-list a").bind('click.prevent', function(e) {
		e.preventDefault();
	});

	var scrollableOptions = {
		 size: 1
		,keyboard: false
		,navi: "ul.dual-list"
		,prev: ".nav-prev"
		,next: ".nav-next"
		,interval: 5000
		,loop: true
		,onSeek: function() {
			var desc = this.getConf().duelTitle;
			var url = '/pojedynek/' + this.getConf().duelId + '/' + this.getConf().duelUrlTitle + '#pojedynek';

			var $titleSpan = this.getRoot().next(".dual-title").children("span");

			if (desc == $titleSpan.text()) {
				return false;
			}

			$titleSpan.stop().animate({opacity: 0}, 300, 'linear', function() {
				$(this).text(desc).animate({opacity: 1}, 300);
			});

			this.getRoot().nextAll("a.vote").attr('href', url);
		}
	};

	window.setTimeout(function() {
		$(".duels-widgets .similar .dual-images").scrollable(scrollableOptions);
	}, 1000);
	window.setTimeout(function() {
		$(".duels-widgets .most-popular .dual-images").scrollable(scrollableOptions);
	}, 2000);
	window.setTimeout(function() {
		$(".duels-widgets .best-judged .dual-images").scrollable(scrollableOptions);
	}, 3000);
	window.setTimeout(function() {
		$(".duels-widgets .most-badly-judged .dual-images").scrollable(scrollableOptions);
	}, 4000);

});
