
// ----------------------------------------------------------------------
//  (C) 2005 J. Kreiss  All Rights Reserved  [ jkreiss@web-centric.net ]
//    HERCVLE SI HOC SINE PERMISSV VSVS ERIS PRVNAS PRO IENTACVLO EDES
// ----------------------------------------------------------------------



var month = [ "IAN", "FEB", "MAR", "APR", "MAI", "IVN", "IVL", "AVG", "SEP", "OCT", "NOV", "DEC", "IAN" ];
var mlength  = [ 31,    28,    31,    30,    31,    30,    31,    31,    30,    31,    30,    31 ];
var nonae    = [  5,     5,     7,     5,     7,     5,     7,     5,     5,     7,     5,     5 ];
var idus     = [  13,    13,    15,   13,    15,    13,    15,    13,    13,    15,    13,    13 ];

var nundina = [ "A", "B", "C", "D", "E", "F", "G", "H" ];

/*
var h_roman = new Array();
h_roman[0][9] = "AGON&middot;I";
h_roman[0][11] = "CAR&middot;I";
h_roman[0][15] = "CAR&middot;V";
h_roman[1][15] = "LVPER&middot;";
h_roman[1][17] = "QVIR&middot;";
h_roman[1][21] = "FERA&middot;";
h_roman[1][23] = "TERM&middot;";
h_roman[1][24] = "REGIF&middot;";
h_roman[1][27] = "EQVIR&middot;I";
h_roman[2][14] = "EQVIR&middot;II";
h_roman[2][17] = "LIBER&middot;";
h_roman[2][19] = "QVIN&middot;";
h_roman[2][23] = "TVBIL&middot;";
h_roman[2][24] = "Q&middot;R&middot;C&middot;F";
h_roman[3][15] = "FORDI&middot;";
h_roman[3][19] = "CERIA&middot;";
h_roman[3][21] = "PARIL&middot;";
h_roman[3][23] = "VINAL&middot;";
h_roman[3][25] = "ROBIG&middot;";
h_roman[4][9] = "LEM&middot;III";
h_roman[4][11] = "LEM&middot;V";
h_roman[4][13] = "LEM&middot;VII";
h_roman[4][21] = "AGON&middot;II";
*/


var dies = new Array();
dies[0] = new Array();
dies[1] = new Array();
dies[2] = new Array();
dies[3] = new Array();
dies[4] = new Array();
dies[5] = new Array();
dies[6] = new Array();
dies[7] = new Array();
dies[8] = new Array();
dies[9] = new Array();
dies[10] = new Array();
dies[11] = new Array();

dies[1][7] = "VIR&middot;";
dies[2][25] = "D&middot;DE&AElig;";
dies[3][15] = "SCAM&middot;";
dies[4][18] = "NAT&middot;MOL&middot;";
dies[5][8] = "MANVS";
dies[5][9] = "V&middot;MAG&middot;";
dies[5][12] = "V&middot;MAI&middot;";
dies[6][16] = "FOR&middot;";
dies[6][18] = "NVNT&middot;";
dies[6][21] = "X&middotF&middot;";
dies[7][9] = "NAT&middot;G&middot;A&middot;";
dies[8][27] = "COB&middot;";
dies[9][24] = "TAT&middot";
dies[10][15] = "NAT&middot;HIST&middot;";
dies[10][26] = "FIL&middot;";
dies[11][10] = "ORI&middot;";
dies[11][19] = "ELEG&middot;";

/*
dies[3][14] = "C&middot;S&middot;";

*/










var today = new Date();

// adjust for leap years
if( today.getFullYear() % 4 == 0 )
	mlength[2] = 29;


/* for testing
var m;
var d;
for( m = 0 ; m < 12 ; m++ ) {
	document.write("<p>");
	for( d = 1 ; d < 32 ; d++ ) {
		var today = new Date( 2005, m, d, 0, 0, 0, 0 );
*/


// find the day of the year ( 1 - 365 )
var daynum = 0;
for( i = 0 ; i < today.getMonth() ; i++ )
	daynum += mlength[i];
daynum += today.getDate();



//document.write( nundina[ daynum % 8 ] );




var dayname;

if( today.getDate() == 1 )
	dayname = "KAL&middot;" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() < nonae[ today.getMonth() ] - 1 )
	dayname = 
		to_roman_numerals( nonae[ today.getMonth() ] - today.getDate() + 1 ) +
		"&middot;NON&middot;" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() == nonae[ today.getMonth() ] - 1 )
	dayname = "PR&middot;NON&middot" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() == nonae[ today.getMonth() ] )
	dayname = "NON&middot;" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() < idus[ today.getMonth() ] - 1 )
	dayname = 
		to_roman_numerals( idus[ today.getMonth() ] - today.getDate() + 1 ) +
		"&middot;ID&middot;" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() == idus[ today.getMonth() ] - 1 )
	dayname = "PR&middot;ID&middot" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() == idus[ today.getMonth() ] )
	dayname = "IDVS" + month[ today.getMonth() ] + "&middot;";

else if( today.getDate() < mlength[ today.getMonth() ] )
	dayname = 
		to_roman_numerals( mlength[ today.getMonth() ] - today.getDate() + 2 ) +
		"&middot;KAL&middot;" + month[ today.getMonth() + 1 ] + "&middot;";

else if( today.getDate() == mlength[ today.getMonth() ] )
	dayname = "PR&middot;KAL&middot" + month[ today.getMonth() + 1 ] + "&middot;";


if( dies[ today.getMonth() ][ today.getDate() ] != null )
	dayname = dies[ today.getMonth() ][ today.getDate() ];



document.write( dayname + "<br />" );



/* for testing loop  }} */





//document.write( "G&middot;V&middot;BVSH" + to_roman_numerals( today.getFullYear() - 2000 ) );


















function to_roman_numerals( n ) {
 var place;
 var temp;
 var answer = "";


 temp = Math.floor( n / 1000 );
 for( i = 0 ; i < temp ; i++ )
	answer += "M";
 n -= temp * 1000


 place = Math.floor( n / 100 );
 temp = place;
 if( temp == 9 )
	answer += "CM";
 else if( temp == 4 )
	answer += "CD";
 else {
	if( temp >= 5 ) {
		answer += "D";
		//alert( temp );
		temp -= 5;
		//alert( temp );
	}
	for( i = 0; i < temp ; i++ )
		answer += "C";
 }
 n -= place * 100;



 place = Math.floor( n / 10 );
 temp = place;
 if( temp == 9 )
	answer += "XC";
 else if( temp == 4 )
	answer += "XL";
 else {
	if( temp >= 5 ) {
		answer += "L";
		temp -= 5;
	}
	for( i = 0; i < temp ; i++ )
		answer += "X";
 }
 n -= place * 10;



 place = Math.floor( n / 1 );
 temp = place;
 if( temp == 9 )
	answer += "IX";
 else if( temp == 4 )
	answer += "IV";
 else {
	if( temp >= 5 ) {
		answer += "V";
		temp -= 5;
	}
	for( i = 0; i < temp ; i++ )
		answer += "I";
 }





 return answer;
}



