var d3mls_main =
{
//	setupJQueryUI : function()
//	{
//		$("head").append('<script type="text/javascript" src="/js/jquery/extensions/d3mls/js/jquery-ui-1.8.14.custom.min.js"></script>')
//			.append('<link href="/js/jquery/extensions/ui/themes/coldwell/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />');
//	},
	
	loadProgressWheel : function(divId, loadingIcon)
	{
		if (loadingIcon == null)
			loadingIcon = "/images/ajax-loader.gif";
		$("<div class='loadingBlanket'></div>").prependTo("#"+divId).css({
			height: $("#"+divId).height()
		}).show();
		$("<img class='loadingIcon' src='"+loadingIcon+"' />").prependTo("#"+divId).css({
			"top"		: ($("#"+divId).height() / 2),
			"left"		: ($("#"+divId).width() / 2)
		}).show();
	},
	
	hideProgressWheel : function(divId)
	{
		$("#"+divId).find(".loadingBlanket").hide().end().find(".loadingIcon").hide().end();
	}

};

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;
	}
};

