//var cal_style = '"color: #000000; font-size: 7pt; font-family:verdana; letter-spacing: 1pt;"';  // calendar style parameters

var cal_style = '"color: #000000; font-size: 9px; font-family:verdana; letter-spacing: 0px;"';  // calendar style parameters

var hlight_style = '"background-color: #4169ff; color:#ffff00; font-weight: bold; border: solid #ff0000; border-width:1;"';  // highlighted cell style parameters

//var cal_bgcolor = '#A4CE3C';        // calendar background color

var cal_bgcolor = '#CAEAFF';        // calendar background color

var nr_week_bgcolor = '#F4CA44';    // weekday background color

var wday_bgcolor = '#c0c0c0';       // weekday background color

//var bars_bgcolor = '#C1D6EC';       // background color of top & bottom bars

var bars_bgcolor = '#CAEAFF';       // background color of top & bottom bars

var cell_size = 8;                 // size of each cell

var bars_height = 5;               // top & bottom height bars

var lang = 0;                       // set language, 0=magyar

//  SET ARRAYS FOR DIVERSE LANGUAGES



var day_of_week = new Array()



day_of_week[0] = new Array('H','K','SZ','CS','P','SZ','V');











var month_of_year = new Array()



month_of_year[0] = new Array



('Január','Február','Március','Április','Május','Június','Július','Augusztus','Szeptember','Október','November','December');







var current_daya = new Array('. nap');



var current_dayb = new Array(' az évben');



var week = new Array('Hét');







//  DECLARE AND INITIALIZE GLOBAL VARIABLES



var Calendar = new Date();



var year = Calendar.getYear();	      // Returns year



if ( year < 1000 ) { year += 1900; }  // Correction for 2 digit year format



var month = Calendar.getMonth();      // Returns month (0-11)



var today = Calendar.getDate();       // Returns day (1-31)



var weekday = Calendar.getDay();      // Returns weekday (0-6)







var nowepoc = Date.UTC(year,month,today+1,0,0,0);    // getting current day from epoc, millisec 







// CONVERTING FOR ISO (european) FORMAT



weekday = weekday-1



if (weekday < 0) { weekday = 6; }



// END CONVERTING FOR ISO (european) FORMAT







var num_OF_cols = 8;                 // number of table's columns



var DAYS_OF_WEEK = num_OF_cols - 1;  // days of week



var DAYS_OF_MONTH = 31;              // max number of days in a month



var cal;                             // Used for printing



var flag=0;











Calendar.setDate(1);    // Start the calendar day at '1'



Calendar.setMonth(month);    // Start the calendar month at now











 // GETTING ISO FORMAT WEEK INFO







	unomese = Date.UTC(year,month,2,0,0,0);    // getting first day of current month - epoc, millisec



	unogen = Date.UTC(year,0,1,0,0,0);         // getting first day of january current year - epoc, millisec







	var unogennaio = new Date();



	unogennaio.setYear(year);



	unogennaio.setMonth(0);



	unogennaio.setDate(1);



	gsett1gennaio = unogennaio.getDay();       // getting weekday of january firstday current year







var startfirstweek = 0;



var numyeardays = (nowepoc-unogen)/86400000;   // getting today number of days since january firstday 



var numdays1mnth = (unomese-unogen)/86400000;  // getting number of days from month firstday since january firstday 



var nOfWk = 0;







 // OFFSET WEEKDAY FOR ISO FORMAT



if ( gsett1gennaio == 1 ) {startfirstweek = 1;}



if ( gsett1gennaio == 0 ) {startfirstweek = 2;}



if ( gsett1gennaio == 6 ) {startfirstweek = 3;}



if ( gsett1gennaio == 5 ) {startfirstweek = 4;}



if ( gsett1gennaio == 4 ) {startfirstweek = 5;}



if ( gsett1gennaio == 3 ) {startfirstweek = 6;}



if ( gsett1gennaio == 2 ) {startfirstweek = 7;}











// nr. weeks at begining of month 



if ( gsett1gennaio > 4 || gsett1gennaio == 0 && month == 0) { nOfWk = ""; } else { nOfWk =  1; }







if (month != 0) { nOfWk = Math.floor((numdays1mnth-startfirstweek)/7)+1; }







//var nOWeeks =  Math.floor((numyeardays-startfirstweek)/7)+1;                 // today nr. of weeks 















var nOWeeks =  Math.floor((numyeardays-startfirstweek)/7)+2;                 // today nr. of weeks 















 // END GETTING ISO FORMAT WEEK INFO







 // OTHER VARIABLES







var TR_start = '<TR>';



var TR_end = '</TR>';



var highlight_start = '<TD WIDTH='+cell_size+' align="center" style='+hlight_style+'>';



var highlight_end   = '</B></font></TD>';



var TD_start = '<TD WIDTH='+cell_size+' align=right>';



var TD_start_set = '<TD WIDTH='+cell_size+' bgcolor='+nr_week_bgcolor+' align=center>';



var highlight_start_set = '<TD WIDTH='+cell_size+' align="center" style='+hlight_style+'>';



var highlight_set_end   = '</B></FONT></TD>';



var TD_dayw = '<TD WIDTH='+cell_size+' bgcolor='+wday_bgcolor+' align=center>';



var TD_highlight_dayw = '<TD WIDTH='+cell_size+' align="center" style='+hlight_style+'>';



var TD_end = '</TD>';







/* BEGIN CODE FOR CALENDAR



NOTE: some minor changes can be set here 



to customize your calendar's look.*/







cal =  '<TABLE bgcolor='+cal_bgcolor+' BORDER=0 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=#0000ff><TR><TD>';



cal += '<TABLE border=2px bordercolor=#CAEAFF cellspacing=0 cellpadding=3 style='+cal_style+'>' + TR_start;



cal += '<TD height='+bars_height+' COLSPAN='+ num_OF_cols +' BGCOLOR='+bars_bgcolor+' style="border: solid #CAEAFF; border-width: 1;" align="center"><B>';











//cal +=  month_of_year[lang][month] + ' ' + year + '</B>' + TD_end + TR_end;







cal +=  month_of_year[lang][month] + '</B>' + '<br>' + TD_end + TR_end;











cal +=  TR_start + TD_start_set + week[lang] + TD_end;







//   NOTHING TO EDIT BELOW THIS POINT, BUT YOU CAN EXPERIMENT IF YOU WISH :-)  //







// LOOPS FOR EACH DAY OF WEEK



for(index=0; index < DAYS_OF_WEEK; index++)



{







// BOLD TODAY'S DAY OF WEEK



if(weekday == index)



cal += TD_highlight_dayw + day_of_week[lang][index] + TD_end;







// PRINTS DAY



else



cal += TD_dayw + day_of_week[lang][index] + TD_end;



}







cal += TR_end;







// CONVERTING FOR ISO (european) FORMAT



var giornosett = Calendar.getDay()-1;



if (giornosett < 0) { giornosett = 6; }







var weekdayflag = giornosett;  // set variable to use for filling last row blank cell







   // SETS HEAD OF ROW FOR WEEK STARTING WITH AT LEAST A BLANK GAP AND NUMBER OF WEEK



if ( giornosett != 0 ) { cal += TR_start;







if ( nOWeeks == nOfWk ) {







cal += highlight_start_set + nOfWk + highlight_set_end;  // HIGHLIGHT TODAY'S NUMBER OF WEEKS







} else { cal += TD_start_set + nOfWk + TD_end; }        // PRINTS ORDINARY TODAY'S NUMBER OF WEEKS







} // END IF CONDITION THAT SETS HEAD OF ROW...







// FILL IN BLANK GAPS UNTIL TODAY'S DAY



for(idx=0; idx < giornosett; idx++)



{ cal += TD_start + '&nbsp;' + TD_end; }







// LOOPS FOR EACH DAY IN CALENDAR



for(index=0; index < DAYS_OF_MONTH; index++)



{



if( Calendar.getDate() > index )     // this condition stops writing day number for month shorter of 31 days



{



  // RETURNS THE NEXT DAY TO PRINT



  week_day = giornosett;







  // START NEW ROW FOR FIRST DAY OF WEEK



  if(week_day == 0)



{ cal += TR_start;







if ( nOWeeks == nOfWk ) {







cal += highlight_start_set + nOfWk + highlight_set_end;  // HIGHLIGHT TODAY'S NUMBER OF WEEKS







} else { cal += TD_start_set + nOfWk + TD_end; }        // OR PRINTS ORDINARY TODAY'S NUMBER OF WEEKS







 }  // END IF CONDITION OF NEW ROW FOR FIRST DAY OF WEEK







  // SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES



  var day  = Calendar.getDate();







  // HIGHLIGHT TODAY'S DATE



  if( today == Calendar.getDate() )



{ cal += highlight_start + day + highlight_end + TD_end;



flag++;



  // OR PRINTS ORDINARY DAY



}  else { cal += TD_start + day + TD_end; flag++;}







 }    // end if condition that stops month shorter of 31 days











  // INCREMENTS UNTIL END OF THE MONTH



  Calendar.setDate(Calendar.getDate()+1);











// CONVERTING FOR ISO (european) FORMAT



giornosett = Calendar.getDay()-1;



if (giornosett < 0) { giornosett = 6; }



// END CONVERTING FOR ISO (european) FORMAT















idx++;



if ( idx > 6 ) { idx = 0; nOfWk++; }







} // end for loop











// FILLING LAST ROW BLANK CELL



var blanks = 7 - ((flag + weekdayflag) % 7);



if ( blanks == 7 ) { blanks = 0; }







for (i=0; i<blanks; i++)



{ cal += TD_start + '&nbsp;' + TD_end; }







cal += '</TR><TR><TD height='+bars_height+' COLSPAN="'+ num_OF_cols +'" BGCOLOR='+bars_bgcolor+' style="'+cal_style+' border:solid #CAEAFF;border-width:10;" align=center><b>';







//cal += current_daya[lang] + numyeardays + current_dayb[lang];







cal += numyeardays + current_daya[lang] + current_dayb[lang];











cal += '</B></TD></TR></TABLE></TD></TR></TABLE>';







//  PRINT CALENDAR



document.write(cal);
