var van_dullink__website__interface__shared__gallery_c = function()
{
	this.group_i = 0;
	this.flow_i = 0;
	this.path_a = [];
	this.open_path_s = '';

	/**/

	this.setElementVisible = function(id_s, state_b)
	{
		var element_o = document.getElementById(id_s);

		if (element_o)
			element_o.style.display = state_b ? '' : 'none';
	};

	/**/

	this.setBackgroundVisible = function(state_b)
	{
		var background_o = document.getElementById('gallery_background');

		if (background_o)
		{
			background_o.style.height = document.body.offsetHeight + 'px';
			background_o.style.display = state_b ? '' : 'none';
		}
	};

	this.setOpenVisible = function(state_b)
	{
		this.setElementVisible('gallery_open', state_b);

		if (state_b) gallery_o = this;
	};

	this.setOpenNavigation = function()
	{
		var open_b = (this.path_a.length > 1)

		this.setElementVisible('gallery_open_next', open_b);
		this.setElementVisible('gallery_open_previous', open_b);
		this.setElementVisible('gallery_open_flow', open_b);
	};

	this.setOpenPath = function(path_s)
	{
		var image_o = document.getElementById('gallery_open_image');

		if (image_o)
			image_o.src = path_s + '?width=640&height=480';

		this.open_path_s = path_s;
	};

	this.getOpenPathIndex = function()
	{
		var path_index_i = false;

		for (var index_i = 0; index_i < this.path_a.length; index_i++)
			if (this.path_a[index_i] == this.open_path_s)
			{
				path_index_i = index_i; break;
			}

		return path_index_i;
	};

	this.setFlowStart = function()
	{
		var host_o = this;

		var setStart = function()
		{
			host_o.setNext(true);
		};

		this.flow_i = setInterval(setStart, 3500);
	};

	this.setFlowStop = function()
	{
		clearInterval(this.flow_i);
	};

	/**/

	this.setGroup = function(index_i)
	{
		this.group_i = index_i;
	};

	this.setPath = function(path_s)
	{
		this.path_a.push(path_s);
	};

	this.setVisible = function(path_s, open_path_s)
	{
		var image_o = document.getElementById('gallery_image_' + this.group_i);

		if (image_o)
			image_o.src = path_s + '?width=310&height=200';

		this.open_path_s = open_path_s ? open_path_s : path_s;
	};

	this.setOpen = function()
	{
		this.setBackgroundVisible(true);
		this.setOpenVisible(true);
		this.setOpenNavigation();
		this.setOpenPath(this.open_path_s);
	};

	this.setClose = function()
	{
		this.setFlowStop();
		this.setBackgroundVisible(false);
		this.setOpenVisible(false);
	};

	this.setNext = function(flow_b)
	{
		if (!flow_b) this.setFlowStop();

		var index_i = this.getOpenPathIndex();
			index_i = ((index_i + 1) < this.path_a.length) ? ++index_i : 0;

		this.setOpenPath(this.path_a[index_i]);
	};

	this.setPrevious = function()
	{
		 this.setFlowStop();

		var index_i = this.getOpenPathIndex();
			index_i = ((index_i - 1) > 0) ? --index_i : (this.path_a.length - 1);

		this.setOpenPath(this.path_a[index_i]);
	};

	this.setFlow = function()
	{
		this.setFlowStop();
		this.setFlowStart();
	};
};
