/*------------------------------
　  カレンダー自動作成 JavaScript  
  ------------------------------*/

function showCalendar(){
  var  year, today, month, startDay;
  var  date=new Date();
  var  monthdays=new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  var  days=new Array("Sun","Mon","Tue","Wed","Thr","Fri","Sat");

  year=date.getFullYear();    //西暦を返す
  today=date.getDate();       //日にちを返す
  month=date.getMonth();

  if(today>24){               //25日以降であれば次の月を表示
    if( month==11 ){
      year++;
      month=0;  //月は実際のつきより1少ない値
    }
    else{
      month++;
    }
    date.setMonth(month);
  }

//年、うるう年の設定
  if( ((year%4==0) && (year%100!=0))||(year%400==0) ){
    monthdays[1]=29;
  }
  thisMonthdays=monthdays[month];
  date.setDate(1);
  startDay=date.getDay();   //曜日をかえす

//年月表示
  document.write("<table border='0'>");
  document.write("<caption align='bottom'><img src='./order/img/pinkbox.gif' border=0 alt=''></caption>");
  document.write("<tr><th colspan='7' height='36'>");
  document.write( year, '年', month+1, '月');
  document.write("</th></tr>");

//曜日の表示
  document.write("<tr>");
  for( i=0 ; i<7 ; i++ ){
    if(i==0){
      document.write("<th width='36'><font color='red'>", days[i], "</font></th>");
    }
    else if(i==6){
      document.write("<th width='36'><font color='blue'>", days[i], "</font></th>");
    }
    else{
      document.write("<th width='36'><font color='black'>", days[i], "</font></th>");
    }
  }
  document.write("</tr>");

//日にちの表示
  document.write("<tr>");
  var col=0;
  for(i=0 ; i<startDay ; i++ ){
    document.write("<td>&nbsp;</td>");
    col++;
  }
  for( i=1 ; i<=thisMonthdays; i++ ){
    if( col==0){
      document.write("<td><font color='red'>", i, "</font></td>");
    }
    else if( col==6){
      document.write("<td bgcolor='pink'><font color='blue'>", i, "</font></td>");
    }
    else{
      document.write("<td>", i, "</td>");
    }
    col++;
    if(col==7){
      document.write("</tr><tr>");
      col=0;
    }
  }
  document.write("</tr></table>");
}