$(document).ready(function () {
	// MOTIVE ROTATOR
	$('#rotator').each(function () {
		var $this = $(this),
			time = null,
			eq = 0,
			len = $('.item', $this).length - 1;
		$('.item', $this).hide().css('position', 'absolute');
		$('.item:eq(' + eq + ')', $this).show();
		$('.pager a:eq(' + eq + ')', $this).addClass('active');
		$('.rotator-wrap', $this).css('overflow', 'hidden');

		var rote = function (eq) {
			if (eq != $('div.active', $this).index()) {
				$('div.item:eq(' + eq + ')', $this).show().css({ 'z-index': '2', 'opacity': '1' });
				$('div.active', $this)
					.animate({
						'opacity': '0'
					}, 2500, function () {
						$(this).hide().removeClass('active').css('z-index', '1');
						$('div.item:eq(' + eq + ')', $this).addClass('active');
					});
				$('.pager a', $this).removeClass('active');
				$('.pager a:eq(' + eq + ')', $this).addClass('active');
			}
		}
		var timex = function () {
			time = setInterval(function () {
				if (eq == len) {
					eq = 0;
				}
				else {
					eq = eq + 1;
				}
				rote(eq);
			}, 10000);
		}
		timex();

		$('.pager a', $this).click(function () {
			eq = $(this).index();
			rote(eq);
			time = clearInterval(time);
			timex();
			return false;
		});
	});

});
