













function getBirthdayListWeek( month , day , mode_flag ){
    oWeek = new Array( "(日)","(月)","(火)","(水)","(木)","(金)","(土)" );
    nowDate = new Date();
    var year = nowDate.getFullYear();
    var month_tmp = month -1;

    if( month_tmp < nowDate.getMonth() ){
      year = year + 1;
    }

    oDate = new Date( year ,
      month_tmp ,
      day );
    if ( mode_flag ) {
      document.write( oWeek[ oDate.getDay() ] );
    } else {
      return oWeek[ oDate.getDay() ];
    }

}

function getBirthdayListMonthName( month ){
    oMonth = new Array( "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" );
    return oMonth[ month - 1 ];
}

function BirthdayUsrList( month ){
  var birth_day
  var blog_url
  var usr_name

  var usr_array = new Array();

  if( month == 1 ){
  
    return usr_array;
  }

  if(month == 2){
  
    return usr_array;
  }

  if(month == 3){
  
    return usr_array;
  }

  if(month == 4){
  
    return usr_array;
  }

  if(month == 5){
  
    return usr_array;
  }

  if(month == 6){
  
    return usr_array;
  }

  if(month == 7){
  
    return usr_array;
  }

  if(month == 8){
  
    return usr_array;
  }
  if(month == 9){
  
    return usr_array;
  }
  if(month == 10){
  
      
      usr_array.push( {
        'birth_day' : "10" ,
        'blog_url'  : "/taiju/" ,
        'usr_name'  : "福岡大樹ライオンズクラブ" 
      } );
  
    return usr_array;
  }
  if(month == 11){
  
    return usr_array;
  }
  if(month == 12){
  
    return usr_array;
  }
}

function switch_list( month ){
  var oBirthdayListDiv = document.getElementById("birthday_list");

  oBirthdayListDiv.innerHTML = "";

  if ( oBirthdayListDiv.hasChildNodes() ) {
    for (i = 0; i < oBirthdayListDiv.childNodes.length ;i++){
      oBirthdayListDiv.removeChild(oBirthdayListDiv.childNodes[i]);
    }
  }

  var oDiv = document.createElement('div');

  oDiv.className ='section birthday';

  var oH2 = document.createElement('h2');
  oH2.innerHTML = month + "月誕生日一覧";
  oDiv.appendChild( oH2 );

  var oDiv_sectionbody = document.createElement('div');
  var birth_day = 0;
  var usrs = BirthdayUsrList( month );
  var oDl  = document.createElement('dl');
  for( var i in usrs ){
    if(birth_day != usrs[i].birth_day){
      var oDt = document.createElement('dt');
      oDt.innerHTML = month + "月" + usrs[i].birth_day + "日" + getBirthdayListWeek( month, usrs[i].birth_day ,0 );
      oDl.appendChild(oDt);
      birth_day = usrs[i].birth_day;
    }

    var oDd = document.createElement('dd');

    oDd.innerHTML = "<a href='" + usrs[i].blog_url + "'> " + usrs[i].usr_name + "</a>";
    oDl.appendChild(oDd);
  }
  
  oDiv_sectionbody.className ='sectionBody';

  var oTable = createBirthdayListMonthTable( month , 0);

  oDiv_sectionbody.appendChild( oTable );

  if( !usrs.length ){
    var oMessage  = document.createElement('p');
    oMessage.innerHTML = "登録されていません。";
    oDiv_sectionbody.appendChild(oMessage);
  }

  oDiv_sectionbody.appendChild( oDl );

  oDiv.appendChild( oDiv_sectionbody );

  oBirthdayListDiv.appendChild(oDiv);
}

function createBirthdayListMonthTable( month, mode_flag ){
  var oTable = document.createElement('table');
  var oTr    = document.createElement('tr');
  var oTbody = document.createElement('tbody');

  oTbody.appendChild(oTr);
  oTable.appendChild(oTbody);

  for (i = 1 ; i <= 12 ; i++){
    var oTd = document.createElement('td');

    if(month == i){
      oTd.className = "nowBirthdayMonth";
    }
    var oA = document.createElement('a');
    oA.href = "javascript:switch_list(" + i + ")";
    oA.innerHTML = getBirthdayListMonthName(i);

    oTd.appendChild( oA );
    oTr.appendChild( oTd );

    if( i % 6 == 0 && i != 12 ){
      oTr = document.createElement('tr');

      oTbody.appendChild(oTr);
      oTable.appendChild( oTbody );
    }
  }

  var oDiv = document.createElement('div');
  oDiv.appendChild( oTable );

  if(mode_flag){
    document.writeln( oDiv.innerHTML );
  } else {
    return oTable;
  }
}

