//deal with months
for (var i=1; i<=lastDayOfMonth; i++)
{
//insert a <br> every 7 days
if ((i % 5) == 1)
{
calendarDiv.appendChild(document.createElement('br'));
}
//create the button
dateButton[i] = document.createElement('button');
dateButton[i].value = i;
dateButton[i].id = "calButton";
dateButton[i].onclick = function(){dateClicked(dateButton[i].value);};
//create the text for the button and add it to the button
dateButtonTxt[i] = document.createTextNode(i);
dateButton[i].appendChild(dateButtonTxt[i]);
//add the button to the calendar div.
calendarDiv.appendChild(dateButton[i]);
}