if (document.getElementById && document.getElementsByTagName)
{
	var CSS = '';

	document.write('<style type="text/css">' + CSS + '</style>');
}

var Navi = new Object();
Navi.active = null;
Navi.list = null;
Navi.up = null;
Navi.down = null;
Navi.offset = 71;
Navi.imgOffset = 8;

window.addListener(Navi);

Navi.onload = function()
{
	if (document.getElementById && document.getElementsByTagName)
	{
		this.active = document.getElementById('active');
		var full = document.getElementById('full').getElementsByTagName('img')[0];
		var thumbs = document.getElementById('thumbs');
		this.list = thumbs.getElementsByTagName('div')[0];
		var items = thumbs.getElementsByTagName('ul')[0].getElementsByTagName('li');

		for (var i = 0, ii = items.length; i < ii; i++)
		{
			var naviItem = new NaviItem(items[i]);
		}

		if ((thumbs.offsetHeight + this.offset / 2) >= (this.list.offsetTop + this.list.offsetHeight)) return;

		this.up = document.getElementById('up');
		this.up.obj = this;
		this.down = document.getElementById('down');
		this.down.obj = this;

		if (this.active.offsetTop >= thumbs.offsetHeight)
		{
			this.list.style.top = (thumbs.offsetHeight - this.active.offsetTop - this.offset) + 'px';
		}

		if (this.list.offsetTop < 0)
		{
			this.up.style.display = 'block';
		}

		if ((thumbs.offsetHeight + this.offset / 2) < (this.list.offsetTop + this.list.offsetHeight))
		{
			this.down.style.display = 'block';
		}

		this.up.onclick = function()
		{
			var list = this.obj.list;

			if (list.offsetTop < 0)
			{
				var top = (list.style.top) ? parseInt(list.style.top) : 0;
				top += this.obj.offset;
				top += 'px';
				list.style.top = top;

				this.obj.down.style.display = 'block';

				if (0 <= list.offsetTop)
				{
					this.style.display = 'none';
				}
			}
		};

		this.up.style.cursor = 'hand';
		if (!this.up.style.cursor)
		{
			this.up.style.cursor = 'pointer';
		}

		this.down.onclick = function()
		{
			var list = this.obj.list;

			if ((thumbs.offsetHeight + this.obj.offset / 2) < (list.offsetTop + list.offsetHeight))
			{
				var top = (list.style.top) ? parseInt(list.style.top) : 0;
				top -= this.obj.offset;
				top += 'px';
				list.style.top = top;

				this.obj.up.style.display = 'block';

				if ((list.offsetTop + list.offsetHeight) <= (thumbs.offsetHeight + this.obj.offset / 2))
				{
					this.style.display = 'none';
				}
			}
		};

		this.down.style.cursor = 'hand';
		if (!this.down.style.cursor)
		{
			this.down.style.cursor = 'pointer';
		}
	}
};

var NaviItem = function(element)
{
	this.element = element;
	this.element.obj = this;

	this.link = this.element.getElementsByTagName('a')[0];
	this.link.obj = this;

	this.border = document.createElement('span');
	this.link.appendChild(this.border);
	this.border.obj = this;

	if (this.element.id != 'active')
	{
		this.link.onmouseover = this.hilite;
		this.link.onmouseout = this.clear;
	}
};
NaviItem.prototype.hilite = function()
{
	this.obj.border.className = 'over';
};
NaviItem.prototype.clear = function()
{
	this.obj.border.className = '';
};

