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(d,k){var o,c,a,b,j,h,p,n,l,e,m,f,g;o=d.chooseMonth.selectedIndex;c=parseInt(d.chooseYear.options[d.chooseYear.selectedIndex].text,10);if(k==null){a=window.dialogArguments;k=new Date(a.substring(0,4),a.substring(4,6)-1,a.substring(6,8))}b=getFirstDay(c,o);j=getMonthLen(c,o);h="";if((d.chooseYear.selectedIndex!=0)||(d.chooseMonth.selectedIndex!=0)){h="<input type='button' value='<<' onClick='changeMonth( "+c+","+(o+1)+","+k.getDate()+",-1 );' />  "}p="0"+(o+1);h=h+c+" / "+p.slice(p.length-2);if((d.chooseYear.selectedIndex!=(d.chooseYear.length-1))||(d.chooseMonth.selectedIndex!=(d.chooseMonth.length-1))){h=h+"  <input type='button' value='>>' onClick='changeMonth( "+c+","+(o+1)+","+k.getDate()+",1 );' />"}document.getElementById("tableHeader").innerHTML=h;n=1;l=document.getElementById("tableBody");while(l.rows.length>0){l.deleteRow(0)}f=false;while(!f){e=l.insertRow(l.rows.length);if(e){for(g=0;g<7;g++){m=e.insertCell(e.cells.length);if(l.rows.length==1&&g<b){m.innerHTML="&nbsp;";continue}if(n==j){f=true}if(n<=j){if(k!=null&&k.getFullYear()==c&&k.getMonth()==o&&k.getDate()==n){m.id="today"}m.innerHTML="<a href='#'onclick='chooseDate("+n+","+o+","+c+"); return false;'>"+n+"</a>";n++}else{m.innerHTML="&nbsp;"}}}else{f=true}}setWinSize()}function fillYears(a){var b,d,c;b=a.getFullYear();d=document.dateChooser.chooseYear;for(c=b-1;c<b+5;c++){d.options[d.options.length]=new Option(c,c)}setCurrMonth(a)}function setCurrMonth(a){document.dateChooser.chooseYear.selectedIndex=1;document.dateChooser.chooseMonth.selectedIndex=a.getMonth()}function chooseDate(b,e,c){var f,a,d;f=c.toString();a=(e>=9)?(e+1).toString():"0"+(e+1).toString();d=(b>=10)?b.toString():"0"+b.toString();window.returnValue=f+a+d;window.close()}function initCalendar(){var c,b,a;c=window.dialogArguments;if(c==null||c.length!=8){b=new Date()}else{b=new Date(c.substring(0,4),c.substring(4,6)-1,c.substring(6,8))}window.returnValue=c;fillYears(b);populateTable(document.dateChooser,b);a=document.getElementById("calendar");a.style.visibility="visible";window.focus()}function setWinSize(){var b,a,d,c;b=document.getElementById("calendarTable");if(b){d=0;c=0;if(document.all){a=getInternetExplorerVersion();if(a<7){c=6;d=52}window.dialogWidth=b.offsetWidth+c+"px";window.dialogHeight=b.offsetHeight+d+"px"}else{do{c=b.offsetWidth-(document.documentElement.clientWidth||document.body.clientWidth);d=b.offsetHeight-(document.documentElement.clientHeight||document.body.clientHeight);window.resizeBy(c,d)}while(c>0||c>0)}}}function changeMonth(d,f,b,e){var g,c,a;g=Number(f)+e;c=d;if(g==0){g=12;c=Number(d)-1;document.dateChooser.chooseYear.selectedIndex=document.dateChooser.chooseYear.selectedIndex-1}else{if(g==13){g=1;c=Number(d)+1;document.dateChooser.chooseYear.selectedIndex=document.dateChooser.chooseYear.selectedIndex+1}}a=new Date(c,g-1,b);document.dateChooser.chooseMonth.selectedIndex=g-1;populateTable(document.dateChooser,a)};