galleryThumbs.js 2.4 KB
function c_GalleryThumb (thu, cat, tit, tex, u)
{
	var thumb = thu;
	var cat   = cat;
	var title = tit;
	var text  = tex;
	var url   = u;

	this.getThumb = function ()	{ return thumb; }
	this.getCat   = function ()	{ return cat; }
	this.getTitle = function ()	{ return title; }
	this.getText  = function ()	{ return text; }
	this.getUrl   = function ()	{ return url; }
}

function c_GalleryThumbs (_id, data, pos, _count)
{
	var thumbs = new Array ();
	var startIdx = pos;
	var id = _id;
	var count = _count;

	for (var d in data)
	{
		var expr = /(.*) [^ ]*$/;
		thumbs.push (
				new c_GalleryThumb (
					d.getThumbUrl (),
					d.getOrdnerName (0).toUpperCase (),
					d.titel,
					d.ffBildzeile+' '.substr (0, 100).replace (expr, '$1...'),
					d.getShowUrl ()));
	}

	// Dies kann warscheinlich auch raus aus c_GalleryThumbs
	this.popup = function (i)
	{
		url = document.getElementById (id+'_BG_URL1_'+i).href;
		thumbs = eval ();

		if (url.match (/javascript:ftvlaunch\(/))
		{
			expr = /\(([0-9]+),\s*([0-9]+),\s*'(.+)'\)/;
			expr.exec (url);

			ftvlaunch (RegExp.$1, RegExp.$2, RegExp.$3);
			return false;
		}

		return popup (document.getElementById (id+'_BG_URL1_'+i).href);
	}
	// -----

	function changeDisplay (client)
	{
		for (i = 0; i < count; i++)
		{
			idx = i + startIdx;

			if (idx > (thumbs.length - 1))
				idx -= thumbs.length;

			thumb = thumbs[idx].getThumb ();
			cat   = thumbs[idx].getCat ();
			title = thumbs[idx].getTitle ();
			text  = thumbs[idx].getText ();
			url   = thumbs[idx].getUrl ();

			document.getElementById (id+'_BG_THUMB'+i).src = thumb;

			node = document.getElementById (id+'_BG_CAT'+i);
			node.firstChild.data = cat;
			node = document.getElementById (id+'_BG_TITLE'+i);
			node.firstChild.data = title;
			node = document.getElementById (id+'_BG_TEXT'+i);
			node.firstChild.data = text;

			document.getElementById (id+'_BG_URL1_'+i).href = 
				url + '?em_client=' + client;
			document.getElementById (id+'_BG_URL2_'+i).href =
				url + '?em_client=' + client;
		}
	}

	this.incGallery = function (client)
	{
		startIdx = (startIdx == (thumbs.length - count)) ? 
			thumbs.length - count : startIdx + 1;

		changeDisplay (client);

		return false;
	}

	this.decGallery = function (client)
	{
		startIdx = (startIdx == 0) ?  0 : startIdx - 1;

		changeDisplay (client);

		return false;
	}
}