﻿$(document).ready(
	function() {

		// cycles the images
		$('.cmcycle1').cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			timeout: 0,
			speed: 1000
		});


		// cycles the content area to right
		$('#cmcycle2').cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			timeout: 5000,
			speed: 1000,
			pause: 1,
			pager: '#pager',
			pagerAnchorBuilder: function(idx, slide) {
				return '#pager a:eq(' + idx + ')';
			},
			pauseOnPagerHover: true,
			before: onBeforeCycle
		});


		//  restore the standard click navigate functionality to pager menu 
		$('.cnav').unbind('click').click(function() {
			window.location = $(this)[0].href;
		});

		// set correct slide on hover
		$('.cnav').each(function(n) {
		$(this).hover(function() {
			skipFirstTransition = false;
				$('#cmcycle2').cycle(n);
				$('.cmcycle1').cycle(n);
			});
		});
	}
);


// cycle the image, each time the content slide is cycled
// special code to prevent initial transition
var skipFirstTransition = true;
function onBeforeCycle() {
	if (skipFirstTransition == true) {
		skipFirstTransition = false;
	}
	else {
		$('.cmcycle1').cycle('next');
	}
}
	
