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] = '2010. Ianuarie';
honev[1] = '2010. Februarie';
honev[2] = '2010. Martie';
honev[3] = '2010. Aprilie';
honev[4] = '2010. Mai';
honev[5] = '2010. Iunie';
honev[6] = '2010. Iulie';
honev[7] = '2010. August';
honev[8] = '2010. Septembrie';
honev[9] = '2010. Octombrie';
honev[10] = '2010. Noiembrie';
honev[11] = '2010. Decembrie';

function getContainer()
{
	return document.getElementById( "calendar" );
}

function initCalendar( n )
{
if( n != undefined )
{
	month += n;
}

var nap = 1;

var str = "";

str += '<table class="naptarone" cellpadding="0" cellspacing="2" > <tr>';
str += '<td colspan="7" class="fejlec">';
if (honev[month]=='2010. Ianuarie')
{str +=  honev[month] + "<span style='cursor: pointer' onclick='initCalendar( 1 )'> > </span>";}
else if (honev[month]=='2010. Decembrie')
{str +=  "<span style='cursor: pointer' onclick='initCalendar( -1 )'> < </span>" + honev[month];}
else
{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="nemaktualis">Lu</td>';
str +=  '<td class="nemaktualis">Ma</td>';
str +=  '<td class="nemaktualis">Mi</td>';
str +=  '<td class="nemaktualis">Jo</td>';
str +=  '<td class="nemaktualis">Vi</td>';
str +=  '<td class="nemaktualis">Să</td>';
str +=  '<td class="nemaktualis">Du</td></tr><tr>';
for(o=0;o<tomonth[month];o++) { str +=  '<td class="nemaktualis" align="center">&nbsp;</td>' };
for(i=0;i<(7-tomonth[month]);i++){
				 if (nap == date) {
				  str +=  '<td class="aktualis">';
				  str +=  (nap++);
				  str +=  '</td>';
				 }
				else {
				  str += ('<td class="nemaktualis">');
			      str += (nap++);
		    	  str += ('</td>');
				 } 
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="aktualis">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="nemaktualis">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="nemaktualis">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="aktualis">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="nemaktualis">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="nemaktualis">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="aktualis">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="nemaktualis">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="nemaktualis">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="aktualis">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="nemaktualis">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="nemaktualis">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('<tr>');
for(i=0;i<7;i++){
				if (nap <= monthend[month]) {
						if (nap == date) {
						 str +=  ('<td class="aktualis">');
						 str +=  (nap++);
						 str +=  ('</td>');
						                 }
						else {
						 str += ('<td class="nemaktualis">');
					     str += (nap++);
		 		   	     str += ('</td>');
						 }
						}
				else {str += ('<td class="nemaktualis">&nbsp;</td>'); }
				}
str += ('</tr>');
str += ('</table>');

getContainer().innerHTML = str;
}

initCalendar();