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(e,l,d){var p,c,a,b,k,j,q,o,m,f,n,g,h;p=e.chooseMonth.selectedIndex;c=parseInt(e.chooseYear.options[e.chooseYear.selectedIndex].text,10);if(l==null){if(typeof window.dialogArguments!="undefined"){a=window.dialogArguments}else{a=getPopArgs()}if(d){a=a.replace(/\//g,"")}l=new Date(a.substring(0,4),a.substring(4,6)-1,a.substring(6,8))}if(HYBS_CAL_START_MON){b=(getFirstDay(c,p)+6)%7}else{b=getFirstDay(c,p)}k=getMonthLen(c,p);j="";if((e.chooseYear.selectedIndex!=0)||(e.chooseMonth.selectedIndex!=0)){j="<input type='button' value='<<' onClick='changeMonth( "+c+","+(p+1)+","+l.getDate()+",-1 );' />  "}q="0"+(p+1);j=j+c+" / "+q.slice(q.length-2);if((e.chooseYear.selectedIndex!=(e.chooseYear.length-1))||(e.chooseMonth.selectedIndex!=(e.chooseMonth.length-1))){j=j+"  <input type='button' value='>>' onClick='changeMonth( "+c+","+(p+1)+","+l.getDate()+",1 );' />"}document.getElementById("tableHeader").innerHTML=j;o=1;m=document.getElementById("tableBody");while(m.rows.length>0){m.deleteRow(0)}g=false;while(!g){f=m.insertRow(m.rows.length);if(f){for(h=0;h<7;h++){n=f.insertCell(f.cells.length);if(m.rows.length==1&&h<b){n.innerHTML="&nbsp;";continue}if(o==k){g=true}if(o<=k){if(l!=null&&l.getFullYear()==c&&l.getMonth()==p&&l.getDate()==o){n.id="today"}n.innerHTML="<a href='#'onclick='chooseDate("+o+","+p+","+c+","+d+"); return false;'>"+o+"</a>";o++}else{n.innerHTML="&nbsp;"}}}else{g=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,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(){var d,b,a;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;fillYears(b);populateTable(document.dateChooser,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 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)};