var URL;
var HOTCODE="###";
var ANZ=0,FIRST=true,L="";
var IE=new Array(0);

window.start=commandline();

function commandline() {
	var s=window.location.href,a=s.indexOf('?');
	URL=s;
	if(a>=0) {
		URL=s.substring(0,a);
		s=s.substring(a+1);
		a=s.indexOf("#");
		if(a>=0) s=s.substring(0,a);
		L=s;
		FIRST=false;
	}
}

function next(n) {
	if(document.all) { ienext(n); return; }
	FIRST=false;
	var s=L.charAt(n);
	if((s=="o")||(s=="O")) L=L.substring(0,n)+"X"+L.substring(n+1);
	else if((s=="x")||(s=="X")) L=L.substring(0,n)+"O"+L.substring(n+1);
	ANZ=0;
	window.location=URL+"?"+L+"#x";
}

/*---------       IE  ---------------*/

function ienext(n) {
	var ihtml,id;
	if(IE[n].status) ihtml=IE[n].text1;
	else ihtml=IE[n].text2;
	id=eval("document.all.DD"+n);
	id.innerHTML=ihtml;
	IE[n].status=!IE[n].status;
}

function iemerker(t1,t2,anz) {
	this.text1=t1;
	this.text2=t2;
	this.status=false;
	return this;
}

function ietextw(text1,text2) {
	var out;
 	text1=md(text1,ANZ,false);
	text2=md(text2,ANZ,false);
	out="<div id='DD"+ANZ+"'>"+text1+"</div>";
	IE.length++;
	IE[ANZ]=new iemerker(text1,text2,ANZ);
	ANZ++;
	document.write(out);
}
/*---------    Ende  IE  ---------------*/

function md(t,index,aktiv) {
	var a=t.indexOf(HOTCODE),l=HOTCODE.length;
	while((a=t.indexOf(HOTCODE))>=0) {
		t=t.substring(0,a)+"next("+index+") "+t.substring(a+l);
		}
	if(aktiv) t="<a name='x'></a>"+t;
	return t;
}

function textw(text1,text2) {
	if(document.all) return ietextw(text1,text2);
	var n,out;
	if(FIRST) L+="o";
	n=L.charAt(ANZ);
	if(n=="o") out=md(text1,ANZ,false);
	else if(n=="O") {
		L=L.substring(0,ANZ)+"o"+L.substring(ANZ+1);
		out=md(text1,ANZ,true);
		}
	if(n=="x") out=md(text2,ANZ,false);
	else if(n=="X") {
		L=L.substring(0,ANZ)+"x"+L.substring(ANZ+1);
		out=md(text2,ANZ,true);
		}
	ANZ++;
	document.write(out);;
}

function textw_new(){
	L="";
	window.location=URL;
}


