var area_photos =
{
	slideshowInitialized : null,
	slideshowInterval : null,
	slideshowIntervalValue : 5000,

	swapMainImage : function(index)
	{
		$("#areaphotosshow .active").stop().removeClass("active");
		this.stopSlideShow();
		$("#areaphotosshow .areaphoto:eq("+index+")").addClass("active");
		this.slideShow();

		return false;
	},

	stopSlideShow : function()
	{
		window.clearInterval(this.slideshowInterval);
	},

	slideShowInit : function()
	{
		if (this.slideshowInitialized == null)
		{
			$("#areaphotosshow").bind("mouseover",function(){
				area_photos.stopSlideShow();
			}).bind("mouseout", function(){
				area_photos.slideShow(area_photos.slideshowIntervalValue);
			});
			this.slideshowInitialized = true;
			return true;
		}
		else return true;
	},

	slideShow : function(interval)
	{
		if (this.slideShowInit())
		{
			if (interval > 1000)
				this.slideshowIntervalValue = interval;
			this.slideshowInterval = setInterval( this.slideSwitch, this.slideshowIntervalValue );
		}
	},

	/**
	 * http://jonraasch.com/blog/a-simple-jquery-slideshow
	 */
	slideSwitch : function()
	{
		var $active = $('#areaphotosshow .active');
		
		if ( $active.length == 0 ) $active = $('#areaphotosshow .areaphoto:last');

		var $next =  $active.next().length ? $active.next() : $('#areaphotosshow .areaphoto:first');

		$active.addClass('last-active');

		$next.css({
			opacity: 0.0
		})
		.addClass('active')
		.animate({
			opacity: 1.0
		}, 1000, function() {
			$active.removeClass('active last-active');
		});
	}
};

$.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};

