// (c) 2001 - 2002 Tom Dolezal, all rights reserved
// updated: 20.5.2002 1:59

// item handlers
// over
function itemOver(id)
{
	if (document.all)
	{
		// odkaz na polozku menu
		var item = items.item('item_' + id);
		if (item.active == '0')
		{
			var icon = item.all.item('icon_' + id);
			var label = item.all.item('label_' + id);

			// zmena ikony a vzhledu
			if (icon) icon.src = icon.src.replace(regexOff, '_on.');
			with (label.style)
			{
				borderColor = '#054E73';
				backgroundColor = 'white';
			}
		}
	}
	else
	{
		var icon = document.getElementById('icon_' + id);
		var label = document.getElementById('label_' + id);
		// zmena ikony a vzhledu
		if (icon) icon.src = icon.src.replace(regexOff, '_on.');
		with (label.style)
		{
			borderColor = '#054E73';
			backgroundColor = 'white';
		}
	}
}
	
// out
function itemOut(id)
{
	if (document.all)
	{
		// odkaz na polozku menu
		var item = items.item('item_' + id);
		if (item.active == '0')
		{
			// odkazy na ikonu a nazev polozky
			var icon = item.all.item('icon_' + id);
			var label = item.all.item('label_' + id);
			
			// zmena ikony a vzhledu
			if (icon) icon.src = icon.src.replace(regexOn, '_off.');
			with (label.style)
			{
				borderColor = '#F8F8F8';
				backgroundColor = '#F8F8F8';
			}
		}
	}
	else
	{
		// odkaz na polozku menu
		var icon = document.getElementById('icon_' + id);
		var label = document.getElementById('label_' + id);
		// zmena ikony a vzhledu
		if (icon) icon.src = icon.src.replace(regexOn, '_off.');
		with (label.style)
		{
			borderColor = '#F8F8F8';
			backgroundColor = '#F8F8F8';
		}
	}
}
	
// click
function itemClick(id, dontClick)
{
	// odkaz na polozku menu
	var item = document.getElementById('item_' + id);
	var link = document.getElementById('link_' + id);
	if (item.active == '0' && link)
	{
		// obnoveni puvodne vybrane polozky
		if (itID)
		{
			// odkazy na objekty
			var item = document.getElementById('item_' + itID);
			var icon = document.getElementById('icon_' + itID);
			var label = document.getElementById('label_' + itID);
			var link = document.getElementById('link_' + itID);
			
			// zmena vhledu
			if (icon) icon.src = icon.src.replace(regexOn, '_off.');
			item.active = '0';
			item.style.cursor = 'hand';
			label.style.borderColor = '#F8F8F8';
			label.style.backgroundColor = '#F8F8F8';
			label.style.fontWeight = 'normal';
			if (link) link.style.cursor = 'hand';
		}
		// odkazy na aktivni polozku
		var item = document.getElementById('item_' + id);
		var link = document.getElementById('link_' + id);
		var label = document.getElementById('label_' + id);

		// zmena vzhledu
		item.active = '1';
		item.style.cursor = 'default';
		label.style.fontWeight = 'bold';
		link.style.cursor = 'default';

		// kliknuti
		if (link.click && !dontClick) link.click();
		itID = id;
	}
}

// zmena aktivni polozky
function itemSetClick(id)
{
	if (document.all)
	{
		for (var i = 0; i < items.length; i ++)
		{
			if (items(i).callID == id)
			{
				id = items(i).id.replace(/^item_/, '');
				itemOver(id);
				itemClick(id, true);
				break;
			}
		}
	}
}

// scroller handlers
// over
function scrollerOver(id, where)
{
	var scrollingDiv = document.getElementById('scrollingDiv_' + id);
	if (!scTimer && ((where == 'up' && scrollingDiv.scrollTop > 0) ||
		(where == 'down' && scrollingDiv.scrollTop + scrollingDiv.clientHeight < scrollingDiv.scrollHeight)))
	{
		scID = id;
		scrollerOffset = (where == 'up' ? -23 : 23);
		scTimer = window.setInterval('scroll()', 25);
		document.getElementById('scroller_' + id + '_' + where).style.borderColor = '#054E73';
	}
}
	
// out
function scrollerOut(id, where)
{
	// zruseni casovace posunu
	if (scTimer)
	{
		window.clearInterval(scTimer);
		scTimer = null;
	}

	// zmena vzhledu
	document.getElementById('scroller_' + id + '_' + where).style.borderColor = '#B0B0B0';
	window.status = '';
}
	
// out
function scrollerClick(id, where)
{
	// zruseni casovace posunu
	if (scTimer)
	{
		window.clearInterval(scTimer);
		scTimer = null;
	}
	// posunuti okna
	var scrollingDiv = document.getElementById('scrollingDiv_' + id);
	if (where == 'up')
	{
		scrollingDiv.scrollTop = 0;
		window.status = '0%';
	}
	else
	{
		scrollingDiv.scrollTop = scrollingDiv.scrollHeight - scrollingDiv.clientHeight;
		window.status = '100%';
	}

	// zmena vzhledu
	var icon = document.getElementById('scrollerIcon_' + id + '_' + where);
	icon.src = icon.src.replace(regexOn, '_off.');
	document.getElementById('scroller_' + id + '_' + where).style.borderColor = '#B0B0B0';
}

// timer handler for scroller
function scroll()
{
	// odkaz na okno
	var scrollingDiv = document.getElementById('scrollingDiv_' + scID);
	if (scrollingDiv)
	{
		// posunuti okna
		scrollingDiv.scrollTop = scrollingDiv.scrollTop + scrollerOffset;
		window.status = Math.round(scrollingDiv.scrollTop / ((scrollingDiv.scrollHeight - scrollingDiv.clientHeight) / 100)) + '%';
		if (scrollingDiv.scrollTop == 0)
		{
			// zmena vzhledu
			var icon = document.getElementById('scrollerIcon_' + scID + '_up');
			icon.src = icon.src.replace(regexOn, '_off.');
			document.getElementById('scroller_' + scID + '_up').style.borderColor = '#B0B0B0';
		}
		else if (scrollingDiv.scrollTop + scrollingDiv.clientHeight == scrollingDiv.scrollHeight)
		{
			// zmena vzhledu
			var icon = document.getElementById('scrollerIcon_' + scID + '_down');
			icon.src = icon.src.replace(regexOn, '_off.');
			document.getElementById('scroller_' + scID + '_down').style.borderColor = '#B0B0B0';
		}
		else
		{
			// zmena vzhledu
			var icon = document.getElementById('scrollerIcon_' + scID + '_up');
			icon.src = icon.src.replace(regexOff, '_on.');
			var icon = document.getElementById('scrollerIcon_' + scID + '_down');
			icon.src = icon.src.replace(regexOff, '_on.');
		}
	}
}
