("TD");
for (var i=0;i<tds.length;i++){
if (tds(i) != object){
tds(i).style.backgroundColor = tds(i).bgcolor;
tds(i).style.color = ""
}else{
tds(i).style.backgroundColor = "navy";
tds(i).style.color = "white";
}
}
}
function selectDate(){
var i = parseInt(window.event.srcElement.innerText);
if ((!isNaN(i)) && (i<3000)){
hightLightDate(window.event.srcElement);
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
sendEvent();
}
}
function moveDate(){
var k = window.event.keyCode;
switch(k){
case 37:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-1);
break;
case 38:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-7);
break;
case 39:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+1);
break;
case 40:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+7);
break;
}
date.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate());
fillCalendar(date);
sendEvent();
}
function setActiveDate(){
var i = activeDate.getDate();
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
while ((date.getMonth() != activeDate.getMonth()) || (date.getFullYear() != activeDate.getFullYear())){
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i--);
}
sendEvent();
}
function goNextMonth(){
date.setMonth(date.getMonth()+1,1);
setActiveDate();
fillCalendar(date);
}
function goNextYear(){
date.setFullYear(date.getFullYear()+1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
function goPriorYear(){
date.setFullYear(date.getFullYear()-1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
function goPriorMonth(){
date.setMonth(date.getMonth()-1,1);
setActiveDate();
fillCalendar(date);
}
//---------------------------------------------------------------------
var tbl = window.document.createElement("<TABLE style="border:solid 1px;width:100%;height:100%;font-size:9pt" cellspacing=0>");
var tblhd = window.document.createElement("THEAD");
var tblbd = window.document.createElement("TBODY");
var anchorPriorYear = window.document.createElement("A");
anchorPriorYear.style.fontFamily = "webdings";
anchorPriorYear.style.cursor = "hand";
anchorPriorYear.innerText = "7";
anchorPriorYear.title = "上一年";
var anchorPriorMonth = window.document.createElement("A");
anchorPriorMonth.style.fontFamily = "webdings";
anchorPriorMonth.style.cursor = "hand";
anchorPriorMonth.innerText = "3";
anchorPriorMonth.title = "上一月";
var anchorNextMonth = window.document.createElement("A");
anchorNextMonth.style.fontFamily = "webdings";
anchorNextMonth.style.cursor = "hand";
anchorNextMonth.innerText = "4";
anchorNextMonth.title = "下一月";
var anchorNextYear = window.document.createElement("A");
anchorNextYear.style.fontFamily = "webdings";
anchorNextYear.style.cursor = "hand";
anchorNextYear.innerText = "8";
anchorNextYear.title = "下一年";
var ynm = window.document.createElement("FONT");
ynm.style.width = "60%";
ynm.style.fontWeight = "bold";
var cpt = window.document.createElement("CAPTION");
tbl.appendChild(cpt);
tbl.appendChild(tblhd);
tbl.appendChild(tblbd);
function inithead(){
cpt.style.backgroundColor = "navy";
cpt.style.color = "white";
cpt.style.textAlign = "center";
cpt.style.cursor = "defalut";
cpt.appendChild(anchorPriorYear);
cpt.appendChild(anchorPriorMonth);
cpt.appendChild(ynm);
cpt.appendChild(anchorNextMonth);
cpt.appendChild(anchorNextYear);
var row = tblhd.insertRow();
row.align = "center";
var weekStr = new Array("日","一","二","三","四","五","六");
for (var i=0;i<weekStr.length;i++){
var cell = row.insertCell();
cell.innerText = weekStr[i];
cell.style.borderBottom = "solid 1px";
cell.style.cursor = "default";
cell.align = "center";
}
}
function initbody(){
for (var i=0;i<6;i++){
var row = tblbd.insertRow();
for (var j=0;j<7;j++){
var cell = row.insertCell();
cell.innerHTML = " ";
cell.style.cursor = "default";
cell.align = "center";
}
}
}
function init(){
inithead();
initbody();
element.appendChild(tbl);
fillCalendar(date);
tblbd.attachEvent("onclick",selectDate);
tblbd.attachEvent("onkeydown",moveDate);
anchorPriorYear.attachEvent("onclick",goPriorYear);
anchorPriorMonth.attachEvent("onclick",goPriorMonth);
anchorNextMonth.attachEvent("onclick",goNextMonth);
anchorNextYear.attachEvent("onclick",goNextYear);
sendEvent();
}
</script>
for (var i=0;i<tds.length;i++){
if (tds(i) != object){
tds(i).style.backgroundColor = tds(i).bgcolor;
tds(i).style.color = ""
}else{
tds(i).style.backgroundColor = "navy";
tds(i).style.color = "white";
}
}
}
function selectDate(){
var i = parseInt(window.event.srcElement.innerText);
if ((!isNaN(i)) && (i<3000)){
hightLightDate(window.event.srcElement);
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
sendEvent();
}
}
function moveDate(){
var k = window.event.keyCode;
switch(k){
case 37:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-1);
break;
case 38:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-7);
break;
case 39:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+1);
break;
case 40:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+7);
break;
}
date.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate());
fillCalendar(date);
sendEvent();
}
function setActiveDate(){
var i = activeDate.getDate();
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
while ((date.getMonth() != activeDate.getMonth()) || (date.getFullYear() != activeDate.getFullYear())){
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i--);
}
sendEvent();
}
function goNextMonth(){
date.setMonth(date.getMonth()+1,1);
setActiveDate();
fillCalendar(date);
}
function goNextYear(){
date.setFullYear(date.getFullYear()+1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
function goPriorYear(){
date.setFullYear(date.getFullYear()-1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
function goPriorMonth(){
date.setMonth(date.getMonth()-1,1);
setActiveDate();
fillCalendar(date);
}
//---------------------------------------------------------------------
var tbl = window.document.createElement("<TABLE style="border:solid 1px;width:100%;height:100%;font-size:9pt" cellspacing=0>");
var tblhd = window.document.createElement("THEAD");
var tblbd = window.document.createElement("TBODY");
var anchorPriorYear = window.document.createElement("A");
anchorPriorYear.style.fontFamily = "webdings";
anchorPriorYear.style.cursor = "hand";
anchorPriorYear.innerText = "7";
anchorPriorYear.title = "上一年";
var anchorPriorMonth = window.document.createElement("A");
anchorPriorMonth.style.fontFamily = "webdings";
anchorPriorMonth.style.cursor = "hand";
anchorPriorMonth.innerText = "3";
anchorPriorMonth.title = "上一月";
var anchorNextMonth = window.document.createElement("A");
anchorNextMonth.style.fontFamily = "webdings";
anchorNextMonth.style.cursor = "hand";
anchorNextMonth.innerText = "4";
anchorNextMonth.title = "下一月";
var anchorNextYear = window.document.createElement("A");
anchorNextYear.style.fontFamily = "webdings";
anchorNextYear.style.cursor = "hand";
anchorNextYear.innerText = "8";
anchorNextYear.title = "下一年";
var ynm = window.document.createElement("FONT");
ynm.style.width = "60%";
ynm.style.fontWeight = "bold";
var cpt = window.document.createElement("CAPTION");
tbl.appendChild(cpt);
tbl.appendChild(tblhd);
tbl.appendChild(tblbd);
function inithead(){
cpt.style.backgroundColor = "navy";
cpt.style.color = "white";
cpt.style.textAlign = "center";
cpt.style.cursor = "defalut";
cpt.appendChild(anchorPriorYear);
cpt.appendChild(anchorPriorMonth);
cpt.appendChild(ynm);
cpt.appendChild(anchorNextMonth);
cpt.appendChild(anchorNextYear);
var row = tblhd.insertRow();
row.align = "center";
var weekStr = new Array("日","一","二","三","四","五","六");
for (var i=0;i<weekStr.length;i++){
var cell = row.insertCell();
cell.innerText = weekStr[i];
cell.style.borderBottom = "solid 1px";
cell.style.cursor = "default";
cell.align = "center";
}
}
function initbody(){
for (var i=0;i<6;i++){
var row = tblbd.insertRow();
for (var j=0;j<7;j++){
var cell = row.insertCell();
cell.innerHTML = " ";
cell.style.cursor = "default";
cell.align = "center";
}
}
}
function init(){
inithead();
initbody();
element.appendChild(tbl);
fillCalendar(date);
tblbd.attachEvent("onclick",selectDate);
tblbd.attachEvent("onkeydown",moveDate);
anchorPriorYear.attachEvent("onclick",goPriorYear);
anchorPriorMonth.attachEvent("onclick",goPriorMonth);
anchorNextMonth.attachEvent("onclick",goNextMonth);
anchorNextYear.attachEvent("onclick",goNextYear);
sendEvent();
}
</script>