var img_othello = image + "othello/";
var width = 297;
var height = 297;
var s_size = 32;
var u_height = 21;
var d_height = 20;
var l_width = 21;
var r_width = 20;

function board(bd) {
	var row;
	var col;
	var n;
	var buffer ="<img width='" + width + "' height='" + u_height +"' src='" + img_othello + "u" + width + "x" + u_height + ".png' alt='A B C D E F G H' /><br />";
	for (row=1, n=0; row<=8; row++) {
		buffer += "<img width='" + l_width + "' height='" + s_size + "' src='" + img_othello + "l" + row + "_" + l_width + "x" + s_size + ".png' alt='" + row + "' />";
		for (col=1; col<=8; col++, n++) {
			var disc = bd.charAt(n);
			if (disc == "b") {
				buffer += "<img width='32' height='32' src='" + img_othello + "b32.png' alt='x' />";
			} else if (disc == "w") {
				buffer += "<img width='32' height='32' src='" + img_othello + "w32.png' alt='o' />";
			} else if (disc == "e") {
				buffer += "<img width='32' height='32' src='" + image + "othello/e32.png' alt='.' />";
			} else if (disc == "X") {
				buffer += "<img width='32' height='32' src='" + image + "othello/r32.png' alt='-' />";
			}
		}
		buffer += "<img width='20' height='32' src='" + image + "othello/r" + row + "_20x32.png' alt='' /><br />";
	}
	buffer += "<img width='297' height='20' src='" + image + "othello/d297x20.png' alt='' /><br />";
	document.writeln(buffer);
}

function applet_code(record){
	var buffer = "<applet code='OthelloBrowser.class' archive='OthelloBrowser.jar' codebase='" + java + "' width='290' height='370'>\n";
	buffer += "<param name='game' value='" + record + "' />\n";
	//buffer += "<param name='board' value='--------------------------------------------O#--------#O--------------------------------------------'>";
	buffer += "<param name='atmove' value='black' />\n";
	buffer += "<strong>\n";
	buffer += "This browser does not have a Java Plug-in.<br />\n";
	buffer += "<a href='http://java.com/' target='_blank'>Get the latest Java Plug-in here.</a>\n";
	buffer += "</strong>\n";
	buffer += "</applet>\n";
	return buffer;
}

function popup_game(record){
	var popup = window.open("", record, "width=290, height=370");
	popup.document.open();
	popup.document.writeln("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>");
	popup.document.writeln("<html xmlns='http://www.w3.org/1999/xhtml'>");
	popup.document.writeln("<head><title></title></head>");
	popup.document.writeln("<body style='margin: 0px'>");
	popup.document.writeln(applet_code(record));
	//popup.document.writeln("record");
	popup.document.writeln("</body>");
	popup.document.writeln("</html>");
	popup.document.close();
}
