//2009年5月12日17:52:30
//sunloft
function getmatch(match_json)
{  
  //クリア
  $('match_info').innerHTML = '';
  
  if (match_json["data"].length >= 1){
    
    //table作成
    var table,tbody,th,tr,td,text,font,link;
    var dt,matchrank;
    table = document.createElement('table');
    //table.setAttribute('name', 'match_table');
    table.setAttribute('id', '_HPB_TABLE_6_B_081028215850');
    table.className = 'hpb-cnt-tb3';
    //table.setAttribute('class', 'hpb-cnt-tb3');
    table.border = "1";
    // border="1" id="_HPB_TABLE_6_B_081028215850" class="hpb-cnt-tb3"
    tbody = document.createElement('tbody');
    tr = document.createElement("tr")
    td = document.createElement("td")
    th = document.createElement("th")
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.setAttribute('align','center');
    font = document.createElement("font")
    font.size="-1";
    text = document.createTextNode("日付")
    font = document.createElement("font")
    font.size="-1";
    font.appendChild(text);
    th.appendChild(font);
    tr.appendChild(th);

    text = document.createTextNode("時間")
    font = document.createElement("font")
    font.size="-1";
    font.appendChild(text);
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(font);
    tr.appendChild(th);
    text = document.createTextNode("チーム名")
    font = document.createElement("font")
    font.size="-1";
    font.appendChild(text);
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(font);
    tr.appendChild(th);
    text = document.createTextNode("ランキング")
    font = document.createElement("font")
    font.size="-1";
    font.appendChild(text);
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(font);
    tr.appendChild(th);
    text = document.createTextNode("コート")
    font = document.createElement("font")
    font.size="-1";
    font.appendChild(text);
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(font);
    tr.appendChild(th);

    text = document.createTextNode("対戦希望")
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(text);
    tr.appendChild(th);

    text = document.createTextNode(" ")
    th = document.createElement("th")
    th.setAttribute('align','center');
    th.className = 'hpb-cnt-tb-th2';
    //th.setAttribute('class', 'hpb-cnt-tb-th2');
    th.appendChild(text);
    tr.appendChild(th);
    tbody.appendChild(tr);
    
         
     for (var i = 0; i < match_json["data"].length; i++){

     tr = document.createElement("tr")


     //日付
     dt = match_json["data"][i]["date"].substr(4,2) + "月" + match_json["data"][i]["date"].substr(6,2) + "日";
     text = document.createTextNode(dt);
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(text);
     text = document.createTextNode("(");
     td.appendChild(text);
     font = document.createElement("font");
     font.color=match_json["data"][i]["color"];
     text = document.createTextNode(match_json["data"][i]["week"]);
     font.appendChild(text);
     td.appendChild(font);
     text = document.createTextNode(")");
     td.appendChild(text);
     tr.appendChild(td);
     text = document.createTextNode(match_json["data"][i]["time_s"].substr(0,2) + ":" + match_json["data"][i]["time_s"].substr(2,2) + "〜");
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(text);
     tr.appendChild(td);
     text = document.createTextNode(match_json["data"][i]["team_name"]);
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(text);
     tr.appendChild(td);
     text = document.createTextNode(match_json["data"][i]["team_rank"] + '位');
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.setAttribute('align','center');
     td.appendChild(text);
     tr.appendChild(td);
     text = document.createTextNode(match_json["data"][i]["court"]);
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(text);
     tr.appendChild(td);

     matchrank = '';
     if (match_json["data"][i]["match_s"] != '0'){
     	matchrank = match_json["data"][i]["match_s"] + '位';
     }
     if (match_json["data"][i]["match_e"] != '0' && match_json["data"][i]["match_e"] != '999'){
     	matchrank = matchrank + '〜';
     }
     if (match_json["data"][i]["match_e"] == '999'){
     	matchrank = matchrank + '以降';
     }else{
     	if (match_json["data"][i]["match_e"] != '0'){
     		matchrank = matchrank + match_json["data"][i]["match_e"] + '位';
     	}else{
     		matchrank = '　';
     	}
     }
     text = document.createTextNode(matchrank);
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(text);
     tr.appendChild(td);

     link = document.createElement("a");
     link.href='/court/stat.asp?d=' + match_json["data"][i]["date"] + '&t=' + match_json["data"][i]["time_s"];
     text = document.createTextNode("対戦する");
     link.appendChild(text);
     td = document.createElement("td");
     td.className = 'hpb-cnt-tb-cell5';
     //td.setAttribute('class','hpb-cnt-tb-cell5');
     td.appendChild(link);
     tr.appendChild(td);
     tr.appendChild(td);
     tbody.appendChild(tr);
     }
    
    
    
    table.appendChild(tbody)
    $('match_info').appendChild(table);
  }
  
    

}
