﻿function InsertMailAddress(objectName)
{
	if(document.getElementById)
	{
		mp1 = "rku"; mp2 = "mai"; mp3 = "ma"; mp4 = "lto:"; mp5 = "s@m"; mp6 = "-sc"; mp7 = "et"; mp8 = "z.n"; mp9 = "hul";
		mp24 = mp2 + mp4; mp31 = mp3 + mp1; mp56 = mp5 + mp6; mp98 = mp9 + mp8;
		mc = document.getElementById(objectName);
		if (mc)
		{
			mc.innerHTML = '<a href="' + mp24 + mp31 + mp56 + mp98 + mp7 + '">' + mp31 + mp56 + mp98 + mp7 + '<\/a>';
		}
		
		mp1 = "ast"; mp2 = "mai"; mp3 = "webm"; mp4 = "lto:"; mp5 = "er@ab"; mp6 = "v-fr"; mp7 = "e"; mp8 = "urt.d"; mp9 = "ankf";
		mp24 = mp2 + mp4; mp31 = mp3 + mp1; mp56 = mp5 + mp6; mp98 = mp9 + mp8;
		mc = document.getElementById('webmasterMailCell');
		if (mc)
		{
			mc.innerHTML = '<a href="' + mp24 + mp31 + mp56 + mp98 + mp7 + '">' + mp31 + mp56 + mp98 + mp7 + '<\/a>';
		}
	}
}

function toggleMenu(id)
{
	menu = document.getElementById(id);
	
	if (menu.style.display == 'none')
	{
//		addOpenMenu(id);
		menu.style.display = '';
	}
	else
	{
//		deleteOpenMenu(id);
		menu.style.display = 'none';
	}

//	alert(readCookie('openMenus'));
}

function readCookie(n)
{
	a = document.cookie;
	
/*	alert('read cookie: ' + a);
	
	endIndex = a.search(';');
	if (endIndex >= 0)
	{
		a = a.substring(0, endIndex).trim();
	}

	alert('Read cookie: ' + a);*/
	
	res = '';
	while(a != '')
	{
		equalsIndex = a.search('=');
		
		if (equalsIndex >= 0)
	
		cookiename = a.substring(0,a.search('='));
		cookiewert = a.substring(a.search('=')+1,a.search(';'));
		if(cookiewert == '')
		{cookiewert = a.substring(a.search('=')+1,a.length);}

		if(n == cookiename){res = cookiewert;}

		i = a.search(';')+1;
		if(i == 0){i = a.length}
		a = a.substring(i,a.length);
	}
	return(res)
}

function addOpenMenu(menuId)
{
	openMenus = readCookie('openMenus');
	alert('[' + openMenus + ']');

	if (openMenus.length == 0)
	{
		document.cookie = 'openMenus=' + menuId;
	}
	else
	{
		document.cookie = 'openMenus=' + openMenus + ', ' + menuId;
	}
	
	alert('openMenus after add: |' + readCookie('openMenus') + "|");
}

function deleteOpenMenu(menuId)
{
	openMenusString = readCookie('openMenus');
	
	alert('openMenus before close: ' + openMenusString);
	
	openMenus = openMenusString.split(',');

	result = '';
	isFirstResult = true;
	
	for(i=0; i<openMenus.length; ++i)
	{
		if (openMenus[i] != menuId)
		{
			if (!isFirstResult)
			{
				result = result + ',';
				isFirstResult = false;
			}
			result = result + openMenus[i];
		}
	}
	
	document.cookie = 'openMenus=|' + result + "|";

	openMenusString = readCookie('openMenus');
	alert('openMenus after close: ' + openMenusString);
}

var menuItemHoverColor = '#7FFF7F';
var menuItemDefaultColor = '#FFFFFF';

function SetMenuItemHoverColor(elementID)
{
	document.getElementById(elementID).style.color = menuItemHoverColor;
}
function SetMenuItemDefaultColor(elementID)
{
	document.getElementById(elementID).style.color = menuItemDefaultColor;
}

function ShowElement(elementID)
{
	document.getElementById(elementID).style.visibility = 'visible';
}

function HideElement(elementID)
{
	document.getElementById(elementID).style.visibility = 'hidden';
}

