Week = new Array("日","月","火","水","木","金","土");

hizuke    = new Array();
zikoku1   = new Array();
zikoku2   = new Array();
title     = new Array();
subtitle1 = new Array();
subtitle2 = new Array();
linkfile  = new Array();
sponsor   = new Array();
tel       = new Array();
fee       = new Array();

kensuu = SetEventData();

function ViewEvent(add_month)
{

  day_1 = new Date();

  yy_1 = day_1.getYear();
  if(add_month < 0){
    mm_1 = day_1.getMonth() + 1;
  }else{
    mm_1 = day_1.getMonth() + 1 + add_month;
  }
  if (mm_1 > 12) {
    mm_1 -= 12;
    yy_1 += 1;
  }
  dd_1 = day_1.getDate();
  if (yy_1 < 2000) { yy_1 += 1900; }
  if (mm_1 < 10) { mm_1 = "0" + mm_1; }
  if (dd_1 < 10) { dd_1 = "0" + dd_1; }
  yy_1 = "" + yy_1; //文字列に変換するために必要
  mm_1 = "" + mm_1; //文字列に変換するために必要
  dd_1 = "" + dd_1; //文字列に変換するために必要
  document.write("<table width=\"600\" border=\"2\" cellspacing=\"2\" cellpadding=\"2\">");
  document.write("  <tr>");
  document.write("    <td width=\"84\" align=\"center\" bgcolor=\"\#CCFFCC\">開演日時</td>");
  document.write("    <td width=\"311\" align=\"center\" bgcolor=\"\#CCFFCC\">催事名</td>");
  document.write("    <td width=\"99\" align=\"center\" bgcolor=\"\#CCFFCC\">問合せ先</td>");
  document.write("    <td width=\"61\" align=\"center\" bgcolor=\"\#CCFFCC\">料　金</td>");
  document.write("  </tr>");

  if(add_month < 0){
    for(i = kensuu - 1; i >= 0; i--){
      ViewEvent_Sub(add_month, i);
    }
  }else{
    for(i = 0; i < kensuu; i++){
      ViewEvent_Sub(add_month, i);
    }
  }

  document.write("</table>");
}

function ViewEvent_Sub(add_month, i)
{
  yy_2 = hizuke[i].substr(0, 4);
  mm_2 = hizuke[i].substr(5, 2);
  dd_2 = hizuke[i].substr(8, 2);
  if((add_month >= 0 && (yy_1 + mm_1 == yy_2 + mm_2)) || (add_month < 0 && (yy_1 + mm_1 > yy_2 + mm_2))){
    document.write("<tr>\n");
    day_2 = new Date(yy_2, mm_2 - 1, dd_2);
    mdw = (day_2.getMonth() + 1).toString() + "/" + (day_2.getDate()).toString() + "（" + Week[day_2.getDay()] + "）"
    if(zikoku2[i] == ""){
      document.write("<td width=\"84\">" + mdw + "<br>" + zikoku1[i] + "〜</td>\n");
    } else {
      document.write("<td width=\"84\">" + mdw + "<br>" + zikoku1[i] + "〜<br>" + zikoku2[i] + "〜</td>\n");
    }
    if(linkfile[i] == ""){
      if(subtitle1[i] != ""){
        if(subtitle2[i] != ""){
          document.write("<td width=\"311\">" + title[i] + "<br>" + subtitle1[i] + "<br>" + subtitle2[i] + "</td>\n");
        } else {
          document.write("<td width=\"311\">" + title[i] + "<br>" + subtitle1[i] + "</td>\n");
        }
      } else {
        document.write("<td width=\"311\">" + title[i] + "</td>\n");
      }
    } else {
      if(subtitle1[i] != ""){
        if(subtitle2[i] != ""){
          document.write("<td width=\"311\">" + "<a href=\"" + linkfile[i] + "\">" + title[i] + "</a><br>" + subtitle1[i] + "<br>" + subtitle2[i] + "</td>\n");
        } else {
          document.write("<td width=\"311\">" + "<a href=\"" + linkfile[i] + "\">" + title[i] + "</a><br>" + subtitle1[i] + "</td>\n");
        }
      } else {
        document.write("<td width=\"311\">" + "<a href=\"" + linkfile[i] + "\">" + title[i] + "</a></td>\n");
      }
    }
    if(sponsor[i] == ""){
      document.write("<td width=\"99\"><br></td>\n");
    } else {
      document.write("<td width=\"99\">" + sponsor[i] + "<br>" + tel[i] + "</td>\n");
    }
    if(fee[i] == ""){
      document.write("<td width=\"61\"><br></td>\n");
    } else {
      document.write("<td width=\"61\" style=\"text-align: center\">" + fee[i] + "</td>\n");
    }
    document.write("</tr>\n");
  }
}
