
function InitGames()
{
leftWindow.igames_women_round_50.value=GMS(m0, n0, 0, b0, 'games_women_round_5g0.htm');
leftWindow.igames_women_round_51.value=GMS(m1, n1, 1, b1, 'games_women_round_5g1.htm');
leftWindow.igames_women_round_52.value=GMS(m2, n2, 2, b2, 'games_women_round_5g2.htm');
leftWindow.igames_women_round_53.value=GMS(m3, n3, 3, b3, 'games_women_round_5g3.htm');
leftWindow.igames_women_round_54.value=GMS(m4, n4, 4, b4, 'games_women_round_5g4.htm');
leftWindow.igames_women_round_55.value=GMS(m5, n5, 5, b5, 'games_women_round_5g5.htm');
leftWindow.igames_women_round_56.value=GMS(m6, n6, 6, b6, 'games_women_round_5g6.htm');
leftWindow.igames_women_round_57.value=GMS(m7, n7, 7, b7, 'games_women_round_5g7.htm');
leftWindow.igames_women_round_58.value=GMS(m8, n8, 8, b8, 'games_women_round_5g8.htm');
leftWindow.igames_women_round_59.value=GMS(m9, n9, 9, b9, 'games_women_round_5g9.htm');
leftWindow.igames_women_round_510.value=GMS(m10, n10, 10, b10, 'games_women_round_5g10.htm');
leftWindow.igames_women_round_511.value=GMS(m11, n11, 11, b11, 'games_women_round_5g11.htm');
leftWindow.igames_women_round_512.value=GMS(m12, n12, 12, b12, 'games_women_round_5g12.htm');
leftWindow.igames_women_round_513.value=GMS(m13, n13, 13, b13, 'games_women_round_5g13.htm');
leftWindow.igames_women_round_514.value=GMS(m14, n14, 14, b14, 'games_women_round_5g14.htm');
leftWindow.igames_women_round_515.value=GMS(m15, n15, 15, b15, 'games_women_round_5g15.htm');
leftWindow.igames_women_round_516.value=GMS(m16, n16, 16, b16, 'games_women_round_5g16.htm');
leftWindow.igames_women_round_517.value=GMS(m17, n17, 17, b17, 'games_women_round_5g17.htm');
leftWindow.igames_women_round_518.value=GMS(m18, n18, 18, b18, 'games_women_round_5g18.htm');
leftWindow.igames_women_round_519.value=GMS(m19, n19, 19, b19, 'games_women_round_5g19.htm');
leftWindow.igames_women_round_520.value=GMS(m20, n20, 20, b20, 'games_women_round_5g20.htm');
leftWindow.igames_women_round_521.value=GMS(m21, n21, 21, b21, 'games_women_round_5g21.htm');
leftWindow.igames_women_round_522.value=GMS(m22, n22, 22, b22, 'games_women_round_5g22.htm');
leftWindow.igames_women_round_523.value=GMS(m23, n23, 23, b23, 'games_women_round_5g23.htm');
leftWindow.igames_women_round_524.value=GMS(m24, n24, 24, b24, 'games_women_round_5g24.htm');
leftWindow.igames_women_round_525.value=GMS(m25, n25, 25, b25, 'games_women_round_5g25.htm');
leftWindow.igames_women_round_526.value=GMS(m26, n26, 26, b26, 'games_women_round_5g26.htm');
leftWindow.igames_women_round_527.value=GMS(m27, n27, 27, b27, 'games_women_round_5g27.htm');
leftWindow.igames_women_round_528.value=GMS(m28, n28, 28, b28, 'games_women_round_5g28.htm');
leftWindow.igames_women_round_529.value=GMS(m29, n29, 29, b29, 'games_women_round_5g29.htm');
leftWindow.igames_women_round_530.value=GMS(m30, n30, 30, b30, 'games_women_round_5g30.htm');
leftWindow.igames_women_round_531.value=GMS(m31, n31, 31, b31, 'games_women_round_5g31.htm');
leftWindow.igames_women_round_532.value=GMS(m32, n32, 32, b32, 'games_women_round_5g32.htm');
leftWindow.igames_women_round_533.value=GMS(m33, n33, 33, b33, 'games_women_round_5g33.htm');
leftWindow.igames_women_round_534.value=GMS(m34, n34, 34, b34, 'games_women_round_5g34.htm');
leftWindow.igames_women_round_535.value=GMS(m35, n35, 35, b35, 'games_women_round_5g35.htm');
leftWindow.igames_women_round_536.value=GMS(m36, n36, 36, b36, 'games_women_round_5g36.htm');
leftWindow.igames_women_round_537.value=GMS(m37, n37, 37, b37, 'games_women_round_5g37.htm');
leftWindow.igames_women_round_538.value=GMS(m38, n38, 38, b38, 'games_women_round_5g38.htm');
leftWindow.igames_women_round_539.value=GMS(m39, n39, 39, b39, 'games_women_round_5g39.htm');
leftWindow.igames_women_round_540.value=GMS(m40, n40, 40, b40, 'games_women_round_5g40.htm');
leftWindow.igames_women_round_541.value=GMS(m41, n41, 41, b41, 'games_women_round_5g41.htm');
leftWindow.igames_women_round_542.value=GMS(m42, n42, 42, b42, 'games_women_round_5g42.htm');
leftWindow.igames_women_round_543.value=GMS(m43, n43, 43, b43, 'games_women_round_5g43.htm');
leftWindow.igames_women_round_544.value=GMS(m44, n44, 44, b44, 'games_women_round_5g44.htm');
leftWindow.igames_women_round_545.value=GMS(m45, n45, 45, b45, 'games_women_round_5g45.htm');
leftWindow.igames_women_round_546.value=GMS(m46, n46, 46, b46, 'games_women_round_5g46.htm');
leftWindow.igames_women_round_547.value=GMS(m47, n47, 47, b47, 'games_women_round_5g47.htm');
leftWindow.igames_women_round_548.value=GMS(m48, n48, 48, b48, 'games_women_round_5g48.htm');
leftWindow.igames_women_round_549.value=GMS(m49, n49, 49, b49, 'games_women_round_5g49.htm');
leftWindow.igames_women_round_550.value=GMS(m50, n50, 50, b50, 'games_women_round_5g50.htm');
leftWindow.igames_women_round_551.value=GMS(m51, n51, 51, b51, 'games_women_round_5g51.htm');
leftWindow.igames_women_round_552.value=GMS(m52, n52, 52, b52, 'games_women_round_5g52.htm');
leftWindow.igames_women_round_553.value=GMS(m53, n53, 53, b53, 'games_women_round_5g53.htm');
leftWindow.igames_women_round_554.value=GMS(m54, n54, 54, b54, 'games_women_round_5g54.htm');
leftWindow.igames_women_round_555.value=GMS(m55, n55, 55, b55, 'games_women_round_5g55.htm');
leftWindow.igames_women_round_556.value=GMS(m56, n56, 56, b56, 'games_women_round_5g56.htm');
leftWindow.igames_women_round_557.value=GMS(m57, n57, 57, b57, 'games_women_round_5g57.htm');
leftWindow.igames_women_round_558.value=GMS(m58, n58, 58, b58, 'games_women_round_5g58.htm');
leftWindow.igames_women_round_559.value=GMS(m59, n59, 59, b59, 'games_women_round_5g59.htm');
leftWindow.igames_women_round_560.value=GMS(m60, n60, 60, b60, 'games_women_round_5g60.htm');
leftWindow.igames_women_round_561.value=GMS(m61, n61, 61, b61, 'games_women_round_5g61.htm');
leftWindow.igames_women_round_562.value=GMS(m62, n62, 62, b62, 'games_women_round_5g62.htm');
leftWindow.igames_women_round_563.value=GMS(m63, n63, 63, b63, 'games_women_round_5g63.htm');
leftWindow.igames_women_round_564.value=GMS(m64, n64, 64, b64, 'games_women_round_5g64.htm');
leftWindow.igames_women_round_565.value=GMS(m65, n65, 65, b65, 'games_women_round_5g65.htm');
leftWindow.igames_women_round_566.value=GMS(m66, n66, 66, b66, 'games_women_round_5g66.htm');
leftWindow.igames_women_round_567.value=GMS(m67, n67, 67, b67, 'games_women_round_5g67.htm');
leftWindow.igames_women_round_568.value=GMS(m68, n68, 68, b68, 'games_women_round_5g68.htm');
leftWindow.igames_women_round_569.value=GMS(m69, n69, 69, b69, 'games_women_round_5g69.htm');
leftWindow.igames_women_round_570.value=GMS(m70, n70, 70, b70, 'games_women_round_5g70.htm');
leftWindow.igames_women_round_571.value=GMS(m71, n71, 71, b71, 'games_women_round_5g71.htm');
leftWindow.igames_women_round_572.value=GMS(m72, n72, 72, b72, 'games_women_round_5g72.htm');
leftWindow.igames_women_round_573.value=GMS(m73, n73, 73, b73, 'games_women_round_5g73.htm');
leftWindow.igames_women_round_574.value=GMS(m74, n74, 74, b74, 'games_women_round_5g74.htm');
leftWindow.igames_women_round_575.value=GMS(m75, n75, 75, b75, 'games_women_round_5g75.htm');
leftWindow.igames_women_round_576.value=GMS(m76, n76, 76, b76, 'games_women_round_5g76.htm');
leftWindow.igames_women_round_577.value=GMS(m77, n77, 77, b77, 'games_women_round_5g77.htm');
}
// Copyright 98,99,00,01 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 < leftDocument.images.length; i++ )
	{	if ( leftDocument.images[i].name != "" )
			if ( leftDocument.images[i].name == basename )
				return i;
			else if ( leftDocument.images[i].name.substring(0,3) == basename.substring(0,3) )
				i+= 63;
	}
	return -1;
}
function MF_5( 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 MB_5( 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 )
		{	GenerateVarWindow(moves, names, nm, base, basename);
			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]   ] = leftDocument.images[ base + from ].src;
		names[ nNameCount[nm]+1 ] = leftDocument.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";
		leftDocument.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 )
			leftDocument.images[ base + from ].src = EmptyBlackPath;
		else
			leftDocument.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;
		leftDocument.images[ base + from ].src = names[ nNameCount[nm] ];
		leftDocument.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 = leftDocument.images[ base + to ].src.length;
		var piece = leftDocument.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 ( leftDocument.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 (leftDocument.all)
	{	if ( bFrames )	name = 'i' + baseName + '0';
		else name = 'i' + baseName + nm;
		if ( result == '' )
			leftDocument.all.tags( "DIV" )[name].innerHTML = start_pos;
		else
			leftDocument.all.tags( "DIV" )[name].innerHTML = pos_after + result;
	}
	else if ( leftDocument.layers )
	{	var inx = nm;
		if ( bFrames ) inx = 0;
		leftDocument.layers[inx].document.layers[0].document.clear();
		if ( result == '' )
			var gesamt = "<center>" + start_pos + "</center>";
		else
			var gesamt = "<center>" + pos_after + " " + result + "</center>";
		leftDocument.layers[inx].document.layers[0].document.write(gesamt);
		leftDocument.layers[inx].document.layers[0].document.close();
	}
	else if ( leftDocument.getElementById )
	{	if ( bFrames ) name = 'i' + baseName + '0';
		else name = 'i' + baseName + nm;
		if ( result == '' )
			leftDocument.getElementById(name).innerHTML = start_pos;
		else
			leftDocument.getElementById(name).innerHTML = pos_after + result;
	}
	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 ( leftDocument.all )
		{	if ( nOld[nm] != -1 )
				rightDocument.anchors[nOld[nm]].style.background=BackColor;
			if ( nMoveNumber > 0 )
			{	nOld[nm] = moves[nLevel].base[nMoveNumber-1];
				rightDocument.anchors[nOld[nm]].style.background="gray";
				with ( rightDocument )
					with ( all.tags("a")[nOld[nm]] )
					{	if ( parent.frames[1] && ( offsetTop > body.scrollTop + offsetParent.offsetHeight - offsetHeight || offsetTop < body.scrollTop ))
							rightWindow.scrollTo( 0, offsetTop - ( offsetParent.offsetHeight / 2 ) );
					}
			}
			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);
}
