/*
 * SCM cycle/slideshow/carousel
 * Version: 2.0
 * Updated: 14/03/2011
*/

var $j = jQuery.noConflict();

$j(function() {
		   
// cycle:		   
	
	var index = 0, hash = window.location.hash;
		if (hash) {
			index = /\d+/.exec(hash)[0];
			index = (parseInt(index) || 1) - 1;
		}
	
	// on imax page: 	 
	$j('#imax_features .feat_slides').cycle({ 
		fx: 'toss',
		speed: 600,
		startingSlide: index,
		pager: '.slide_nums',
		pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) { 
        	return '.slide_nums li a:eq(' + idx + ')';
    	},
		after: function(curr,next,opts) {
				window.location.hash = opts.currSlide + 1;
		}
	});
	
	// on new homepage w/carousel: 
	$j('#home_features .feat_slides').cycle({ 
		fx: 'scrollHorz',
		speed: 600,
		startingSlide: index,
		pager: '.slide_nums',
		pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) { 
        	return '.slide_nums li a:eq(' + idx + ')';
    	},
		after: function(curr,next,opts) {
				window.location.hash = opts.currSlide + 1;
		}
	});
	
	$j('#pause-play').toggle (
		function () {
			$j(this).addClass('paused');
			$j(this).html('<a href="#">Play</a>');
			$j('.feat_slides').cycle('pause');
		},
		function () {
			$j(this).removeClass('paused');
			$j(this).html('<a href="#">Pause</a>');
			$j('.feat_slides').cycle('resume');
		}	
	);

});
