$(document).ready(function(){  										 
	// move the readmore links into the prev sibling para
	$('.readmore').each(function(){
		$(this).removeClass('up-2').appendTo($(this).prev('p'));
	})
	
		//::TODO:: selectors should be cached		   		   
		// show slideshow navigation
		$('.image-slider-nav').css('display','block');
		// implement pause/resume toggle
		$('.image-slider-control p').toggle(function(){
			$('.image-slider').cycle('pause');
			$(this).text('Play');
			$(this).parent().addClass('paused');
		},function(){
			$('.image-slider').cycle('resume');
			$(this).text('Paused');
			$(this).parent().removeClass('paused');
		});
		
		// hide overflow (look in css for .nojs --> no scrollbar)								  
		$('.image-slider').removeClass('nojs');

		//click on .image-slider shows next image unless it's a link
		$('.image-slider').click(function(event){
			if (!$(event.target).is('a')){
				$('.image-slider').cycle('next','$(this)');
			};
		});
		
		// Create columns if there are no CSS3 columns
		if (!Modernizr.csscolumns){
			// prevent splitting ul/ol over columns
			$('.three-col ol, .three-col ul').addClass('dontsplit');
			$('.three-col').columnize({ columns : 3 });
		}      								  

		$('.image-slider').cycle({ 
			// generate link id's with onbefore (CSS)   
			before: onBefore,   
			fx:     'fade',
			// actual transition 
			speed:  '400',
			// how long is the slide visible
			timeout: 7000, 
			//what div to populate with page links
			pager:  '.image-slider-nav-slides',
			//trigger event when pager links are clicked on (pause slideshow) 
			pagerClick: pauseSlide
		});
		
    // create link id's so they can be styled
		function onBefore(){		
			$('.image-slider-nav-slides a').each(function(index){
				// zero based so let's up the index by one	  
				index++;
				$(this).attr(('id'), 'slide-nav-' + index);
				//keep it alive in the corpse known as IE6
				$(this).attr(('style'), 'zoom:1;');
				});
		}								
		
		function pauseSlide(){
			$('.image-slider').cycle('pause');
			$('.image-slider-control p').text('Play');
			$('.image-slider-control').addClass('paused');
		}								
}); //end doc ready

