<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "doctype/xhtml11.dtd">
<html>
<head>
<title>Magická koule</title>

<script type="text/javascript">
function objGet(x,doc)	{var d,o; d=(doc)?doc:document; o=d.getElementById?d.getElementById(x):d.all?d.all[x]:d.layers?d.layers[x]:null; if (o==null) {alert(x+" = null !");}; return o;}

var symbol_types = 'abcdefghijklmnopqrstuvwxyz'.split('');
var symbol, symbols;

function init()
{
var i,j,k, s,s2,l, arr, t,r;
symbol  = Math.floor(Math.random()*symbol_types.length);	//select main symbol
symbols = new Array();
arr     = new Array();
r       = new Array();
//remove main symbol
j = 0;
for (i=0;i<symbol_types.length;i++)
	{if (i!=symbol) {arr[j]=i;j++;}}
//table mix symbol
for (i=0;i<=99;i++,j++)
	{symbols[i] = arr[Math.floor(Math.random()*arr.length)];}
//table add main symbol
j = 0;
for (i=11;i<=99;i++)
	{
	k = Math.floor(i/10)
	j = i - (i-k*10+k);
	symbols[j] = symbol;
	}
//generate html
board  = "\n<table align=\"center\"><tr><td>";
board += "\n<p><b>Navod: <\/b><br>1. Mysli si dvouciferne cislo od 11-99.<br>2. Vypocitej cislo symbolu tak, ze od mysleneho cisla odectes soucet jeho cifer (XZ - (X+Y)).<br>3. Najdi symbol odpovidajici cislu v tabulce.<br>4. Klikni na magickou kouli...<\/p>";
board += "\n<p><b>Priklad vypoctu:<\/b> Myslim si cislo 59. Spocitam cislo symbolu 59 - (5+9) = 45 .<\/p>";

board += "\n<br><input type=text name=out size=\"60\">";
board += "\n<input type=\"button\" value=\" Magicka koule \" onclick=\"this.form.out.value='Symbol k tvemu myslenemu cislu je... *** "+symbol_types[symbol]+" ***'; this.style.visibility='hidden';\"\/>";
board += "\n<input type=\"submit\" value=\" Spustit znovu \"/>";
board += "\n<\/td><td>";
board += "\n<table><caption>Tabulka cisel a symbolu<\/caption>";
for (i=0;i<=99;i++)
	{r[i%20]='';}
for (i=0;i<=99;i++)
	{
	j = i%20;
	r[j]+="<td>"+i+"<\/td>";
	r[j]+="<td><b>"+symbol_types[symbols[i]]+"<\/b><\/td>";
	}
for (i=0;i<r.length;i++)
	{board+="\n<tr>"+r[i]+"<\/tr>";}
board += "\n<\/table>";
board += "\n<\/td><\/tr><\/table>";
objGet("board").innerHTML = board;
}
</script>
    
</head>


<body onload="init()">
<form action="js-magkoule.htm">
<div id="board"></div>
<p align="center">
</p>
</form>

<script type="text/javascript" src="view-source.js"></script>
</body>
</html>
