var submenuElementShown = null;
var globalTimer = null;
var scrElementMenu = null;


function showSubmenu(ev)
{
	srcElement = getSrcElement(ev);
	srcElementId = srcElement.id;
	
	srcElementMenu = srcElement;
	
	submenuContent = '';

	if (submenuElementShown)
	{
		if (srcElementId != submenuElementShown.id)
		{
			_hideSubmenu();
			stopTimer();
			submenuElementShown = null;
		}
	}
	
	if (!submenuElementShown)
	{
		if (srcElementId == 'menu-profil')
		{
			submenuContent ='<a href="./../p/profil-fa-udaje.php">fakturační údaje</a>';
			submenuContent += '<a href="./../p/profil-nastaveni-uctu.php">nastavení účtu</a>';
			submenuContent += '<a href="./../p/profil-zmenit-heslo.php">změnit heslo</a>';
			//submenuContent += '<a href="#">statistika</a>';
			//submenuContent += '<a href="#">historie akcí</a>';
		}
		else if (srcElementId == 'menu-domeny')
		{
			submenuContent ='<a href="./../p/domeny-spravce.php">správce domén</a>';
			submenuContent += '<a href="./../p/domeny-expirator.php">expirátor</a>';
			submenuContent += '<a href="./../p/domeny-whois.php">whois</a>';
		}
		else if (srcElementId == 'menu-platby')
		{
			submenuContent ='<a href="./../p/platby-stav.php">stav kreditu</a>';
			submenuContent += '<a href="./../p/platby-prehled-plateb.php">přehled plateb</a>';
			submenuContent += '<a href="./../p/platby-prehled-blokovane.php">platby blokované/nedokončené</a>';
			//submenuContent += '<a href="#">vyúčtování</a>';
		}
		else if (srcElementId == 'menu-tickety')
		{
			submenuContent ='<a href="./../p/tickety-spravce.php">správce ticketů</a>';
			submenuContent += '<a href="./../p/tickety-probihajici.php">probíhající tickety</a>';
			submenuContent += '<a href="./../p/tickety-selhane.php">selhané tickety</a>';
			submenuContent += '<a href="./../p/tickety-info.php">info o ticketu</a>';
		}
		else if (srcElementId == 'menu-registrace')
		{
			submenuContent ='<a href="./../p/formulare-registrace.php">registrace domény</a>';
			submenuContent +='<a href="./../p/formulare-registrace-kontaktu-cz.php">registrace kontaktu cz</a>';
			submenuContent +='<a href="./../p/formulare-registrace-nsset.php">registrace nsset cz</a>';
		}
		else if (srcElementId == 'menu-zmeny')
		{
			
			submenuContent = '<a href="./../p/formulare-zmeny-all.php">všechny údaje</a>';
			submenuContent += '<a href="./../p/formulare-zmeny-vlastnik.php">vlastník domény</a>';
			submenuContent += '<a href="./../p/formulare-zmeny-admin.php">administrační kontakt</a>';
			submenuContent += '<a href="./../p/formulare-zmeny-tech-dns.php">technický správce a DNS</a>';
			submenuContent += '<a href="./../p/formulare-zmeny-billing.php">fakturace</a>';
			//submenuContent += '<a href="./../p/formulare-zmeny-tech-dns.php">změna DNS</a>';
			submenuContent += '<a href="./../p/formulare-prevod-registratora.php">převod od jiného registrátora</a>';
			submenuContent += '<a href="./../p/formulare-zmenit-heslo.php">změnit autorizační heslo</a>';
			submenuContent += '<a href="./../p/formulare-zaslat-heslo.php">zaslat autorizační heslo</a>';
			
			submenuContent += '<a href="./../p/formulare-registrace-kontaktu-cz.php?modify=true">změna kontaktu cz</a>';
			submenuContent += '<a href="./../p/formulare-registrace-nsset.php?modify=true">změna nssetu cz</a>';
			
		}
		else if (srcElementId == 'menu-informace')
		{
			submenuContent ='<a href="./../p/info-whois.php">info o doméně</a>';
			submenuContent +='<a href="./../p/info-kontakt-cz.php">info o kontaktu cz</a>';
			submenuContent +='<a href="./../p/info-nsset-cz.php">info o nssetu cz</a>';
			submenuContent += '<a href="./../p/info-ticket.php">info o ticketu</a>';
			submenuContent += '<a href="./../p/info-ceny.php">info o cenách</a>';
		}
		else if (srcElementId == 'menu-napoveda')
		{
			//submenuContent ='<a href="./../p/napoveda-aplikace.php">o aplikaci</a>';
			submenuContent += '<a href="./../p/napoveda-domeny.php">o doménách</a>';
		}
		
			submenuElementShown = $('submenu');
			submenuElementShown.innerHTML = submenuContent;
			submenuElementShown.style.display = 'block';
			submenuElementShown.style.left = srcElement.offsetLeft + 'px';
			submenuElementShown.style.top = ($('menu').offsetTop + $('menu').offsetHeight) + 'px';
			if (srcElementId == 'menu-napoveda')
			{
				submenuElementShown.style.width = '132px';
			}
			else
			{
				submenuElementShown.style.width = '152px';
			}
	}
	else
	{
		if (globalTimer)
		{
			stopTimer(globalTimer);
		}
	}
}


function stopTimer()
{
	if (globalTimer)
	{
		clearTimeout(globalTimer);
		globalTimer = null;
	}
}


function hideSubmenu()
{
	globalTimer = setTimeout("_hideSubmenu();", 500); 
}

function _hideSubmenu()
{
	if (submenuElementShown)
	{
		submenuElementShown.style.display = 'none';
		submenuElementShown = null;
		$('submenu').innerHTML = '';
	}
}

function Some()
{
	ev           = ev || window.event;
	
	if (dragObject)
	{
		mouseUpPosition = mouseCoords(ev);
		mouseMove = getMouseMoveCoords();
		
		if (dragObject.id == 'rbcMailFoldersDivider')
		{
			dragObject.style.left = (dragObjectInitialPosition.x + mouseMove.x) + 'px';
		}
		
		if (dragObject.id == 'rbcMailListDetailHorizDivider')
		{
			dragObject.style.top = (dragObjectInitialPosition.y + mouseMove.y) + 'px';
			dragObject.style.zIndex = 50;	
		}
	}
}
	
function getSrcElement(ev)
{
	if (window.event)
	{
		var evSrcElement = window.event.srcElement;
	}
	else
	{
		var evSrcElement = ev.originalTarget ;
	}
	
	return evSrcElement;
}

function setSameAsOwner(ev,targetElPrefix)
{
	elementSrc = getSrcElement(ev);
	
	isChecked = elementSrc.checked;
	
	tagDic = $('ownerDic');
	tagIdentifyType = $('ownerIdentifyType');
	tagIdentify = $('ownerIdentify');
	tagNotifyEmail = $('ownerNotifyEmail');
	
	if (isChecked)
	{
		$(targetElPrefix + 'Firstname').value = $('ownerFirstname').value;
		$(targetElPrefix + 'Surname').value = $('ownerSurname').value;
		$(targetElPrefix + 'CompanyName').value = $('ownerCompanyName').value;
		$(targetElPrefix + 'City').value = $('ownerCity').value;
		$(targetElPrefix + 'Street').value = $('ownerStreet').value;
		$(targetElPrefix + 'ZIP').value = $('ownerZIP').value;
		$(targetElPrefix + 'Phone').value = $('ownerPhone').value;
		$(targetElPrefix + 'Email').value = $('ownerEmail').value;
		$(targetElPrefix + 'Fax').value = $('ownerFax').value;
		$(targetElPrefix + 'Country').selectedIndex = $('ownerCountry').selectedIndex;
		
		if (tagDic) $(targetElPrefix + 'Dic').value = $('ownerDic').value;
		if (tagIdentifyType) $(targetElPrefix + 'IdentifyType').selectedIndex = $('ownerIdentifyType').selectedIndex;
		if (tagIdentify) $(targetElPrefix + 'Identify').value = $('ownerIdentify').value;
		if (tagNotifyEmail) $(targetElPrefix + 'NotifyEmail').value = $('ownerNotifyEmail').value;
	}
	else
	{
		$(targetElPrefix + 'Firstname').value = '';
		$(targetElPrefix + 'Surname').value = '';
		$(targetElPrefix + 'CompanyName').value = '';
		$(targetElPrefix + 'Street').value = '';
		$(targetElPrefix + 'City').value = '';
		$(targetElPrefix + 'ZIP').value = '';
		$(targetElPrefix + 'Phone').value = '';
		$(targetElPrefix + 'Email').value = '';
		$(targetElPrefix + 'Fax').value = '';
		$(targetElPrefix + 'Country').selectedIndex = 0;
		if (tagDic) $(targetElPrefix + 'Dic').value = '';
		if (tagIdentifyType) $(targetElPrefix + 'IdentifyType').selectedIndex = 0;
		if (tagIdentify) $(targetElPrefix + 'Identify').value = '';
		if (tagNotifyEmail) $(targetElPrefix + 'NotifyEmail').value = '';
	}
	
}

function manageTag(ev,tagId)
{
	elementSrc = getSrcElement(ev);
	
	isChecked = elementSrc.checked;
	
	if (isChecked)
	{
		if (elementSrc.value == 1)
		{
			$(tagId).style.display = 'none';
		}
		else if (elementSrc.value == 2)
		{
			$(tagId).style.display = 'block';
		}
	}
}

function manageCheck(ev,tagId)
{
	elementSrc = getSrcElement(ev);
	
	isChecked = elementSrc.checked;
	
	if (isChecked)
	{
		$(tagId).style.display = 'block';
	}
	else
	{
		$(tagId).style.display = 'none';
	}
}


function managePlatebniPodminky()
{
	if ($('selectPlatebniKontakt').value == 'other')
	{
		$('tablePlatebniKontakt').style.display = "block";
	}
	else
	{
		$('tablePlatebniKontakt').style.display = "none";
	}
}
