/*  avoea/simplecal.js */
function calendar(){
 var current = new Date();
 var month = current.getMonth();
 var day = current.getDate();
 var year = current.getFullYear();
 tempMonth = month +1;
 firstday=1;
var tempDate = new Date(year,month,firstday); // 
// integer (nonstring) is new Date(yr,mo,da); string is quoted new Date("monthname,day,year");
// var tempDate = new Date(tempMonth +' 1 ,'+year); // ff ok, not IE6,7 ie says NaN
// this was totally breaking IE
 var tempweekday= tempDate.getDay(); //what day of the week is the first day of the month?
 var tempweekday2 = tempweekday;
 var calendarTable;
 if ( (year%100!=0) && (year%4==0) || (year%400==0)){
   var totalFeb = 29;
  }else{
   var totalFeb = 28;
  }

 var totalDays = ["31", ""+totalFeb+"","31","30","31","30","31","31","30","31","30","31"];

var padding= "";
while (tempweekday > 0) {
 padding += "<td class='premonth'></td>";// &nbsp; make cell higher than needed
 tempweekday--;
}
dayAmount = totalDays[month];
i = 1; // not 0
 while (i <= dayAmount){
  if (tempweekday2 > 6){ 
   tempweekday2 = 0;
   padding += "</tr><tr>";
  }

  if (i == day){
   padding +="<td id='curday' class='currentday'>"+i+"</td>";
  }else{
   padding +="<td class='currentmonth'>"+i+"</td>";	
  }

  tempweekday2++;
  i++;
 }

 var monthNames = ["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov", "Dec"];

 var calendarTable = "<table id='lilcal' class='calendar round' border=0  > <tr id='curmon' class='currentmonth'><th colspan='7'>"+monthNames[month]+" "+ year +"</th></tr>";
calendarTable+="<tbody>";
 calendarTable +="<tr class='weekdays'>  <td>Sun</td>  <td>Mon</td> <td>Tue</td> <td>Wed</td> <td>Thu</td> <td>Fri</td> <td>Sat</td> </tr>";
 calendarTable += "<tr>";
 calendarTable += padding;
 calendarTable += "</tr></tbody></table>";
//window.status='cal done...';
calobj=document.getElementById('cal');
//calobj.style.border='1px solid orange';
//calobj.style.backgroundColor='#ffffb7';
calobj.style.fontFamily='verdana,arial';
calobj.innerHTML=calendarTable;

lc=document.getElementById('lilcal');
lc.style.fontSize='70%';
lc.style.textAlign='center';
lc.style.border='1px solid orange';
lc.style.backgroundColor='#ffffb7';
cm=document.getElementById('curmon');
cm.style.color='#0000ff';
cm.style.textAlign='center';
cd=document.getElementById('curday');
cd.style.border='1px solid black';
cd.style.color='#0000ff';
}
/* Style information
#cal {border:0px solid black;width:auto;padding:4px;height:auto;}

.calendar {xbackground:#ffffb7;border:1px solid orange;font-family:verdana,arial;}
.calendar {background: url(gradien99.gif);}
.currentmonth{
 color: blue;
 text-align: center;
 font-size:75%;
}
.weekdays {
 color:black;
 text-align:center;
 font-size:75%;
 }
 .currentday{
 border: 1px solid black;
 color: #00FF00;
 text-align: center;
 font-size:75%;
}
*/
