var oid;
var soid;
var opt;

function matchup_history(t0,t1,lg) {
  var req = new XMLHttpRequest();

  req.onreadystatechange=function() {
    if(req.readyState==4)
      document.getElementById('matchup_history').innerHTML = req.responseText;
  }

  url = "matchup_history.php?t0=" + t0 + "&t1=" + t1 + "&lg=" + lg;
  req.open("POST",url,true);
  req.send(null);
}


function loadselect(a) {
  x = document.getElementById('select_seas');
  n = x.selectedIndex + a;
  if ( (n>=0) && (n<x.options.length) ) { // range check [0,length)
    //    x.selectedIndex = n;
    //    change_seas(oid,x.options[n].value,opt,0);
    window.location = "team.php?t=" + oid + "&s=" + x.options[n].value;
  }
}



/*
function team_sch() {
  var req = new XMLHttpRequest();

  req.onreadystatechange=function() {
    if(req.readyState==4) {
      eval(req.responseText);
      document.getElementById('team_sch').innerHTML = htm;
      maketables(1);
    }
  }

  url = "team_head.php?t=" + oid + "&s=" + soid + "&o=" + opt + "&i=3";
  req.open("POST",url,true);
  req.send(null);
}

function team_head(i) {
  var req = new XMLHttpRequest();
  var x;
  if (i==0) x='team_org';
  else if (i==1) x='team_parents';
  else if (i==2) x='team_stat';

  req.onreadystatechange=function() {
    if(req.readyState==4)
      document.getElementById(x).innerHTML = req.responseText;
  }

  url = "team_head.php?t=" + oid + "&s=" + soid + "&o=" + opt + "&i=" + i;
  req.open("POST",url,true);
  req.send(null);
}

function change_seas(t,s,o,x) {
  oid = t;
  soid = s;
  opt = o;
  if (x) team_head(0);     // org changed
  team_head(1);
  team_head(2);
  team_sch();
}
*/




// see play.php
function play(soid) {
  var req = new XMLHttpRequest();

  req.onreadystatechange=function() {
    if(req.readyState==4)
      document.getElementById('prediction').innerHTML = req.responseText;
  }

  x0 = document.getElementById('t0');
  t0 = x0.options[x0.selectedIndex].value;
  x1 = document.getElementById('t1');
  t1 = x0.options[x1.selectedIndex].value;
  xh = document.getElementById('hf');
  hf = xh.options[xh.selectedIndex].value;

  url = "users/matchup.php?t0="+t0 + "&t1="+t1 + "&s0="+soid + "&s1="+soid + "&h="+hf + "&f=1";
  req.open("POST",url,true);
  req.send(null);
}
