function getFirstDay(c,a){var b=new Date(c,a,1);return b.getDay()}function getMonthLen(c,a){var b=new Date(c,a+1,1);b.setHours(b.getHours()-3);return b.getDate()}function populateTable(A,h,e,l){var f,m,B,q,y,v,n,r,j,a,o,s,w;var y=new Array(h);var r=new Array(h);var q=new Array(h);var b=new Array(h);var z=new Array(h);var d;f=A.getMonth();m=A.getFullYear();var c=new Date();var t=document.getElementById("tableHaderMonth");t.innerHTML=m+" / "+("0"+(f+1)).slice(-2);var p=document.getElementById("tableHeaderLink");var u="<a href='#' class='movelink' onClick='changeMonth( "+m+","+(f+1)+","+A.getDate()+",-12,"+h+","+e.getFullYear()+","+e.getMonth()+","+e.getDate()+");return false;'>&lt;&lt;</a>";u+="<a href='#' class='movelink' onClick='changeMonth( "+m+","+(f+1)+","+A.getDate()+",-1,"+h+","+e.getFullYear()+","+e.getMonth()+","+e.getDate()+");return false;'>&lt;</a>";u+="<a href='#' class='movelink' onClick='changeToday("+h+","+e.getFullYear()+","+e.getMonth()+","+e.getDate()+");'>今日</a>";u+="<a href='#' class='movelink' onClick='changeMonth( "+m+","+(f+1)+","+A.getDate()+",1,"+h+","+e.getFullYear()+","+e.getMonth()+","+e.getDate()+");return false;'>&gt;</a>";u+="<a href='#' class='movelink' onClick='changeMonth( "+m+","+(f+1)+","+A.getDate()+",12,"+h+","+e.getFullYear()+","+e.getMonth()+","+e.getDate()+");return false;'>&gt;&gt;</a>";p.innerHTML=u;var x=Math.floor(h/2);f-=x;if(f<0){f+=12;m-=1}if(A==null){if(typeof window.dialogArguments!="undefined"){B=window.dialogArguments}else{B=getPopArgs()}if(l){B=B.replace(/\//g,"")}A=new Date(B.substring(0,4),B.substring(4,6)-1,B.substring(6,8))}for(w=0;w<h;w++){if(w==0){b[w]=m;z[w]=f}else{if(z[w-1]<11){b[w]=b[w-1];z[w]=z[w-1]+1}else{b[w]=b[w-1]+1;z[w]=0}}if(HYBS_CAL_START_MON){q[w]=(getFirstDay(b[w],z[w])+6)%7}else{q[w]=getFirstDay(b[w],z[w])}y[w]=getMonthLen(b[w],z[w]);v="";n="0"+(z[w]+1);v=n.slice(n.length-2)+"月";if(w==0){document.getElementById("tableHeader").innerHTML=v}else{document.getElementById("tableHeader"+w).innerHTML=v}r[w]=1}j=document.getElementById("tableBody");while(j.rows.length>0){j.deleteRow(0)}s=false;d=0;while(!s){a=j.insertRow(j.rows.length);if(a){for(k=0;k<h;k++){for(w=0;w<7;w++){o=a.insertCell(a.cells.length);o.className+=" cell";if(w==6&&k!=h-1){o.className+=" cell-right"}if(j.rows.length==1&&w<q[k]){o.innerHTML="&nbsp;";continue}if(r[k]==y[k]){d+=1;if(d==h){s=true}}if(r[k]<=y[k]){var g=new Date(b[k],z[k],r[k]);if(g.getDay()==0||g.getDay()==6){o.className+=" holiday"}if(c.getFullYear()==b[k]&&c.getMonth()==z[k]&&c.getDate()==r[k]){o.className+=" now"}if(A!=null&&e.getFullYear()==b[k]&&e.getMonth()==z[k]&&e.getDate()==r[k]){o.id="basic"}o.innerHTML="<a href='#'onclick='chooseDate("+r[k]+","+z[k]+","+b[k]+","+l+"); return false;'>"+r[k]+"</a>";r[k]++}else{o.innerHTML="&nbsp;"}}}}else{s=true}}setWinSize()}function chooseDate(b,f,c,d){var g,a,e;g=c.toString();a=(f>=9)?(f+1).toString():"0"+(f+1).toString();e=(b>=10)?b.toString():"0"+b.toString();if(d){rtnPopup(g+"/"+a+"/"+e)}else{rtnPopup(g+a+e)}if(typeof window.dialogArguments!="undefined"){window.close()}}function initCalendar(e){var d,b,a;var e=typeof e!="undefined"?e:1;d=getPopArgs();var c=(d.indexOf("/")>=0);if(c){d=d.replace(/\//g,"")}if(d==null||d.length!=8){b=new Date()}else{b=new Date(d.substring(0,4),d.substring(4,6)-1,d.substring(6,8))}window.returnValue=d;populateTable(b,e,b,c);a=document.getElementById("calendar");a.style.visibility="visible";window.focus()}function setWinSize(){var b,a,e,d;b=document.getElementById("calendarTable");if(b){e=0;d=0;if(document.all){a=getInternetExplorerVersion();if(a<7){d=6;e=52}window.dialogWidth=b.offsetWidth+d+"px";window.dialogHeight=b.offsetHeight+e+"px"}else{var c=10;do{d=b.offsetWidth-(document.documentElement.clientWidth||document.body.clientWidth);e=b.offsetHeight-(document.documentElement.clientHeight||document.body.clientHeight);window.resizeBy(d,e);c--}while((d>0||d>0)&&c>0)}}}function changeToday(e,f,d,c){var b=new Date();var a=new Date(f,d,c);populateTable(b,e,a)}function changeMonth(f,d,g,i,m,b,j,e){var l,a,h;l=Number(d)+i;a=f;if(l<=0){l=12+l;a=Number(f)-1}else{if(l>=13){l=l-12;a=Number(f)+1}}h=new Date(a,l-1,g);var c=new Date(b,j,e);populateTable(h,m,c)};