function drawSecTable1(tbody, C) {
  top.virginTbl &= top.contentFrame.s == 0;
  var c1 = "#fff", c2 = "#eee", c3 = "#ffffcc";
  var even = false;
  var evenColor, oddColor;
  var tr, td;
  for (var i = 0; i < C.length; i++) {
    if (extrName(C[i].n) == "ALL") {
      evenColor = c3;
      oddColor = c3;
    }
    else {
      evenColor = c1;
      oddColor = c2;
    }
    tr = tbody.rows[i];
    tr.style.backgroundColor = even ? evenColor : oddColor;
    td = tr.cells[0];
    td.innerHTML = C[i].n;
    td = tr.cells[1];
    td.innerHTML = top.addCommas(C[i].m.toFixed(0));
    td = tr.cells[2];
    td.innerHTML = C[i].s.toFixed(2);
    td = tr.cells[3];
    td.innerHTML = extrName(C[i].n) == "ALL" ? "n/a" : C[i].r.toFixed(0);
    td = tr.cells[4];
    td.innerHTML = C[i].x.toFixed(1) + "%";
    td = tr.cells[5];
    td.innerHTML = C[i].y.toFixed(1) + "%";
    td = tr.cells[6];
    td.innerHTML = C[i].z.toFixed(1) + "%";
    td = tr.cells[7];
    td.innerHTML = C[i].q.toFixed(1) + "%";
    td = tr.cells[8];
    td.innerHTML = C[i].v;
    td = tr.cells[9];
    td.innerHTML = C[i].w;
    td = tr.cells[10];
    td.innerHTML = C[i].u;
    td = tr.cells[11];
    td.innerHTML = C[i].b == -999 ? "n/a" : C[i].b.toFixed(2);
    td = tr.cells[12];
    td.innerHTML = C[i].b == -999 ? "n/a" : C[i].c.toFixed(2);
    td = tr.cells[13];
    td.innerHTML = C[i].b == -999 ? "n/a" : C[i].e.toFixed(1) + "%";
    even = !even;
  }
  top.showOrd();
}

// Sorting function dispatcher (invoked by table column links)
function srtSec1(type, tbody, C)
{
  if (top.sTyp == type)
    top.sOrd *= -1;
  else {
    top.delOrd();
    top.sOrd = 1;
    top.sTyp = type;
  }
  setTimeout("top.controlFrame.document.getElementById('progress').style.visibility='hidden'", 300);
  switch (type) {
    case 0 : C.sort(sortBySecName); break;
    case 1 : C.sort(sortByMCap); break;
    case 2 : C.sort(sortBySignal); break;
    case 3 : C.sort(sortByRank); break;
    case 4 : C.sort(sortByChg1); break;
    case 5 : C.sort(sortByChg5); break;
    case 6 : C.sort(sortByChg20); break;
    case 7 : C.sort(sortByChg60); break;
    case 8 : C.sort(sortByVol); break;
    case 9 : C.sort(sortByVol5); break;
    case 10 : C.sort(sortByVol20); break;
    case 11 : C.sort(sortByBeta); break;
    case 12 : C.sort(sortByCorr); break;
    case 13 : C.sort(sortByVols); break;
  }
  drawSecTable1(tbody, C);
}

// Sorting functions (invoked by sortTable())
function sortBySecName(x, y) {
  a = extrName(x.n).toLowerCase();
  b = extrName(y.n).toLowerCase();
  return ((a < b) ? -top.sOrd : ((a > b) ? top.sOrd : 0));
}
function sortByRank(a, b) {
  if (extrName(b.n) == "ALL")
    return -1;
  if (extrName(a.n) == "ALL")
    return 1;
  return (a.r - b.r) * top.sOrd;
}
function sortBySignal(a, b) {
  return (b.s - a.s) * top.sOrd;
}
function sortByVols(a, b) {
  return (b.e - a.e) * top.sOrd;
}
function sortByVol5(a, b) {
  return (b.w - a.w) * top.sOrd;
}
function sortByVol20(a, b) {
  return (b.u - a.u) * top.sOrd;
}
function extrName(n) {
  return n.substring(n.indexOf(">")+1,n.lastIndexOf("<"));
}
