jQuery.noConflict();
jQuery(document).ready(function($){
    $(window).load(
		    function() {		
				$('.slideshow').cycle({
					fx: 'fade',
					timeout: 3000,
					delay:  -1000,
					autostop: 1,
					easing: 'easeInSine',
					speed: 500,
					after: changeUrls
				});
		    }
		);

		
		
		$.fn.delay = function(time, callback){
		    var $t = this;
		    // No queing, just uses setTimeout:
		    setTimeout(function(){
		        callback.call($t);    
		    }, time);
		    return $t;
		}

		//$('.image').delay(5000, nextImage);
		
		var currentImage = $('.image');
		var imageCount = 1;
		
		function nextImage() {
			var numofquotes = $(".image").size();
			if (imageCount < numofquotes) {
				//show the next quote
				var toshow = $('.image').eq(imageCount);
				imageCount++;
				
				$('.image:not(:hidden)').fadeOut(1000, function(){
					toshow.fadeIn(1000);
					currentImage = toshow;
				});
				//Wait 8 seconds, rotate
				$('image').delay(5000, nextImage);
			}
		}
		
		function changeUrls(currSlideElement, nextSlideElement, options, forwardFlag){
		    var index = options.currSlide;
			
			var projectURL = $(nextSlideElement).children(".homeimagecaptiontext").html();
			$(".homecaptiondisplay").html(projectURL);

			return false;
		}
});

