now = new Date();
year = now.getYear();
month = now.getMonth();
date = now.getDate();
day = now.getDay();


tomonth = new Array(12);
tomonth[0] = 4;
tomonth[1] = 0;
tomonth[2] = 0;
tomonth[3] = 3;
tomonth[4] = 5;
tomonth[5] = 1;
tomonth[6] = 3;
tomonth[7] = 6;
tomonth[8] = 2;
tomonth[9] = 4;
tomonth[10] = 0;
tomonth[11] = 2;


monthend = new Array(12);
monthend[0] = 31;
monthend[1] = 28;
monthend[2] = 31;
monthend[3] = 30;
monthend[4] = 31;
monthend[5] = 30;
monthend[6] = 31;
monthend[7] = 31;
monthend[8] = 30;
monthend[9] = 31;
monthend[10] = 30;
monthend[11] = 31;

honev = new Array(12);
honev[0] = 'Január';
honev[1] = 'Február';
honev[2] = 'Marec';
honev[3] = 'Apríl';
honev[4] = 'Máj';
honev[5] = 'Jún';
honev[6] = 'Júl';
honev[7] = 'August';
honev[8] = 'September';
honev[9] = 'Október';
honev[10] = 'November';
honev[11] = 'December';




function initCalendar( n )
{
if( n != undefined )
{
	month += n;
}
var nap = 1;

var str = "";

str += '<table class="calendar" cellpadding="0" cellspacing="2" > <tr>';
str += '<td colspan="7" class="cal">';
str +=  "<span style='cursor: pointer' onclick='initCalendar( -1 )'> < </span>" + honev[month] + "<span style='cursor: pointer' onclick='initCalendar( 1 )'> > </span>" ;
str +=  '</td></tr><tr>';
str +=  '<td class="not_today">Pon</td>';
str +=  '<td class="not_today">Ut</td>';
str +=  '<td class="not_today">Str</td>';
str +=  '<td class="not_today">Stv</td>';
str +=  '<td class="not_today">Pi</td>';
str +=  '<td class="not_today">So</td>';
str +=  '<td class="not_today">Ne</td></tr><tr>';
for(o=0;o<tomonth[month];o++) { str +=  '<td class="not_today" align="center">&nbsp;</td>' };
for(i=0;i<(7-tomonth[month]);i++){
				 if (nap == date) {
				  str +=  '<td class="today">';
				  str +=  (nap++);
				  str +=  '</td>';
				 }
				else {
				  str += ('<td class="not_today">');
			      str += (nap++);
		    	  str += ('</td>');
				 } 
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="today">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="not_today">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="not_today">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="today">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="not_today">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="not_today">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="today">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="not_today">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="not_today">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="today">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="not_today">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="not_today">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="today">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="not_today">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="not_today">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('</table>');

 document.getElementById('calendar').innerHTML = str;

}

initCalendar();
