
var m0 = new Array(1)

m0[0] = new Array(52,36,10,26,57,42,12,20,62,45,11,19,54,46,6,21,61,54,5,12,60,62,127,61,1,18,51,35,26,35,45,35,4,6,71,5,35,41,0,1,58,44,9,17,53,37,2,9,48,40,5,4,55,47,21,11,61,53,8,16,53,51,3,10,36,28,19,27,59,52,18,24,41,24,17,24,52,53,9,0,44,35,4,2,56,59,12,26,42,32,26,35,53,35,0,18,49,41,18,32,35,32,10,26,62,55,11,17,41,33,24,33,40,33,17,32,33,26,32,26,54,61,16,24,50,34,26,41,51,49,27,35,49,48,1,33,47,39,14,22,39,31,24,32,31,23,6,5,61,43,41,26,43,61,2,3,48,51,32,40,51,48,33,49,59,51,49,51,48,51,35,43,55,54,26,41,51,48,43,51,61,52,41,58);
m0[0].base = new Array(0,1,2,3,4,5,6,7,8,9,10,10,11,12,13,14,15,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,0);
m0[0].root =0;
m0[0].move =0;
var n0 = new Array();
var b0 = -1;
var pieces = "KQNBR ";
function g0(a,b)
{	gm(m0,n0,0,b0,'round5g0.htm',a,b);}
function MB50()
{b0=MB5(m0,n0,0,b0,'round5g0.htm'); GMS(m0,n0,0,b0,'round5g0.htm');}
function MB0()
{b0=MB(m0,n0,0,b0,'round5g0.htm'); GMS(m0,n0,0,b0,'round5g0.htm');}
function MF50()
{b0=MF5(m0,n0,0,b0,'round5g0.htm'); GMS(m0,n0,0,b0,'round5g0.htm');}
function MF0()
{b0=MF(m0,n0,0,b0,'round5g0.htm',true); iround50.value=GMS(m0,n0,0,b0,'round5g0.htm');}

var m1 = new Array(1)

m1[0] = new Array(50,34,6,21,57,42,12,20,62,45,5,33,59,50,4,6,71,5,48,40,33,42,50,42,9,17,49,33,11,19,52,44,2,9,58,49,1,11,61,52,10,26,60,62,127,61,3,12,51,43,20,28,56,57,0,2,49,56,5,4,45,51,11,5,61,60,5,22,51,61,19,27,34,27,21,27,42,51,26,33,40,33,12,30,61,46,22,39,52,61,30,22,57,58,2,3,58,34,39,29,46,29,22,29,44,36,29,37,51,49,27,21,34,10,9,16,54,46,37,23,33,25,16,2,10,8,2,47,61,52,21,11,8,10,11,26,10,18,23,30,49,50,4,20,18,20,26,20,50,58,20,37,58,44,37,52,44,52,47,11,52,49,11,47,49,28,30,28,56,28,3,43);
m1[0].base = new Array(0,1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,15,16,17,18,19,20,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,0);
m1[0].root =0;
m1[0].move =0;
var n1 = new Array();
var b1 = -1;
var pieces = "KQNBR ";
function g1(a,b)
{	gm(m1,n1,1,b1,'round5g1.htm',a,b);}
function MB51()
{b1=MB5(m1,n1,1,b1,'round5g1.htm'); GMS(m1,n1,1,b1,'round5g1.htm');}
function MB1()
{b1=MB(m1,n1,1,b1,'round5g1.htm'); GMS(m1,n1,1,b1,'round5g1.htm');}
function MF51()
{b1=MF5(m1,n1,1,b1,'round5g1.htm'); GMS(m1,n1,1,b1,'round5g1.htm');}
function MF1()
{b1=MF(m1,n1,1,b1,'round5g1.htm',true); iround51.value=GMS(m1,n1,1,b1,'round5g1.htm');}

var m2 = new Array(1)

m2[0] = new Array(62,45,6,21,50,34,9,17,54,46,2,9,61,54,14,22,60,62,127,61,5,14,57,42,4,6,71,5,51,35,21,36,42,36,9,36,58,44,11,27,59,58,10,18,61,59,1,11,44,23,0,2,23,14,6,14);
m2[0].base = new Array(0,1,2,3,4,5,6,7,8,8,9,10,11,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0);
m2[0].root =0;
m2[0].move =0;
var n2 = new Array();
var b2 = -1;
var pieces = "KQNBR ";
function g2(a,b)
{	gm(m2,n2,2,b2,'round5g2.htm',a,b);}
function MB52()
{b2=MB5(m2,n2,2,b2,'round5g2.htm'); GMS(m2,n2,2,b2,'round5g2.htm');}
function MB2()
{b2=MB(m2,n2,2,b2,'round5g2.htm'); GMS(m2,n2,2,b2,'round5g2.htm');}
function MF52()
{b2=MF5(m2,n2,2,b2,'round5g2.htm'); GMS(m2,n2,2,b2,'round5g2.htm');}
function MF2()
{b2=MF(m2,n2,2,b2,'round5g2.htm',true); iround52.value=GMS(m2,n2,2,b2,'round5g2.htm');}

var m3 = new Array(1)

m3[0] = new Array(52,36,12,20,51,35,11,27,57,42,27,36,42,36,2,11,62,45,11,18,36,30,5,19,61,34,15,23,30,20,13,20,34,20,3,21,35,27,18,11,45,35,21,28,58,44,6,21,59,43,21,27,43,22,4,3,60,58,120,59,27,44,53,44,11,4,20,13,4,13,22,13,1,18,35,29,3,2,63,61,7,3,29,14,19,40,13,41,28,14,41,40,8,24,40,41,0,16,41,20,2,1,54,38,24,32,59,3,18,3,20,4,14,30,48,40,16,19,58,57,30,38,44,36,38,52,61,58,19,35,36,28,9,17,4,7,1,9,7,23,52,28,55,39,3,13,23,22,13,19,39,31,19,34,22,54,9,8,54,18,35,39,18,32,8,9,32,33,28,31,49,41,10,26,33,60,34,40,57,49,40,25,60,12,25,10,58,62,39,35,62,14,31,55,14,15,55,19,12,13,35,37,13,6,19,28,49,48,37,53,6,22,28,29,22,29,53,29,50,34,29,53,48,40,17,25,34,25,9,17,15,23,17,24);
m3[0].base = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,0);
m3[0].root =0;
m3[0].move =0;
var n3 = new Array();
var b3 = -1;
var pieces = "KQNBR ";
function g3(a,b)
{	gm(m3,n3,3,b3,'round5g3.htm',a,b);}
function MB53()
{b3=MB5(m3,n3,3,b3,'round5g3.htm'); GMS(m3,n3,3,b3,'round5g3.htm');}
function MB3()
{b3=MB(m3,n3,3,b3,'round5g3.htm'); GMS(m3,n3,3,b3,'round5g3.htm');}
function MF53()
{b3=MF5(m3,n3,3,b3,'round5g3.htm'); GMS(m3,n3,3,b3,'round5g3.htm');}
function MF3()
{b3=MF(m3,n3,3,b3,'round5g3.htm',true); iround53.value=GMS(m3,n3,3,b3,'round5g3.htm');}

var m4 = new Array(1)

m4[0] = new Array(62,45,6,21,50,34,10,18,51,35,11,27,59,50,27,34,50,34,2,29,54,46,12,20,61,54,1,11,57,42,5,12,60,62,127,61,4,6,71,5,45,39,11,17,34,41,3,35,39,29,20,29,61,59,35,28,48,32,28,20,41,50,5,3,58,30,17,34,52,36,34,19,36,28,20,28,59,60,19,36,54,36,21,36,42,36,29,36,30,12,28,12,60,36,12,11,56,60,3,4,32,24,14,22,50,26);
m4[0].base = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,16,17,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,0);
m4[0].root =0;
m4[0].move =0;
var n4 = new Array();
var b4 = -1;
var pieces = "KQNBR ";
function g4(a,b)
{	gm(m4,n4,4,b4,'round5g4.htm',a,b);}
function MB54()
{b4=MB5(m4,n4,4,b4,'round5g4.htm'); GMS(m4,n4,4,b4,'round5g4.htm');}
function MB4()
{b4=MB(m4,n4,4,b4,'round5g4.htm'); GMS(m4,n4,4,b4,'round5g4.htm');}
function MF54()
{b4=MF5(m4,n4,4,b4,'round5g4.htm'); GMS(m4,n4,4,b4,'round5g4.htm');}
function MF4()
{b4=MF(m4,n4,4,b4,'round5g4.htm',true); iround54.value=GMS(m4,n4,4,b4,'round5g4.htm');}
var nMoves = new Array(0,0,0,0,0);
var nLevels = new Array(0,0,0,0,0);
var nNameCount = new Array(0,0,0,0,0);
var nOld = new Array(-1,-1,-1,-1,-1);
baseName = 'round5';
var EmptyWhitePath = "gif/w.gif";
var EmptyBlackPath = "gif/b.gif";
// Copyright 98,99 by ChessBase GmbH, Germany
function Init( path )
{ gifs = new Array(6);
	for ( var i=0; i< 26; i++)
		gifs[i]= new Image();
	gifs[0].src = path + "b.gif";
	gifs[1].src = path + "bbb.gif";
	gifs[2].src = path + "bbw.gif";
	gifs[3].src = path + "bkb.gif";
	gifs[4].src = path + "bkw.gif";
	gifs[5].src = path + "bqb.gif";
	gifs[6].src = path + "bqw.gif";
	gifs[7].src = path + "brb.gif";
	gifs[8].src = path + "brw.gif";
	gifs[9].src = path + "bnb.gif";
	gifs[10].src = path + "bnw.gif";
	gifs[11].src = path + "wbb.gif";
	gifs[12].src = path + "wbw.gif";
	gifs[13].src = path + "wrb.gif";
	gifs[14].src = path + "wrw.gif";
	gifs[15].src = path + "wqb.gif";
	gifs[16].src = path + "wqw.gif";
	gifs[17].src = path + "wkb.gif";
	gifs[18].src = path + "wkw.gif";
	gifs[19].src = path + "wnb.gif";
	gifs[20].src = path + "wnw.gif";
	gifs[21].src = path + "wpb.gif";
	gifs[22].src = path + "wpw.gif";
	gifs[23].src = path + "bpb.gif";
	gifs[24].src = path + "wpb.gif";
	gifs[25].src = path + "b.gif";
}
function SyncPicture( base, basename )
{	if ( base > -1 ) return base;
	for ( i=0; i < document.images.length; i++ )
	{	if ( document.images[i].name != "" )
			if ( document.images[i].name == basename )
				return i;
			else if ( document.images[i].name.substring(0,3) == basename.substring(0,3) )
				i+= 63;
	}
	return -1;
}
function MF5( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	for ( i=0; nMoves[nm] < moves[nLevels[nm]].length / 2 && i < 10; i++ )
		MF( moves, names, nm, base, false );
	return base;
}
function MB5( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	for ( i=0; ( nMoves[nm] > 0 || nLevels[nm] > 0 ) && i < 10; i++ )
		MB( moves, names, nm, base );
	return base;
}
function GoStart( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	while ( nMoves[nm] > 0 || nLevels[nm] > 0 )
		MB( moves, names, nm, base );
	return base;
}
function GoEnd( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	while ( nMoves[nm] < moves[nLevels[nm]].length / 2 )
		MF( moves, names, nm, base, false );
	return base;
}
function MF( moves, names, nm, base, basename, bCheckV )
{	base = SyncPicture( base, basename );
	if ( bCheckV )
	{	var b = false;
		for ( i=0; i < moves.length; i++ )
			if ( i != nLevels[nm] && moves[i].root == nLevels[nm] && moves[i].move == nMoves[nm] )
				b = true;
		if ( b )
		{	var vf = window.open('', 'Frank', 'status=no,scrollbars=no,menubar=no,toolbar=no,width=240,height=160')
			with ( vf.document )
			{	open();
				write('<HTML><HEAD><TITLE>Varianten</TITLE></HEAD><BODY><DIV ID="disp"></DIV><LAYER id="NS"></LAYER></BODY></HTML>')
				close()
			}
			vf.erzeuger = self;
			var ihtml="<a href=\"javascript:erzeuger.MF(erzeuger.m" + nm +
						 ",erzeuger.n" + nm + "," + nm + ",erzeuger.b" + nm + ",'" + basename + "',false);";
			ihtml = ihtml + "erzeuger.GMS(erzeuger.m" + nm +
						",erzeuger.n" + nm + "," + nm + ",erzeuger.b" + nm + ",'" + basename + "');";
			ihtml = ihtml + "self.close()\">";
			ihtml = ihtml + "Hauptvariante - Main line" + "<\a>";
			ihtml = ihtml + "<BR>";
			var nCurrentLevel=nLevels[nm];
			var nMoveNum=nMoves[nm];
			for ( j=0; j < moves.length; j++ )
			{	if ( j != nCurrentLevel && moves[j].root == nCurrentLevel && moves[j].move == nMoveNum )
				{	gm( moves,names,nm,base,basename,1,j);
					var moveStr = GMS2( moves, names, nm, base, 1, j, basename );
					ihtml = ihtml + "<a href=\"javascript:erzeuger.gm(erzeuger.m" + nm +
						",erzeuger.n" + nm + "," + nm + ",erzeuger.b" + nm + ",'" + basename + "',";
					ihtml = ihtml + "1," + j + ");self.close()\">";
					ihtml = ihtml + moveStr + "<\a>";
					ihtml = ihtml + "<BR>";
					gm( moves,names,nm,base,basename,nMoveNum,nCurrentLevel);
				}
			}
			if ( document.all )
				vf.document.all.disp.innerHTML=ihtml
			else if ( document.layers )
			{	vf.document.layers[0].document.clear();
				vf.document.layers[0].document.write(ihtml);
				vf.document.layers[0].document.close();
			}
			return base;
		}
	}
	if ( nMoves[nm] < moves[nLevels[nm]].length / 2 )
	{	var n = nMoves[nm]*2;
		var from = moves[nLevels[nm]][ n ] & 0x3f;
		var to = moves[nLevels[nm]][ n+1 ] & 0x3f;
		names[ nNameCount[nm]   ] = document.images[ base + from ].src;
		names[ nNameCount[nm]+1 ] = document.images[ base + to ].src;
		var len = names[nNameCount[nm]].length;
		var nn = (Math.floor(( to / 8 )) + ( to % 8 ));
		var dest = ( nn % 2 ) == 1 ? "b" : "w";
		var piece = names[nNameCount[nm]].substring(len-6,len-5);
		if (( moves[nLevels[nm]][ n ] & 0x380 ) == 0x80 )
			piece = "q";
		else if (( moves[nLevels[nm]][ n ] & 0x380 ) == 0x100 )
			piece = "n";
		else if (( moves[nLevels[nm]][ n ] & 0x380 ) == 0x180 )
			piece = "b";
		else if (( moves[nLevels[nm]][ n ] & 0x380 ) == 0x200 )
			piece = "r";
		document.images[ base + to ].src = names[nNameCount[nm]].substring(0,len-6) + piece + dest + names[nNameCount[nm]].substring(len-4,len);
		nn = (Math.floor(( from / 8 )) + ( from % 8 ));
		if (( nn % 2 ) == 1 )
			document.images[ base + from ].src = EmptyBlackPath;
		else
			document.images[ base + from ].src = EmptyWhitePath;
		nMoves[nm]++;
		nNameCount[nm] = nNameCount[nm] + 2;
		if ( nMoves[nm] < moves[nLevels[nm]].length / 2 && ( moves[nLevels[nm]][ nMoves[nm]*2 ] & 0x40 ) == 0x40 )
			MF( moves, names, nm, base, bCheckV );
	}
	return base
}
function MB( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	if ( nMoves[nm] > 0 )
	{	nMoves[nm]--;
		nNameCount[nm] -= 2;
		var from = moves[nLevels[nm]][ nMoves[nm]*2 ] & 0x3f;
		var to = moves[nLevels[nm]][ nMoves[nm]*2+1 ] & 0x3f;
		document.images[ base + from ].src = names[ nNameCount[nm] ];
		document.images[ base + to ].src = names[ nNameCount[nm]+1 ];
		if (( moves[nLevels[nm]][ nMoves[nm]*2 ] & 0x40 ) == 0x40 )
			MB( moves, names, nm, base );
	}
	if ( nMoves[nm] == 0 )
		if ( nLevels[nm] > 0 )
		{	nMoves[nm] = moves[nLevels[nm]].move;
			nLevels[nm] = moves[nLevels[nm]].root;
			if (( moves[nLevels[nm]][nMoves[nm]*2] & 0x40 ) == 0x40 )
				nMoves[nm]--;
		}
	return base;
}
function GMS2(  moves, names, nm, base, nMoveNumber, nLevel, basename )
{	if ( nMoveNumber > 0 )
	{	var n = (nMoveNumber-1)*2;
		var off=1;
		for ( i=0; i <= n; i += 2 )
			if (( moves[nLevel][i] & 0x40 ) == 0x40 )
				off = off+1;
		var from = moves[nLevel][ n ] & 0x3f;
		var to = moves[nLevel][ n+1 ] & 0x3f;
		var len = document.images[ base + to ].src.length;
		var piece = document.images[ base + to ].src.substring(len-6,len-5);
		if ( piece == "q" )
			piece = pieces.substring(1,2);
		else if ( piece == "r" )
			piece = pieces.substring(4,5);
		else if ( piece == "b" )
			piece = pieces.substring(3,4);
		else if ( piece == "n" )
			piece = pieces.substring(2,3);
		else if ( piece ==  "k" )
			piece = pieces.substring(0,1);
		else piece = pieces.substring(5,6);
		var piece2 = "";
		if (( moves[nLevel][ n ] & 0x380 ) == 0x80 )
			piece2 = pieces.substring(1,2);
		else if (( moves[nLevel][ n ] & 0x380 ) == 0x100 )
			piece2 = pieces.substring(2,3);
		else if (( moves[nLevel][ n ] & 0x380 ) == 0x180 )
			piece2 = pieces.substring(3,4);
		else if (( moves[nLevel][ n ] & 0x380 ) == 0x200 )
			piece2 = pieces.substring(4,5);
		var lines = "abcdefgh";
		var rows = "87654321";
		var fromLine = from%8;
		var fromRow = Math.floor(from/8);
		var toLine = to%8;
		var toRow = Math.floor(to/8);
		var moveNumber = gmn( moves, nLevel ) + nMoveNumber-off;
		var result = (Math.floor((moveNumber)/2)+1).toString() + ". ";
		if ( document.images[ base + to ].src.substring(len-7,len-6) == "b" )
			result = result + "... ";
		if ( n >= 2 && (( moves[nLevel][n] & 0x40 ) == 0x40 ))
		{	if (( moves[nLevel][n-1] == 62 ) || ( moves[nLevel][n-1] == 6 ))
				result = result + "0-0"
			else if (( moves[nLevel][n-1] == 2 + 7 * 8 ) || ( moves[nLevel][n-1] == 2 + 0 * 8 ))
				result = result + "0-0-0"
			else
			{	var sep = "x";
				from = moves[nLevel][ n-2 ] & 0x3f;
				to = moves[nLevel][ n-1 ] & 0x3f;
				fromLine = from%8;
				fromRow = Math.floor(from/8);
				toLine = to%8;
				toRow = Math.floor(to/8);
				result = result	+ lines.substring( fromLine, fromLine+1 ) + rows.substring( fromRow, fromRow+1 )
										+ sep
										+ lines.substring( toLine, toLine+1 ) + rows.substring( toRow, toRow+1 )
										+ piece2 + " ep";
			}
		}
		else
		{	var len = names[ nNameCount[nm]-1 ].length;
			var substr = names[ nNameCount[nm]-1 ].substring( len-6, len );
			var sep = (( substr == "/w.gif" ) || ( substr == "\\w.gif" ) ||
						  ( substr == "/b.gif" ) || ( substr == "\\b.gif" )) ? "-" : "x";
			if ( piece2 != "" ) piece = "";
			result = result + piece.toUpperCase() + lines.substring( fromLine, fromLine+1 ) + rows.substring( fromRow, fromRow+1 )
				+ sep
				+ lines.substring( toLine, toLine+1 ) + rows.substring( toRow, toRow+1 )
				+ piece2;
		}
	}
	else
		result='';
	if (document.all)
	{	name = 'i' + baseName + nm;
		if ( result == '' )
			document.all.tags( "DIV" )[name].innerHTML = "Startposition";
		else
			document.all.tags( "DIV" )[name].innerHTML = "Position after " + result;
	}
	else if ( document.layers )
	{	document.layers[nm].document.layers[0].document.clear();
		var gesamt = "<center>Position after " + result + "</center>";
		document.layers[nm].document.layers[0].document.write(gesamt);
		document.layers[nm].document.layers[0].document.close();
	}
	return result;
}
function GMS( moves, names, nm, base, basename )
{	base = SyncPicture( base, basename );
	var nLevel = nLevels[nm];
	var nMoveNumber = nMoves[nm];
	if ( nMoveNumber >= 0 && nMoveNumber <= moves[nLevel].length / 2 )
	{	if ( document.all )
		{	if ( nOld[nm] != -1 )
				document.anchors[nOld[nm]].style.background="#FFF8B3";
			if ( nMoveNumber > 0 )
			{	nOld[nm] = moves[nLevel].base[nMoveNumber-1];
				document.anchors[nOld[nm]].style.background="gray";
			}
			else
				nOld[nm] = -1;
		}
		return GMS2( moves, names, nm, base, nMoveNumber, nLevel, basename );
	}
	else
		return "??";
}
function gm( moves, names, nm, base, basename, n, m )
{	base = SyncPicture( base, basename );
	GoStart(moves,names,nm,base,basename );
	gm_sub( moves,names,nm,base,basename,n,m);
	GMS( moves, names, nm, base, basename );
}
function gmn( moves, m )
{	if ( m > 0 )
	{	var off=0;
		var n2 = moves[m].move;
		var m2 = moves[m].root;
		for ( i=0; i <= n2*2; i += 2 )
			if (( moves[m2][i] & 0x40 ) == 0x40 )
				off = off+1;
		return gmn( moves, m2 ) + ( n2 - off );
	}
	return 0;
}
function gm_sub( moves, names, nm, base, basename, n, m )
{	if ( m > 0 )
	{	var off=0;
		var n2 = moves[m].move;
		var m2 = moves[m].root;
		for ( i=0; i <= n2*2; i += 2 )
			if (( moves[m2][i] & 0x40 ) == 0x40 )
				off = off+1;
		gm_sub( moves,names,nm,base, basename, n2-off, m2  );
	}
	nLevels[nm]=m;
	nMoves[nm]=0;
	for ( i=0; i < n; i++ )
		MF(moves,names,nm,base,basename, false);
}

