function UnCryptMailto( s )
{
	var n = 0;
	var r = "";
	for( var i = 0; i < s.length; i++)
	{
	    n = s.charCodeAt( i );
	    if( n >= 8364 )
	    {
	        n = 128;
	    }
	    r += String.fromCharCode( n - 1 );
	}
	return r;
}

function linkTo_UnCryptMailto( s )
{
	location.href=UnCryptMailto( s );
}


function highlightElement(id)
{
	for (var i = 0; i < id.length; i++)
	{
		elm = document.getElementById(id[i]);
		if (elm)
			elm.style.backgroundColor = "rgb(250, 240, 240)";
	}
}

function unhighlightElement(id)
{
	for (var i = 0; i < id.length; i++)
	{
		elm = document.getElementById(id[i]);
		if (elm)
			elm.style.backgroundColor = "";
	}
}

var activeId = null;
var timer = null;
var showId = null;

function showMenu(id)
{
	stopHide();
	elm = document.getElementById('sub_menu');
	for(var i = 0; i < elm.childNodes.length; i++)
		if (elm.childNodes[i].className == 'subMenu')
		{
			if (activeId === null && elm.childNodes[i].style.display == 'block')
				activeId = elm.childNodes[i].id;

			elm.childNodes[i].style.display = 'none';

			if (document.getElementById(elm.childNodes[i].id.substr(3)))
				document.getElementById(elm.childNodes[i].id.substr(3)).className = 'menu_unselected';

			if (elm.childNodes[i].id == 'submenu_' + id)
			{
				elm.childNodes[i].style.display = 'block';
				showId = elm.childNodes[i].id;

				document.getElementById('menu_' + id).className = 'menu_selected';
			}
		}
	if (activeId === null)
		activeId = -1;
}

function stopHide()
{
	if (timer != null)
	{
		clearTimeout(timer);
		timer = null;
	}

}

function hideMenu()
{
	if (showId && showId != activeId)
		timer = setTimeout('doHide("submenu_' + showId + '");', 600);
}

function doHide(id)
{
	timer = null;
	document.getElementById(showId).style.display = 'none';
	document.getElementById(showId.substr(3)).className = 'menu_unselected';

	if (activeId && activeId != -1)
	{
		document.getElementById(activeId).style.display = 'block';
		document.getElementById(activeId.substr(3)).className = 'menu_selected';
	}

	showId = null;
}
