$(document).ready(function() {

	//unhide images that I've hidden during page load via css.
	$('#slideshow-home img').css({display:'block'});
	
	//start cycle plugin options
	$('#slideshow-home')
	.after("<div class='slideshow-nav-container'><div id='slideshow-nav'><a class='slideshow-nav-prev' href='#' title='Previous'>&laquo;</a><div class='slideshow-bg'><span class='slideshow-paginate'></span></div><a class='slideshow-nav-next' href='#' title='Next'>&raquo;</a><div class='clearl'></div></div></div>") 
	.cycle({ 
		fx:		'fade',
		delay:	3000,	// additional delay (in ms) for first transition (hint: can be negative)
		speed:	1000,	// speed of the transition
		timeout:	2400, 
		pause:	1,	//pause on hover
		fastOnEvent:	true,	//fast transition for pager, or use the next option below.
		//manualTrump:	true,	// causes manual transition to stop an active transition instead of being ignored
		pagerEvent: 'click',
		pagerClick:	Pager, //callback function when clicking pager links
		pager:	'.slideshow-paginate',
		next:	'.slideshow-nav-next', 
		prev:	'.slideshow-nav-prev',
		prevNextClick:   Prev, //callback function when clicking prev/next
		pagerAnchorBuilder:	pagerAnchors
	});


	$('.slideshow-home-nav-pause').click(function() { 
		$('#slideshow-home').cycle('pause');
		return false;
	});
	
	$('.slideshow-home-nav-resume').click(function() { 
		$('#slideshow-home').cycle('resume', true);
		return false;
	});

	function Pager(zeroBasedSlideIndex, slideElement) {
	    $('#slideshow-home').cycle('pause'); 
	 }
	
	function Prev(curr, next, opts) {
	    var index = opts.currSlide;
	    $('#slideshow-home').cycle('pause'); 
	}

	function pagerAnchors(index, slide) {
		var title = $('#slideshow-home').children('a').eq(index).attr('title');  //get the alt tag!

		if(index < 1) {
			return "<a href='#' class='nav-border-left' title='"+title+"'>"+title+"</a>";
			//return "<a href='#' class='nav-border-left' title='"+title+"'>" + parseInt(1+index,10) + "</a>";
		} else {
			return "<a href='#' title='"+title+"'>"+title+"</a>";
			//return "<a href='#' title='"+title+"'>" + parseInt(1+index,10) + "</a>";
		}
	}

});