/* This version of FeaturedSlideshow uses jquery instead of mootools */
function FeaturedSlideshow(el, data)
{
	var obj = this;
	this.data = data;
	this.div = document.getElementById(el);
	this.img = this.div.getElementsByTagName('img')[0];
	this.img2 = this.div.getElementsByTagName('img')[1];
	this.index = 0;
	setTimeout(function(){ obj.transition(obj.img, obj.img2); }, 5000); 
}

FeaturedSlideshow.prototype = {
		transition: function(img, img2)
		{
			var obj = this;
			this.index++;
			if(this.index >= this.data.length)
			{
				this.index = 0;
			}

			var next = this.data[this.index];
			img.src = next.src;
			img.title = next.caption;
			img.alt = next.caption;
			$j(img).bind('click', function(){ obj.clicked(next.href); });
			
			$j(img).fadeIn(3000);
			$j(img2).fadeOut(3000, function(){ obj.transitionFinish(img, img2) });
		},
		clicked: function(href)
		{
			window.location.href = href;
		},
		transitionFinish: function(img, img2)
		{
			var obj = this;
			setTimeout(function(){ obj.transition(img2, img); }, 5000); 
		}
}

