
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(go_table);
addLoadEvent(white_stone);
addLoadEvent(black_stone);

   function go_table() {
    //var body = document.getElementsByTagName("body")[0];
	var _tboard = document.getElementById("tboard");
    //var tblBody = document.createElement("tbody");
	for (var j = 0; j < 19; j++){
		var table_row = document.createElement("tr");
		
		for (var i = 0; i < 19; i++){
			var table_cell = document.createElement("td");
            //var cellText = document.createTextNode("cell is row "+j+", column "+i);
            //table_cell.appendChild(cellText);
            var cell_id = "cell_"+j+"_"+i;
            table_cell.setAttribute("id",cell_id);
			table_row.appendChild(table_cell);
		}
	//	tblBody.appendChild(table_row);
	//	_tboard.appendChild(tblBody);
	_tboard.appendChild(table_row);	
	}
}

	function white_stone(){
	   var _piw = document.getElementById("piw");
	   var white_img = _piw.getAttribute("src");
	   var table_cell = document.getElementById("cell_5_3");
	   table_cell.setAttribute("background",white_img);
	}
		function black_stone(){
	   var _pib = document.getElementById("pib");
	   var black_img = _pib.getAttribute("src");
	   var table_cell = document.getElementById("cell_4_3");
	   table_cell.setAttribute("background",black_img);
	}

