var nowDate = new Date(); var class_uno; function showCalendar(date,class_uno,class_id,buno,tutor_id,id) { var destDate = getCalendarStringToDate(date); getCalendarTags(destDate,class_uno,class_id,buno,tutor_id,id); } function getCalendarStringToDate(strDate) { var di = new Array("-", ".", ","); var returnDate = new Date(); var arrDate; for(var i = 0 ; i < di.length; i++){ arrDate = strDate.split(di[i]); if(arrDate.length ==3){ returnDate.setYear(arrDate[0]); returnDate.setMonth(arrDate[1] - 1); returnDate.setDate(arrDate[2]); break; } } if(!isNaN(strDate) && strDate.length ==8) { returnDate.setYear(strDate.substring(0,4)); returnDate.setMonth(strDate.substring(4,6) -1); returnDate.setDate(strDate.substring(6)); } return returnDate; } function getCalendarFirstDateOfWeek(tDate) { var sunDay = new Date(); var firstDateOfMonth = new Date(); firstDateOfMonth.setYear(tDate.getFullYear()); firstDateOfMonth.setMonth(tDate.getMonth()); firstDateOfMonth.setDate(1); sunDay.setTime(dayPlus(firstDateOfMonth, firstDateOfMonth.getDay() * -1)); return sunDay; } function dayPlus(tDate,cnt) { var rtnDate = new Date(); rtnDate.setTime(tDate.getTime() + ( cnt * 24 * 60 * 60 * 1000 ) ); return rtnDate; } function getCalendarLastDate(tDate) { rtnDate = getMonthLastDay(tDate) rtnDate = dayPlus(rtnDate,6 - rtnDate.getDay()) return rtnDate; } function getMonthLastDay(tDate) { var Mon2 var rtnDate = new Date(); var arrLastDay = new Array(31,29,31,30,31,30,31,31,30,31,30,31); if(tDate.getYear() % 4 ==0) Mon2 = true; else Mon2 =false; arrLastDay[1] = (Mon2) ? 29 : 28; rtnDate.setYear(tDate.getFullYear()); rtnDate.setMonth(tDate.getMonth()); rtnDate.setDate(arrLastDay[tDate.getMonth()]); return rtnDate; } function getCalendarTags(destDate,class_uno,class_id,buno,tutor_id,id) { var arrLastDay = new Array(31,29,31,30,31,30,31,31,30,31,30,31); var strTag = ''; var destYear = destDate.getFullYear(); var destMonth = destDate.getMonth() + 1; var destDay = destDate.getDate(); var startDate = getCalendarFirstDateOfWeek(destDate); var endDate = getCalendarLastDate(destDate); var preYear = destYear - 1; var preMonth = destMonth - 1; var nextYear = destYear + 1; var nextMonth = destMonth + 1; if(preMonth <10) { preMonth = "0" + preMonth; } if(nextMonth <10) { nextMonth = "0" + nextMonth; } if(destDay <10) { destDay = "0" + destDay; } var preYear_value = preYear + '-' + destMonth + '-' + destDay; if(destMonth == 1) { var preMonth_value = preYear + '-12' + '-' + destDay; } else { var preMonth_value = destYear + '-' + preMonth + '-' + destDay; } var nextYear_value = nextYear + '-' + destMonth + '-' + destDay; if(destMonth == 12) { var nextMonth_value = nextYear + '-1' + '-' + destDay; } else { var nextMonth_value = destYear + '-' + nextMonth + '-' + destDay; } var pDate = new Date(); pDate = startDate; var yStr = String(destYear); var yimg1 = yStr.substr(0,1); var yimg2 = yStr.substr(1,1); var yimg3 = yStr.substr(2,1); var yimg4 = yStr.substr(3,1); var mStr = String(destMonth); if(mStr.length == 1) mStr = '0' + mStr; var mimg1 = mStr.substr(0,1); var mimg2 = mStr.substr(1,1); strTag = "