function getRelatedTarget(event)
{
	if(window.navigator.appName == 'Microsoft Internet Explorer')
		return window.event.toElement;
	else
		return event.relatedTarget;
}

function isDescendant(element1, element2)
{
	if(element1 == element2)
		return true;
	for(var i = 0; i < element1.childNodes.length; i++)
	{
		if(element1.childNodes[i] == element2)
			return true;
		if(isDescendant(element1.childNodes[i], element2))
			return true;
	}
	return false;
}

function link_onmouseout(event)
{
	if(!isDescendant(document.getElementById('popup' + this.id.substr(4)), getRelatedTarget(event)))
	{
		this.style.backgroundColor = '';
		popup = document.getElementById('popup' + this.id.substr(4));
		popup.style.display = 'none';
	}
}

function link_onmouseover(event)
{
	this.style.backgroundColor = '#DDDDDD';
	popup = document.getElementById('popup' + this.id.substr(4));
	popup.style.display = 'block';
	popup.style.top = (this.offsetTop + 100) + 'px';
}

function popup_onmouseout(event)
{
	if(!isDescendant(this, getRelatedTarget(event)))
	{
		this.style.display = 'none';
		link = document.getElementById('link' + this.id.substr(5));
		link.style.backgroundColor = '';
	}
}

function expanderA_onclick()
{
	document.all.expanderDIV.style.display = 'block';
		for(var i = 0; i < document.all.gallery.children.length; i++)
			if(i >= document.all.expanderA.gallery)
			document.all.gallery.children(i).style.display = 'block';
}

window.onload = function window_onload()
{
	var elements = document.getElementById('navigation').childNodes;
	for(var i = 0; i < elements.length; i++)
		if(elements[i].className == 'popup')
		{
			elements[i].onmouseout = popup_onmouseout;
			link = document.getElementById('link' + elements[i].id.substr(5))
			link.onmouseout = link_onmouseout;
			link.onmouseover = link_onmouseover;
		}

	if(document.all.expanderA)
	{
		document.all.expanderA.onclick = expanderA_onclick;
		for(var i = 0; i < document.all.gallery.children.length; i++)
			if(i >= document.all.expanderA.gallery)
				document.all.gallery.children(i).style.display = 'none';
	}

}
