function roundBorder() {
  var imgdir = "../";
  var divs = document.getElementsByTagName('div');
  var rounded_divs = [];
  for (var i = 0; i < divs.length; i++) {
    if (/\brounded\b/.exec(divs[i].className)) {
      rounded_divs[rounded_divs.length] = divs[i];
    }
  }
  for (var i = 0; i < rounded_divs.length; i++) {
    var original = rounded_divs[i];
    original.className = original.className.replace('rounded', '');
    var mytable = document.createElement("table");
    mytable.setAttribute("border","0");
    mytable.setAttribute("cellPadding","0");
    mytable.setAttribute("cellSpacing","0");
    mytable.style.margin = "5px";
    original.parentNode.replaceChild(mytable, original);
    var mytbody = document.createElement("tbody");
    var myrow=document.createElement("tr");
      var mycell=document.createElement("td");
      var myimg=document.createElement("img");
      myimg.setAttribute("src",imgdir+"TL.gif");
      myimg.setAttribute("width","15");
      myimg.setAttribute("height","15");
      mycell.appendChild(myimg);
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      mytxt=document.createTextNode("\u00a0");
      mycell.appendChild(mytxt);
      mycell.className = "smallfont";
      mycell.style.height = "15px";
      mycell.style.backgroundImage = "url('"+imgdir+"T.gif')";
      mycell.style.backgroundRepeat = "repeat-x";
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      myimg=document.createElement("img");
      myimg.setAttribute("src",imgdir+"TR.gif");
      myimg.setAttribute("width","15");
      myimg.setAttribute("height","15");
      mycell.appendChild(myimg);
    myrow.appendChild(mycell);
    mytbody.appendChild(myrow);

    myrow=document.createElement("tr");
      mycell=document.createElement("td");
      mytxt=document.createTextNode("\u00a0");
      mycell.appendChild(mytxt);
      mycell.style.width = "15px";
      mycell.style.backgroundImage = "url('"+imgdir+"L.gif')";
      mycell.style.backgroundRepeat = "repeat-y";
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      mycell.appendChild(original);
      mycell.className = "roundedcontent";
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      mytxt=document.createTextNode("\u00a0");
      mycell.appendChild(mytxt);
      mycell.style.width = "15px";
      mycell.style.backgroundImage = "url('"+imgdir+"R.gif')";
      mycell.style.backgroundRepeat = "repeat-y";
    myrow.appendChild(mycell);
    mytbody.appendChild(myrow);

    myrow=document.createElement("tr");
      mycell=document.createElement("td");
      myimg=document.createElement("img");
      myimg.setAttribute("src",imgdir+"BL.gif");
      myimg.setAttribute("width","15");
      myimg.setAttribute("height","15");
      mycell.appendChild(myimg);
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      mytxt=document.createTextNode("\u00a0");
      mycell.appendChild(mytxt);
      mycell.className = "smallfont";
      mycell.style.height = "15px";
      mycell.style.backgroundImage = "url('"+imgdir+"B.gif')";
      mycell.style.backgroundRepeat = "repeat-x";
    myrow.appendChild(mycell);
      mycell=document.createElement("td");
      myimg=document.createElement("img");
      myimg.setAttribute("src",imgdir+"BR.gif");
      myimg.setAttribute("width","15");
      myimg.setAttribute("height","15");
      mycell.appendChild(myimg);
    myrow.appendChild(mycell);
    mytbody.appendChild(myrow);
    mytable.appendChild(mytbody);
  }
}

function PrintMoves(moves,emoves,pass,swap){
  var cmcnt = moves.length;
  document.write('<tr>');
  for(i = 1; i < cmcnt; i++){
    document.write('<td class="move">'+i+'</td><td><a href="'+pass+'&m='+i+'">'+moves[i-1]+'</a></td>');
    if(i % 2 == 0)
      document.write('</tr>\n<tr>');
  }
  if(cmcnt > 0){
    document.write('<td>'+cmcnt+'</td><td><a href="'+pass+'">'+moves[cmcnt-1]+'</a>');
    if(cmcnt == swap)
      document.write('&nbsp;(<a class="emove" href="'+pass+'&m='+cmcnt+'&swap=1">swapped</a>)');
    document.write('</td>');
  }
  var emcnt = emoves.length;
  if(cmcnt % 2 == 0){
    document.write('</tr>\n');
    if(emcnt>0)
      document.write('<tr>');
  }
  for(i = cmcnt+1; i <= cmcnt+emcnt; i++){
    if(i % 2 == 1) document.write('<tr>');
    document.write('<td class="emove">'+i+'</td><td><a class="emove" href="'+pass+'&m='+i+'">'+emoves[i-1-cmcnt]+'</a>');
    if(i == swap)
      document.write('&nbsp;(<a href="'+pass+'&m='+i+'&swap=1">swapped</a>)');
    document.write('</td>');
    if(i % 2 == 0) document.write('</tr>\n');
  }
}

window.onload = roundBorder;

