md = getById('menu');

menuh('Menü');
frm = newTag('form');
frm.name = 'menuform';
frm.style.textAlign = 'right';
fs = newTag('fieldset');
fs.appendChild(newText('Zeige '));
sel = newTag('select');
with (sel)
{id = 'filter'; size = '1'; onChange = 'loadscript(this.value)'; }
opt('GC-Cheats', 'cheats.js', true);
opt('> A-E', 'ae.js');
opt('> F-L', 'fl.js');
opt('> M-R', 'mr.js');
opt('> S-Z', 'sz.js');
opt('Sonstiges', 'sonst.js');

fs.appendChild(sel);
frm.appendChild(fs);
md.appendChild(frm);

newScript('', 'loader');

ul = newTag('ul');
with (ul)
{id = 'content'; className = 'menu';}
md.appendChild(ul);

loadscript('cheats.js');

function getById(id) {return document.getElementById(id);}
function newTag(tag) {return document.createElement(tag);}
function newText(text) {return document.createTextNode(text);}
function addLi(li)
{
getById('content').appendChild(li);
}

function newScript(src2, id2)
{
scr = newTag('script');
with (scr)
{id = id2; src = src2;}
md.appendChild(scr);
}

function hf(n, v)
{
inp = newTag('input');
with(inp)
{ type = 'hidden'; name = n; value = v;}
frm.appendChild(inp);
}

function l(name, url)
{
li = newTag('li'); li.className='item';
a = newTag('a'); a.href = url;
a.appendChild(newText(name));
li.appendChild(a);
addLi(li);
}

var lAZli = newTag('li');
function lAZ(A, Z, url, br)
{
 a = newTag('a');
 a.href = 'javascript:loadscript("'+url+'");';
 b1 = newTag('b'); b1.appendChild(newText(A));
 b2 = newTag('b'); b2.appendChild(newText(Z));
 a.appendChild(b1); a.appendChild(newText('-')); a.appendChild(b2);
 lAZli.appendChild(a);
 if (br) {lAZli.className='az'; addLi(lAZli); lAZli = newTag('li');}
 else {lAZli.appendChild(newText(' : '));}
}

function h(text)
{
li = newTag('li'); li.className='h';
img = newTag('img'); img.src='pics/cube.gif';
li.appendChild(img);
li.appendChild(newText(text));
addLi(li);
}

function clearMenu()
{
ul = getById('content');
while(ul.hasChildNodes()) {ul.removeChild(ul.firstChild);}
}

function opt(name, val, sl)
{
opti = newTag('option');
with (opti)
{value = val; text = name;}
if (sl == true) {opti.defaultSelected = true;}
try
 {
 sel.add(opti);
 }
catch (err)
 {
 sel.add(opti,null);
 }
}

function loadscript(url)
{
clearMenu();
li = newTag('li');
li.className = 'menu2';
li.appendChild(newText('Menü wird geladen...'));
addLi(li);
md.removeChild(getById('loader'));
newScript('menu/'+url, 'loader');
getById('filter').value = url;
}

checkfilter(getById('filter').value);
function checkfilter(lastval)
{
 if (getById('filter').value != lastval)
 {
  loadscript(getById('filter').value);
 }
 window.setTimeout('checkfilter("' + getById('filter').value + '")', 50);
}

function menuh(txt)
{
h2 = newTag('h2');
h2.appendChild(newText(txt));
md.appendChild(h2);
}

function extlinks()
{
As = document.getElementsByTagName("a");
for(i = 0; i < As.length; i++)
{
 if (As[i].rel == "external") {As[i].target = "_blank";}
}
}