var lastKeyPressed;
document.onkeydown = Taste;

function Taste(Ereignis)
	{
	if (window.event)
		{
		lastKeyPressed = window.event.keyCode;
		}
	else if (Ereignis.which)
		{
		lastKeyPressed = Ereignis.which;
		}
	if (lastKeyPressed == 13)
		{
	    document.getElementById("task").value = "";
		}
	}

function onEnter(task) 
    {
    if (lastKeyPressed == 13) dotask(task);
    }

function onEnter2(ref, task) 
    {
    if (lastKeyPressed == 13)
    	{
	    document.getElementById("ref").value = ref;
    	dotask(task);
    	}
    }

function show_mail(mail)
	{
	mail = mail.replace(/~/g, "@");
	mail = mail.replace(/ /g, "");
	document.write("<a class=email href='mailto:" + mail + "'>" + mail + "</a>");
	return;
	}

function enableUsername()
	{
	document.control.username.className = "login2";
	document.control.username.value = "";
	}

function enablePassword()
	{
	document.control.password.className = "login2";
	document.control.password.value = "";
	}

function page(id)
	{
    document.getElementById("page").value = id;
    document.getElementById("task").value = "";
    document.getElementById("control").submit();
	}

function dotask(task)
    {
    document.getElementById("task").value = task;
    document.getElementById("control").submit();
    }

function pagetask(id, task)
	{
    document.getElementById("page").value = id;
    document.getElementById("task").value = task;
    document.getElementById("control").submit();
	}

function cmd(id)
	{
    document.getElementById("command").value = id;
    document.getElementById("control").submit();
	}

function setref(id)
    {
    document.getElementById("ref").value = id;
    }

function setanchor(anchor)
	{
    document.getElementById("anchor").value = anchor;
	}

function swlang(lang)
	{
    document.getElementById("lang").value = lang;
    document.getElementById("control").submit();
	}

function viewred(id)
	{
	lang = document.forms.control.elements.lang.value;
	popup("usr/viewred.php?id=" + id + "&lang=" + lang, 100, 100, 640, 480, 1, 1);
	}

function popup(target, left, top, width, height, toolbars, sizeable)
	{
	sizeable_cmd = (sizeable == 1) ? "scrollbars=yes,resizable=yes" : "scrollbars=no,resizable=no";
	toolbars_cmd = (toolbars == 1) ? "toolbar=yes,menubar=yes" : "toolbar=no,menubar=no";
	pop = window.open(target, "popup" + Math.round(Math.random() * 20), "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + "," + sizeable_cmd + "," + toolbars_cmd);
	window.pop.focus();
	}

function mroll(id, mode)
	{
	if (document.getElementById)
		{
		if (document.getElementById("menu" + id))
			{
			className = document.getElementById("menu" + id).className;
			arr = className.split("_");
			document.getElementById("menu" + id).className = arr[0] + ((mode == 0) ? "_dark" : "_lite");
			}
		}
	}

function proll(id, mode)
	{
	return;
	if (document.getElementById)
		{
		if (document.getElementById("menu" + id))
			{
			imgSrc = document.getElementById("menu" + id).src;
			arr = imgSrc.split("~");
			if (arr[1] != mode + ".gif")
				{
				imgSrc = arr[0] + "~" + mode + ".gif";
				document.getElementById("menu" + id).src = imgSrc;
				}
			}
		}
	}


function setfocus(focusfeld)
	{
	if (focusfeld != "none")
		{
		if (document.forms[0].elements[focusfeld])
			{
			document.forms[0].elements[focusfeld].focus();
			if (!document.forms[0].elements[focusfeld].options) document.forms[0].elements[focusfeld].select();
			}
		else
			{
			if (document.forms[0].elements[0])
				{
				if (document.forms[0].elements[0].type != "hidden")
					{
					document.forms[0].elements[0].focus();
					if (document.forms[0].elements[0].type != "select-one") document.forms[0].elements[0].select();
					}
				}
			}
		}
	}


