var d3mls_main =
{
	setupJQueryUI : function()
	{
		//console.log("caller is " + arguments.callee.caller.toString());
		$("head").append('<script type="text/javascript" src="/js/jquery/extensions/d3mls/js/jquery-ui-1.8.12.custom.min.js"></script>')
			.append('<link href="/js/jquery/extensions/d3mls/css/custom-theme/jquery-ui-1.8.12.custom.css" rel="stylesheet" type="text/css" />');
	}

};

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

	swapMainImage : function(index)
	{
		$("#slideshow IMG.active").stop().removeClass("active");
		this.stopSlideShow();
		$("#slideshow img:eq("+index+")").addClass("active");
		this.slideShow();
	},

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

	slideShowInit : function()
	{
		if (this.slideshowInitialized == null)
		{
			$("#slideshow").bind("mouseover",function(){
				d3mls_details.stopSlideShow();
			}).bind("mouseout", function(){
				d3mls_details.slideShow();
			});
			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 = $('#slideshow IMG.active');

		if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

		var $next =  $active.next().length ? $active.next() : $('#slideshow IMG: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;
	}
};

