		function kuketo(nomo)
		{
			var nomo_ = nomo + "=";
			var ka = document.cookie.split(';');
			var i;
			for(i=0;i < ka.length;i++) {
				var c = ka[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nomo_) == 0) return c.substring(nomo_.length,c.length);
			}
			return null;
		}
		function hazarden(lasta_numero)
		{
			var r = 1+Math.floor(Math.random()*lasta_numero);
			if (kuketo(r) != null)
				r = 1+Math.floor(Math.random()*lasta_numero);
			if (kuketo(r) != null)
				r = 1+Math.floor(Math.random()*lasta_numero);
			if (kuketo(r) != null)
				r = lasta_numero;
			document.location="/"+r;
			return false;
		}
		function ekrano(speco)
		{
			var winW = window.screen.availWidth, winH = window.screen.availHeight;
			if (document.body && document.body.offsetWidth) {
			 winW = document.body.offsetWidth;
			 winH = document.body.offsetHeight;
			}
			if (document.compatMode=='CSS1Compat' &&
			    document.documentElement &&
			    document.documentElement.offsetWidth ) {
			 winW = document.documentElement.offsetWidth;
			 winH = document.documentElement.offsetHeight;
			}
			if (window.innerWidth && window.innerHeight) {
			 winW = window.innerWidth;
			 winH = window.innerHeight;
			}
			document.location.search="?ekrano="+winW+speco+winH;
		}

		var dissolvilo = null;
		function montru(o) {clearTimeout(dissolvilo);document.getElementById('ejo2').style.opacity=o;try {document.getElementById('ejo4').style.opacity=o;document.getElementById("ejo4").style.zIndex=100} catch(e) {}}
		function kasxu() {document.getElementById('ejo2').style.opacity=0.5;try {document.getElementById('ejo4').style.opacity=0;document.getElementById("ejo4").style.zIndex=-100;} catch(e) {}}
		function dissolvu() 
		{
			try {
			if (document.getElementById("ejo2").style.opacity>0.5)
			{
				document.getElementById("ejo2").style.opacity = document.getElementById("ejo2").style.opacity - 0.02;
				if (document.getElementById("ejo4").style.opacity > 0.15)
				{
					document.getElementById("ejo4").style.opacity = document.getElementById("ejo4").style.opacity - 0.05;
				}
				else
				{
					document.getElementById("ejo4").style.opacity = 0;
					document.getElementById("ejo4").style.zIndex = -100;
				}
				// http://stackoverflow.com/questions/3015319/jquery-javascript-settimeout-cleartimeout
			}
			} catch(e) {
			}
			dissolvilo = setTimeout(dissolvu, 100);
		} 
try {
		if (gAparato==="max" || gAparato==="handheld")
		{
			// ne dissolvu
		}
		else if (document.location.pathname==="/")
		{
			dissolvilo=setTimeout("dissolvu()", 300);
		}
		else
		{
			dissolvilo=setTimeout("dissolvu()", 2000);
		}
	} catch(e) {
			dissolvilo=setTimeout("dissolvu()", 2000);
}



Date.prototype.kiuTempo = function()
{
	var tempo = ((this.getUTCHours())%24) + this.getUTCMinutes()/60 + this.getUTCSeconds()/3600
	tempo = Math.floor(tempo*1000/24)
	tempo =  String((10>tempo?"00"+tempo:100>tempo?"0"+tempo:tempo))
	tempo += " (" + this.getUTCHours() + ":"
	tempo += ((this.getUTCMinutes()<10)?"0"+this.getUTCMinutes():this.getUTCMinutes())
	tempo +=  " UTC)"
	return tempo
} 
Date.prototype.kiuDato = function()
{
	var jaro = this.getUTCFullYear()
	var monato = this.getUTCMonth() + 1
	var tago = this.getUTCDate()
	var dato = jaro + "-" + ((10>monato) ? "0" : "") + monato
	dato += "-" + ((10>tago) ? "0" : "") + tago
	return dato
}
function metrikaUTC()
{
	try {
	var nun = new Date();
	document.getElementById("utc").innerHTML = /* "DLTM\\u0134VS".charAt(nun.getUTCDay()) + "&nbsp;" + */ nun.kiuDato() + "," + nun.kiuTempo();
	nunilo = setTimeout(metrikaUTC,1000);
	} catch (e) {}
}
var nunilo = setTimeout(metrikaUTC,500)





// Supren Infren Liven Dekstren Enigu
var gFlava="3";
var gAntaua="hazarda";
var gSekva="hazarda";
var gNuna="hazarda";
function pretiguElektilon()
{
	var gXpath = document.evaluate( '//a[not(@tabindex="-1")]|//input[not(@tabindex="-1")]|//button[not(@tabindex="-1")]|//select[not(@tabindex="-1")]|//textarea[not(@tabindex="-1")]' ,document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
	if (gXpath != null) { var elemento = gXpath.iterateNext(); while(elemento) { gElementoj.push(elemento); elemento = gXpath.iterateNext(); } }
}
function elektu(aKiu, aKiel)
{
	if (aKiu >= 0 && aKiu < gElementoj.length)
	{
		if (aKiel == 0 && gElementoj[gElektita].type!="radio")
		{
			gElementoj[aKiu].blur();
		}
		if (gElementoj[gElektita].type=="checkbox"||gElementoj[gElektita].type=="radio")
		{
			var id=gElementoj[gElektita].getAttribute("id");
			if (id)
			{
				var etikedo = document.evaluate( '//label[@for="'+id+'"]' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
				etikedo.style.border=(aKiel?gFlava+'px solid yellow':gFlava+'px solid transparent');
			}
		}
		else if (gElementoj[gElektita].type=="select-one" || gElementoj[gElektita].type=="select-multiple")
		{
			gElementoj[aKiu].style.border=(aKiel?gFlava+'px solid yellow':'0px solid transparent');
			gElementoj[aKiu].style.fontSize=(aKiel?"30px":"medium");
		}		
		else
		{
			gElementoj[aKiu].style.border=(aKiel?gFlava+'px solid yellow':gFlava+'px solid transparent');
		}
		if (aKiel == 0)
		{
			gFlavujo.style.display='none';
			kasxu();
		}
		else if (gElementoj[aKiu].hasAttribute("title"))
		{
			gElementoj[aKiu].parentNode.appendChild(gFlavujo);
			gFlavujo.firstChild.nodeValue=gElementoj[aKiu].getAttribute("title");
			gFlavujo.style.display='block';
			montru(0.9);
		}
		if (aKiel == 1 && gElementoj[gElektita].type!="radio")
		{
			gElementoj[aKiu].focus();
		}
	}
}
var gElementoj = new Array;
var gElektita = -1;
var gFlavujo=document.createElement('div');
gFlavujo.style.fontSize='28px';
gFlavujo.style.cssFloat='relative';
gFlavujo.style.background='yellow';
gFlavujo.style.color='black';
gFlavujo.style.fontWeight='bold';
gFlavujo.style.zIndex=100;
gFlavujo.appendChild(document.createTextNode(""));
var gUnuaLitero=125;
var gTajpaRapideco=650;
var gLitero=gUnuaLitero;
var gAlfabeto="\u2421žżźŷÿýŵųűůũūŭüûúùțŧťţþșšşśŝßřŗŕœőōøöõôóòŋŉňņńñłŀľļĺĸķĵĳiįīĩïîíìıħĥģġğĝěęėēëêéèđďðčċćĉçąăāæåäãâáà-'zyxwvutsrqponmlkjihgfedcba  .,ABCDEFGHIJKLMNOPQRSTUVWXYZ!?/\"0123456789()[]{}<>+:;@=*#$%^&_\\|~`ªºÀÁÂÃÄÅÆĀĂĄÇĈĆĊČÐĎĐÈÉÊËĒĖĘĚĜĞĠĢĤĦİÌÍÎÏĨĪĮIĲĴĶĸĹĻĽĿŁÑŃŅŇʼNŊÒÓÔÕÖØŌŐŒŔŖŘSSŜŚŞŠȘÞŢŤŦȚÙÚÛÜŬŪŨŮŰŲŴÝŸŶŹŻŽµ";
var gTajpu=null;
window.onload = function() {
	pretiguElektilon();
	try{document.getElementById("trovota").focus();}catch(e){}
	document.onkeydown=function(e) {
		if (!e) e=window.event;
		switch(e.keyCode) {

			case 38: // supren
			case 40: // infren
				if (gElektita == -1)
				{
					if (location.pathname != "/bonvenon" && location.pathname != "/televido" && location.pathname != "/radio" && location.pathname != "/trovi")
					{
						if (e.keyCode == 38) {try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/televido';}
						else if (e.keyCode == 40) {try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/hazarda';}
					}
				}
				else if (gElementoj[gElektita].nodeName=="TEXTAREA" || (gElementoj[gElektita].nodeName=="INPUT" && (gElementoj[gElektita].type=="text"||gElementoj[gElektita].type=="password")))
				{
					gElementoj[gElektita].autocomplete='off'; // ne funkcias?
					gLitero+=(e.keyCode==38?+1:-1);
					if (gLitero < 0) {gLitero = 0;}
					else if (gLitero >= gAlfabeto.length) {gLitero = gAlfabeto.length-1;}
					var litero = gAlfabeto[gLitero];
					if (gTajpu==null) {gElementoj[gElektita].value+=litero;}
					else {gElementoj[gElektita].value=gElementoj[gElektita].value.replace(/.$/, litero)}
					clearTimeout(gTajpu);
					gTajpu=setTimeout(function(){gElementoj[gElektita].value=gElementoj[gElektita].value.replace(/.\u2421$/, '');gLitero=gUnuaLitero;clearTimeout(gTajpu);gTajpu=null;}, gTajpaRapideco);
				}
				else if (gElementoj[gElektita].nodeName=="INPUT" && (gElementoj[gElektita].type=="checkbox"||gElementoj[gElektita].type=="radio"))
				{
					gElementoj[gElektita].checked=(e.keyCode==38?true:false);
				}
				break;

			case 37: // liven
				//document.getElementById('menuo_select').selectedIndex=0;; // pro problemeto en Chrome/Safari
				elektu(gElektita, 0);
				if (gElektita == 0)
				{
					gElektita = -1;
					try {
					document.getElementById('ejo4').style.opacity=0;
					document.getElementById("ejo4").style.zIndex=-100;
					} catch (e) {}
					document.getElementById('dewbutonoj').style.display="none";
				}
				else if (gElektita > 0)
				{
					gElektita--;
					elektu(gElektita, 1);
					try {
					document.getElementById('ejo4').style.opacity=1;
					document.getElementById("ejo4").style.zIndex=100;
					} catch (e) {}
					document.getElementById('dewbutonoj').style.display="block";
				}
				break;

			case 39: // dekstren
				//document.getElementById('menuo_select').selectedIndex=0; // pro problemeto en Chrome/Safari
				if (gElektita < gElementoj.length-1)
				{
					elektu(gElektita, 0);
					gElektita++;
					elektu(gElektita, 1);
					try {
					document.getElementById('ejo4').style.opacity=1;
					document.getElementById("ejo4").style.zIndex=100;
					} catch (e) {}
					document.getElementById('dewbutonoj').style.display="block";
				}
				break;

			case 13: // elektu
				break;

			case 179: // ludu/pawzu
				try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/hazarda';
				break;

			case 178: // haltu
				try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/televido';
				break;

			// case 227: // antauen (denove)
			//	try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; window.location.reload();
			//	break;

			case 177: // antauen
				if (gAntaua!=undefined) {try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/'+gAntaua;}
				break;

			case 176: // sekven
			// case 228: // sekven
				if (gSekva!=undefined) {try{document.getElementById('ejo3').style.opacity=0.3}catch(e){}; document.location='/'+gSekva;}
				break;

		}
	}
}

