/* Interaction JS *

	=Sliders
	=Cycles
	=Clock
	=End
*/

$(document).ready(function() {
	
			
	// =Sliders
	
	// Horizontal Slider
	var container = $('article header nav');
	var ul = $('ul', container);
	var maxWidth = ul.innerWidth() - container.outerWidth();
	
	if (maxWidth <= 0) {
		maxWidth = 0;
		$('.horizontal').css('cursor', 'auto');
	} else {
		$('.horizontal', container).slider({
			min: 0,
			max: maxWidth,
			slide: function (event, ui) {
				ul.stop();
				ul.css({'left' : ui.value * -1}, 500);
			}
		});
	}
	
	// Vertical Slider
	var contain = $('article section');
	var section = $('#section', contain);
	var maxHeight = section.innerHeight() - contain.outerHeight();
	if (maxHeight <= 0) {
		maxHeight = 0;
		$('.vertical').css('cursor', 'auto');
	} else {
		$('.vertical').slider({
			min: 0,
			max: maxHeight,
			orientation: 'vertical',
			value: maxHeight,
			slide: function(event, ui) {
				section.stop();
				section.css({
					'top' : ui.value - maxHeight
				}, 500);
			}
		});
	}
	
	
	// =Cycles
	
	// Figure Cycle
	$('#gallery_figure').cycle({ 
		fx: 'fade', 
		speed: 3000, 
		timeout: 5000, 
		pauseOnPagerHover: 1, 
		pager: '#gallery_pager', 
		pagerAnchorBuilder: function(idx, slide) { 
			return '#gallery_pager li:eq(' + idx + ') a'; 
		} 
	});
	
	// Title Cycle
	$('#article_title').cycle({ 
		fx: 'fade', 
		speedOut: 250, 
		speedIn: 750, 
		timeout: 5000, 
		pauseOnPagerHover: 1, 
		pager: '#gallery_pager', 
		pagerAnchorBuilder: function(idx, slide) { 
			return '#gallery_pager li:eq(' + idx + ') a'; 
		} 
	}); 
	
	
	// =Clock
	
	$('.jclock').jclock();
	
	
	// =End.
	
});

