/* calendar.js */ var L = new Array(); L['Sun'] = '日'; L['Mon'] = '一'; L['Tue'] = '二'; L['Wed'] = '三'; L['Thu'] = '四'; L['Fri'] = '五'; L['Sat'] = '六'; L['prev_year'] = '前一年'; L['next_year'] = '后一年'; L['prev_month'] = '上一月'; L['next_month'] = '下一月'; var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false; function Eh(t) { var t = t ? t : 'select'; if (isIE) { var arVersion = navigator.appVersion.split("MSIE"); var IEversion = parseFloat(arVersion[1]); if (IEversion >= 7 || IEversion < 5) return; var ss = document.body.getElementsByTagName(t); for (var i = 0; i < ss.length; i++) { ss[i].style.visibility = 'hidden'; } } } function Es(t) { var t = t ? t : 'select'; if (isIE) { var arVersion = navigator.appVersion.split("MSIE"); var IEversion = parseFloat(arVersion[1]); if (IEversion >= 7 || IEversion < 5) return; var ss = document.body.getElementsByTagName(t); for (var i = 0; i < ss.length; i++) { ss[i].style.visibility = 'visible'; } } } var d_date, c_year, c_month, t_year, t_month, t_day, v_year, v_month, v_day, ca_sep, ca_id, ca_interval, ca_timeout; var today = new Date(); t_year = today.getYear(); t_year = (t_year > 200) ? t_year : 1900 + t_year; t_month = today.getMonth()+1; t_day = today.getDate(); var ca_htm = ''; ca_htm += ''; ca_htm += ''; ca_htm += '
  « »    « » × 
'; ca_htm += '
'; function get_days (year, month) { d_date = new Date(year, month, 1); d_date = new Date(d_date - (24*60*60*1000)); return d_date.getDate(); } function get_start (year, month) { d_date = new Date(year, month-1, 1); return d_date.getDay(); } function ca_setInterval(func) { ca_timeout=setTimeout(function(){ca_interval=setInterval(func+'()',200);},100); } function ca_clearInterval () { clearTimeout(ca_timeout);clearInterval(ca_interval); } function ca_this_year () { if(document.getElementById('ca_year').value.match(/^(\d{4})$/)) { c_year = parseInt(document.getElementById('ca_year').value); ca_setup(c_year, c_month); } else { document.getElementById('ca_year').value = c_year; } } function ca_next_year () {c_year = parseInt(c_year) + 1; ca_setup(c_year, c_month);} function ca_prev_year () {c_year = parseInt(c_year) - 1; ca_setup(c_year, c_month);} function ca_this_month () { if(document.getElementById('ca_month').value.match(/^(\d{1,2})$/)) { c_month = parseInt(document.getElementById('ca_month').value); ca_setup(c_year, c_month); } else { document.getElementById('ca_month').value = c_month; } } function ca_next_month () { if(c_month == 12) { c_year = parseInt(c_year) + 1; c_month = 1; } else { c_month = parseInt(c_month) + 1; } ca_setup(c_year, c_month); } function ca_prev_month () { if(c_month == 1) { c_year = parseInt(c_year) - 1; c_month = 12; } else { c_month = parseInt(c_month) - 1; } ca_setup(c_year, c_month); } function ca_setup(year, month) { if(year > 9999) year = 9999; if(year < 1970) year = 1970; if(month > 12) month = 12; if(month < 1) month = 1; c_year = year; c_month = month; var days = get_days(year, month); var start = get_start(year, month); var end = 7 - (days + start)%7; if(end == 7 ) end = 0; var calendar = ''; var weeks = [L['Sun'],L['Mon'],L['Tue'],L['Wed'],L['Thu'],L['Fri'],L['Sat']]; var cells = new Array; var j = i = l = 0; document.getElementById('ca_year').value = year; document.getElementById('ca_month').value = month; if(start) for(i = 0; i < start; i++) {cells[j++] = 0;} for(i = 1; i<= days; i++) {cells[j++] = i;} if(end) for(i = 0; i < end; i++) {cells[j++] = 0;} calendar += ''; for(i = 0; i < 7; i++) {calendar += '';} calendar += ''; l = cells.length for(i = 0; i < l; i++) { if(i%7 == 0) calendar += ''; if(cells[i]) { calendar += ''; } else { calendar += ''; } if(i%7 == 6) calendar += ''; } calendar += '
'+(weeks[i])+'
'+cells[i]+'  
'; document.getElementById('d_ca_show').innerHTML = calendar; } function ca_show(id, obj, sep) { Eh(); if(document.getElementById('d_calendar') == null) { var d_ca_div = document.createElement("div"); with(d_ca_div.style) {zIndex = 9999; position = 'absolute'; display = 'none'; width = '196px'; padding = '1px'; top = 0; left = 0; border = '#A0A0A0 1px solid'; backgroundColor = '#FFFFFF';} d_ca_div.id = 'd_calendar'; document.body.appendChild(d_ca_div); } var aTag = obj; var leftpos = toppos = 0; do {aTag = aTag.offsetParent; leftpos += aTag.offsetLeft; toppos += aTag.offsetTop; } while(aTag.offsetParent != null); ca_sep = sep; ca_id = id; if($(id).value) { if(sep) { var arr = document.getElementById(id).value.split(sep); c_year = v_year = arr[0]; c_month = v_month = ca_cutzero(arr[1]); v_day = ca_cutzero(arr[2]); } else { c_year = v_year = document.getElementById(id).value.substring(0, 4); c_month = v_month = ca_cutzero(document.getElementById(id).value.substring(4, 6)); v_day = ca_cutzero(document.getElementById(id).value.substring(6, 8)); } } else { c_year = t_year; c_month = t_month; } document.getElementById('d_calendar').style.left = (obj.offsetLeft + leftpos) + 'px'; document.getElementById('d_calendar').style.top = (obj.offsetTop + toppos + 20) + 'px'; document.getElementById('d_calendar').innerHTML = ca_htm; document.getElementById('d_calendar').style.display = ''; ca_setup(c_year, c_month); } function ca_select(year, month, day) { month = ca_padzero(month); day = ca_padzero(day); document.getElementById(ca_id).value = year+ca_sep+month+ca_sep+day; ca_hide(); } function ca_padzero(num) {return (num < 10)? '0' + num : num ;} function ca_cutzero(num) {return num.substring(0, 1) == '0' ? num.substring(1, num.length) : num;} function ca_hide() {document.getElementById('d_calendar').style.display = 'none'; Es();} function ca_close() {ca_hide();}