$(function() {

	var jRotator = $('#rotator-items');
	if (jRotator != undefined) {
		
		function pagerFactory(idx, slide) {
			return '<div><a href="#">'+(idx+1)+'</a></div>';
		};
		
		function setSlideTimeout(curr,next,opts,fwd) {
			currentClass = $(next).attr('class');
			if (currentClass != null && currentClass != "" && isNumeric(currentClass)) {
				return parseFloat(currentClass);
			} else {
				return opts.timeout;
			}
		}
	
		function isNumeric(data) {
			return parseFloat(data)==data;
		}
	
		function pauseRotator() {
			$(rotatorElement).cycle('pause');
			// $('#pause-button').hide();
			// $('#play-button').show();
		}
		
		function resumeRotator() {
			$(rotatorElement).cycle('resume', true);
			// $('#pause-button').show();
			// $('#play-button').hide();
		}
		
		$('#pause-button > img').click(function() { 
			// pauseRotator();
		});
		
		$('#play-button > img').click(function() { 
			// resumeRotator(); 
		});	
	
		$('#play-button').hide();
		$('#pause-button').hide();
		$('#next-button').hide();
		$('#prev-button').hide();
		
		jRotator.cycle({
			fx:		 						'fade',
			speed:							2000,
			timeout: 						4000,
			slideExpr:					'.rotator-item',
			random:						 false,
			// prev:								'#prev-button',
			// next:								'#next-button',
			pager:	 						'#nav-items',
			pagerAnchorBuilder: pagerFactory,
			fastOnEvent:				100,
			timeoutFn:					setSlideTimeout
		});
	}
		
});
