function OSP_Eshop_Module_ProductsSlideshow(module_id, id, duration)
{
	// public Integer
	this.module_id = module_id;

	// public String
	this.id = id;

	// private Integer
	this.duration = duration;

	// private Object
	this.response;

	// private Array
	this.preview_img_arr = new Array();
	this.selected_file_id_arr = new Array();


	// public
	this.Init = function(product_index, options)
	{
		window.setTimeout(dojo.hitch(this, function () {
			this.GetProduct(product_index, options);
		}), this.duration);
	};


	// public
	this.GetProduct = function(product_index, options)
	{
		var url = OSP_PUBLIC_PATH + '/?module_id=' + this.module_id + '&plugin=eshop&action=eshop_product_slideshow_get_product&product_index=' + product_index;

		dojo.xhrGet({
			url : url,
			content : {
				'random' : options['random']
			},
			load : dojo.hitch(this, this.GetProduct_OK)
		});
	}


	// protected
	this.GetProduct_OK = function(response)
	{
		eval('this.response = ' + response);

		$('#' + this.id + '_container').fadeOut('slow', dojo.hitch(this, this.FadeOutFinished));
	}


	this.ImageLoaded = function()
	{
		// Begin the fade in before changing content (so the new content will be hidden)
		$('#' + this.id + '_container').fadeIn('slow', dojo.hitch(this, this.FadeInFinished));

		// Change content
		byId(this.id + '_container').innerHTML = this.response['html'];
	}


	this.FadeInFinished = function()
	{
		window.setTimeout(dojo.hitch(this, function() {
			this.GetProduct(this.response['next_product_index'], this.response);
		}), this.duration);
	}


	this.FadeOutFinished = function()
	{
		var item_index = this.preview_img_arr.push(new Image()) - 1;
		this.preview_img_arr[item_index].onload = dojo.hitch(this, this.ImageLoaded);

		// Load image
		this.preview_img_arr[item_index].src = this.response['image_url'];
	}
}

