function escramble(x, y, z){
   var e,h
   h='<A HREF=\"mai'
   h+='lto:'
   e=x
   e+='@'
   e+=y
   h+=e
   h+='\">'
   if (z) h+=z
   else h+=e
   h+='<' + '/A>'
   document.writeln(h)
}

function randomPassword(id)
{
	var pwd = ''
	while(pwd.length < 8) pwd += Math.ceil(Math.random() * 36*36*36).toString(36)
	document.getElementById(id).value = pwd
}

function showRes(txt, eType, e) {
  var x, y, top, left;

  if (!e) e=window.event;

  if (self.pageYOffset) { // all except Explorer
    x = self.pageXOffset;
    y = self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
    x = document.documentElement.scrollLeft;
    y = document.documentElement.scrollTop;
  }
  else if (document.body) { // all other Explorers
    x = document.body.scrollLeft;
    y = document.body.scrollTop;
  }

  left = x + e.clientX - 200;
  top = y + e.clientY + 15;

  document.getElementById("ResultsSummary").style.left=left + 'px';
  document.getElementById("ResultsSummary").style.top=top + 'px';
  document.getElementById("ResultsSummary").innerHTML='<TABLE CLASS=resSummary CELLPADDING=3>' + txt + '</TABLE>';
  document.getElementById("ResultsSummary").style.visibility='visible';
}

function hideRes() {
  document.getElementById("ResultsSummary").style.visibility = "hidden";
}

function showHideGradingData(vis) {
  var x = document.getElementById('showHideGradingData');
  all = document.all || document.getElementsByTagName('*');
  for (var i=0; i<all.length; i++) {
    if (all[i].className == 'xtabGradeInfo') {
      all[i].style.visibility = vis;
    }
  }
  if (vis == 'visible') {
    x.innerHTML = '<A HREF="javascript:showHideGradingData(\'hidden\')">Hide grading data</A>';
  }
  else {
    x.innerHTML = '<A HREF="javascript:showHideGradingData(\'visible\')">Show grading data</A>';
  }
}

function hideMatch() {
  document.getElementById("Match").style.visibility = 'hidden';
}

function showMatch (pnum, onum, rnd, clr, res, tot, e) {
  var x, y, top, left, xtabHTML;

  if (!e) e=window.event;

  if (self.pageYOffset) { // all except Explorer
    x = self.pageXOffset;
    y = self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
    x = document.documentElement.scrollLeft;
    y = document.documentElement.scrollTop;
  }
  else if (document.body) { // all other Explorers
    x = document.body.scrollLeft;
    y = document.body.scrollTop;
  }

  left = x + e.clientX - 200
  top = y + e.clientY + 15

  document.getElementById("Match").style.left=left + 'px';
  document.getElementById("Match").style.top=top + 'px';
  if (clr == 'w') { clr = 'white'; }
  else { clr = 'black'; }
  if (res == '1') { res = 'win'; }
  else if (res == '0') { res = 'loss'; }
  else { res = 'draw'; }
  xtabHTML = '<TABLE CELLPADDING="2">' +
'<TR><TD style="background: #FDB;">Player:</TD><TD style="background: #FDB;">' + pName[pnum] +
'<TR><TD style="background: #FDB;">Round:</TD><TD style="background: #FDB;">' + rnd +
'<TR><TD style="background: #FDB;">Colour:</TD><TD style="background: #FDB;">' + clr +
'<TR><TD style="background: #FDB;">Opponent:</TD><TD style="background: #FDB;">' + pName[onum] +
'<TR><TD style="background: #FDB;">Result:</TD><TD style="background: #FDB;">' + res;
  if ( tot != '' ) {
    xtabHTML += '<TR><TD style="background: #FDB;">Cum. Score:</TD><TD style="background: #FDB;"> ' + tot;
  }
  xtabHTML += '</TABLE>';
  document.getElementById("Match").innerHTML = xtabHTML;
  document.getElementById("Match").style.visibility='visible';
}

