// owner: Rob

function _CScrollThumbsBase()
{
	this.ref = null;
	this.aThumbs = null;
	this.aIndices = null;
	this.idMinNr = 0;
	this.idNrActive = 0;
	this.nSidecellCount = 0;
	this.nCellCount = 0;
	this.nTimer = 0;
	this.nTimerInterval = 0;
}
_CScrollThumbsBase.prototype._Construct = function(idMinNr, nSidecellCount)
{
	this.aThumbs = new Array();
	this.aIndices = new Array();
	this.idMinNr = idMinNr;
	this.idNrActive = idMinNr;
	this.nSidecellCount = nSidecellCount;
	this.nCellCount = 1 + 2 * nSidecellCount;
	this.nTimerInterval = 4000;
	this.ref = "_CScrollThumbs" + idMinNr;
	eval(this.ref + "=this");
}
_CScrollThumbsBase.prototype.Action = function(nIdNr, bUseFading) {}
_CScrollThumbsBase.prototype.ExtraAction = function(nIdNr) {}
_CScrollThumbsBase.prototype.AddThumb = function(nIdNr, sThumbTag, sExtraData)
{
	this.aIndices[nIdNr] = this.aThumbs.length;
	this.aThumbs[this.aThumbs.length] = { nIdNr:nIdNr, sThumbTag:sThumbTag, sExtraData:sExtraData };
}
_CScrollThumbsBase.prototype.OnClickedCell = function(iCell)
{
	var iActiveItem = this.aIndices[this.idNrActive];
	if (typeof iActiveItem == "undefined")
		return;

	this._StopSlideshow();
	var iItem = iActiveItem - this.nSidecellCount + iCell;
	if ((iItem >= 0) && (iItem < this.aThumbs.length))
		this._StepTo(this.aThumbs[iItem].nIdNr);
}
_CScrollThumbsBase.prototype.StepLeft = function()
{
	var iItem = this.aIndices[this.idNrActive];
	if ((typeof iItem != "undefined") && (this.aThumbs.length))
	{
		this._StopSlideshow();
		if (--iItem >= 0)
			this._StepTo(this.aThumbs[iItem].nIdNr);
		else
			this._StepTo(this.aThumbs[this.aThumbs.length - 1].nIdNr);
	}
}
_CScrollThumbsBase.prototype.StepRight = function()
{
	var iItem = this.aIndices[this.idNrActive];
	if (typeof iItem != "undefined")
	{
		this._StopSlideshow();
		if (++iItem < this.aThumbs.length)
			this._StepTo(this.aThumbs[iItem].nIdNr);
		else if (this.aThumbs.length)
			this._StepTo(this.aThumbs[0].nIdNr);
	}
}
_CScrollThumbsBase.prototype.StepUp = function() { this.StepLeft(); }
_CScrollThumbsBase.prototype.StepDown = function() { this.StepRight(); }
_CScrollThumbsBase.prototype.Slideshow = function()
{
	if (this.nTimer)
		this._StopSlideshow();
	else
		this._NextSlide();
}
_CScrollThumbsBase.prototype._StepTo = function(nIdNr, bUseFading)
{
	var iActiveItem = this.aIndices[nIdNr];
	if (typeof iActiveItem == "undefined")
		return;

	var obj = null;
	var iItem = iActiveItem - this.nSidecellCount;
	for (var iCell=0; iCell<this.nCellCount; iCell++, iItem++)
	{
		obj = document.getElementById("idThumbcell" + this.idMinNr + "_" + iCell);
		if (!obj)
			return;
		if ((iItem >= 0) && (iItem < this.aThumbs.length))
		{
			obj.innerHTML = this.aThumbs[iItem].sThumbTag;
//			obj.onclick = ((iItem == iActiveItem) ? null : eval(this.aThumbs[iItem].sOnClick));
//alert(obj.onclick);
			obj.style.cursor = ((iItem == iActiveItem) ? "default" : "pointer");
		}
		else
		{
			obj.innerHTML = "&nbsp;";
//			obj.onclick = null;
			obj.style.cursor = "default";
		}
	}
	this.Action(nIdNr, bUseFading);
	this.ExtraAction(nIdNr);
	this.idNrActive = nIdNr;
}
_CScrollThumbsBase.prototype._NextSlide = function()
{
	var iItem = this.aIndices[this.idNrActive];
	if (typeof iItem != "undefined")
	{
		if (++iItem < this.aThumbs.length)
		{
			this._StepTo(this.aThumbs[iItem].nIdNr, browser && browser.ie4win);
			this.nTimer = setTimeout(this.ref + "._NextSlide()", this.nTimerInterval);
		}
		else
			this._StopSlideshow();
	}
}
_CScrollThumbsBase.prototype._StopSlideshow = function()
{
	if (this.nTimer)
	{
		clearTimeout(this.nTimer);
		this.nTimer = 0;
	}
}
_CScrollThumbsBase.prototype._Dump = function()
{
	var s = "";
	for (var prop in this)
	{
		if (typeof this[prop] != "function")
			s += prop + ": " + this[prop] + "\n";
	}
	s += "\n";
	for (var prop in this)
	{
		if (typeof this[prop] == "function")
			s += prop + ": function()\n";
	}
	alert(s);
}




function CScrollThumbs(idMinNr, nSidecellCount)
{
	this._Construct(idMinNr, nSidecellCount);
//	this._Dump();
}
CScrollThumbs.prototype = new _CScrollThumbsBase();
CScrollThumbs.prototype.constructor = "CScrollThumbs";
CScrollThumbs.prototype.Action = function(nIdNr, bUseFading)
{
	var oContentDiv = null;
	for (var iItem=0; iItem<this.aThumbs.length; iItem++)
	{
		oContentDiv = document.getElementById("idScrollThumbContent_" + this.aThumbs[iItem].nIdNr);
		if (oContentDiv)
			oContentDiv.style.display = ((this.aThumbs[iItem].nIdNr == nIdNr) ? "" : "none");
	}
}




function CScrollThumbsPhoto(idMinNr, nSidecellCount)
{
	this._Construct(idMinNr, nSidecellCount);
//	this._Dump();
}
CScrollThumbsPhoto.prototype = new _CScrollThumbsBase();
CScrollThumbsPhoto.prototype.constructor = "CScrollThumbsPhoto";
CScrollThumbsPhoto.prototype.Action = function(nIdNr, bUseFading)
{
	var iActiveItem = this.aIndices[nIdNr];
	if (typeof iActiveItem == "undefined")
		return;

	var img = document.getElementById("idScrollThumbContent_" + this.idMinNr);
	if (img)
	{
		if (bUseFading)
		{
			img.style.filter = (browser.ie55win ?
				("progid:DXImageTransform.Microsoft.Fade(duration=0.6, overlap=1)") :
				("blendTrans(duration=0.6)"));
			img.filters[0].apply();
		}
		img.src = this.aThumbs[iActiveItem].sExtraData;
		if (bUseFading)
			img.filters[0].play();
	}

	var nNr = iActiveItem + 1;
	var obj = document.getElementById("idSTBV_counter1");
	if (obj)
		obj.innerHTML = nNr;
	obj = document.getElementById("idSTBV_counter2");
	if (obj)
		obj.innerHTML = nNr;
}
