var bodyCal = createEle("calendar_body");
var dayCal = createEle("calendar_day");
var footCal = createEle("calendar_foot");
var year = currDate.getFullYear();
var month = currDate.getMonth() + 1;
var day = currDate.getDate();
var ymd = year + "\u5e74" + month + "\u6708" + day + "\u65e5";
footCal.appendChild(createEle("calendar_get_today","Today: " + ymd));
}
function freshCalBody(){
clearCalBody();
freshPreviousMonth();
freshCurrentMonth();
freshNextMonth();
}
function clearCalBody(){
$("calendar_day").innerHTML = "";
}
function freshPreviousMonth(){
var firstDay = new Date(currDate.getFullYear(),currDate.getMonth(),1).getDay();
var lastDayOfPreviousMonth = new Date(currDate.getFullYear(),currDate.getMonth(),0).getDate();
var cal_day = $("calendar_day");
for(var i=lastDayOfPreviousMonth-firstDay+1; i<=lastDayOfPreviousMonth; i++){
cal_day.appendChild(createEle("",i,"grey",""));
}
}
function freshCurrentMonth(){
var cal_day = $("calendar_day");
var year = currDate.getFullYear();
var month = currDate.getMonth()+1;
var lastDay = new Date(year,month,0).getDate();
for(var i=1; i<=lastDay; i++){
if(i == new Date().getDate()){
cal_day.appendChild(createEle("",i,"red","gotoSelectedCurrDay(" + year + "," + month + "," + i + ")"));
}else{
cal_day.appendChild(createEle("",i,"","gotoSelectedCurrDay(" + year + "," + month + "," + i + ")"));
}
}
}
function freshNextMonth(){
var cal_day = $("calendar_day");
var firstDay = new Date(currDate.getFullYear(),currDate.getMonth(),1).getDay()
var lastDay = new Date(currDate.getFullYear(),currDate.getMonth()+1,0).getDate();
for(var i=1; i<=42-firstDay-lastDay; i++){
cal_day.appendChild(createEle("",i,"grey",""));
}
}
function gotoPreviousMonth(){
currDate = new Date(currDate.getFullYear(),currDate.getMonth()-1,1);
freshCalHeader();
freshCalBody();
}
function gotoNextMonth(){
currDate = new Date(currDate.getFullYear(),currDate.getMonth()+1,1);
freshCalHeader();
freshCalBody();
}
function gotoSelectedCurrDay(year,month,day){