var count = 0;
jQuery('document').ready(function() {
		
	var images = jQuery('#slideshow').children().size();
	var spanInfo = jQuery('span#spanInfo').attr('rel');
	jQuery('#slideshow').after('<ul id="slideshow-nav">').cycle({ 
		fx:     'fade', 
		speed:  1000, 
		timeout: 5000, 
		pager:  '#slideshow-nav',
		// pause: 1, // killed b/c of conflict with play/pause button
		
		pagerAnchorBuilder: function(idx, slide) {
			count++;
			var markup = '<li><a href="#">' + count + '</a></li>'
			if (count == images && spanInfo != 'noMore') {
				markup += '<li>&nbsp; <a id="slideshowPlayPause" href="">Play/Pause</a></li>';
				// markup += '<li>&nbsp; <a id="photoGalleryLink" href="/photo-gallery.cfm">View All</a></li>'; // this adds view all link
			}
			return markup;
		} 
	});
	
	var pause = 0;
	jQuery('#slideshowPlayPause').click(function() {
		if (pause == 0) {
			jQuery('#slideshow').cycle('pause');
			pause = 1;
			return false;
		} else if (pause == 1) {
			jQuery('#slideshow').cycle('resume');
			pause = 0;
			return false;
		}
	});
	
	jQuery("#directions").live('submit', function() {
		window.location = '/directions/'+jQuery("#from").val()+'/'+jQuery("#to").val()+'/';
		return false;
	})
});
