var mnam=new Array("Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień");
function cal_insert(id,m,y){
t="
";
for(i=1;i<13;i++){
t=t+""+mnam[i-1];
}
t=t+" ";// ";
t=t+"";
for(i=2013;i<=2028;i++)
t=t+""+i;
t=t+" ";
t=t+"Pn Wt Śr Cz Pt So Nd ";
for( r=0;r<6;r++ ){
t=t+"";
for( c=0;c<7;c++ ){
t=t+"a ";
}
t=t+" ";
}
t=t+"
";
document.write(t);
if( m && m>0 && m<13 )
m=m-1;
else {
d=new Date();
m=d.getMonth();
}
m=document.getElementById("mnth").selectedIndex=m;
document.getElementById("caly").value=y;
chg_month();
}
function chg_month(){
m=document.getElementById("mnth").value;
y=document.getElementById("caly").value;
dat=new Date();
//dat.setMonth(m-1);
//dat.setDate(1);
dat.setFullYear(y,m-1,1);
week_day=dat.getDay()-1;
if( week_day<0 )week_day=6;
if( m==1 )maxd_prev=31;
else
maxd_prev=days_in_month(m-1,y);
maxd=days_in_month(m,y);
t_cal=document.getElementById("tcal");
count=0;day=0;outday=0;
py=y;ny=y;pm=m-1;nm=parseInt(m)+1;
if( m==1 ){py--;pm=12;}
if( m==12 ){ny++;nm=1;}
if( m<10 )m="0"+m;
if( pm<10 )pm="0"+pm;
if( nm<10 )nm="0"+nm;
for( r=0; r<6; r++ ){
for( c=0; c<7; c++ ){
if( count < week_day ){
pday=maxd_prev+count-week_day+1;
t_cal.rows[r+2].cells[c].innerHTML="" + pday + " ";
}
if( count >= week_day && day <=maxd )
t_cal.rows[r+2].cells[c].innerHTML="" + day + " ";
if( day >=maxd+1 ){
day++;
t_cal.rows[r+2].cells[c].innerHTML="" + outday + " ";
}
//else
// t_cal.rows[r+2].cells[c].innerHTML="";
count++;
}
// if( day>=maxday )continue;
}
}
function days_in_month(m,y){
if( m==2 ){
d=new Date();
d.setFullYear( y, m-1, 29 )
if( d.getDate()==29 )return 29;else return 28;
}
if( m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
return 31;
else
return 30;
}