	var i = 0;
	var Language = 'Italian';

function calendar()
{
//	if ( !isDiv(where)) return;
	var colors	= new Array("wheat","peachpuff","navajowhite","antiquewhite","beige","bisque","blanchedAlmond","CornSilk","Linen");
	var d		= new Date();
	var nDay		= d.getDate();				//	Day
	var nYear		= d.getFullYear();			//	Year
	var cDOW		= DayName(d.getDay());		//	Name of day of week (custom)
	var cMonth	= MonthName(d.getMonth());	//	Name of month (custom)
	var cTime		= strZero( d.getHours(),2,0) + ':' + strZero( d.getMinutes(),2,0) + ':' + strZero( d.getSeconds(),2,0);
/*
	var t = "<table border=5 bgcolor=(COLOR) width=90 height=120>"+
		"<tr><td>"+"<p align=center>"+"<font color=blue size=+3>"+nYear+
		"<tr><td>"+"<p align=center>"+"<font size=-1>"+
			cMonth+"<br>"+"<font color=red size=+3>"+nDay+"</font><br>"+cDOW+
		"<tr><td><p align=center>"+cTime+"</table>";
*/
	if ( calendar.i == undefined )
		calendar.i=0;
	else
		calendar.i = (calendar.i+1) % colors.length;	//	Rotate color
	var t = "<table border=5 bgcolor=" + colors[calendar.i] + " width=90 height=120>"+
		"<tr><td align=center style='color:blue'>"+"<font size=+3>"+nYear+
		"<tr><td align=center>"+"<font size=-1>"+
			cMonth+"<br>"+"<font color=red size=+3>"+nDay+"</font><br>"+cDOW+
		"<tr><td align=center>"+cTime+"</table>";
	t.output('calend');
}
function isDiv(div)
{
	var o, l;
	if ( typeof div == 'object' )
		if ( div.tagName == 'DIV' )
			div=div.id;			
	if ( typeof div != 'string' ) div = '';
	o = document.getElementById( div);
	l = Boolean(o);
	if (l) l = ( l && o['tagName']=='DIV' );
	return l;
}
function divName(div)
{
	if ( typeof div == 'object' )
	{
		if ( Boolean(div))
			if ( div.tagName == 'DIV' )	//	NEW	accepts a DIV element
				div=div.id;
	}
	else if ( typeof div != 'string' ) div = '';
	if ( isDiv(div) )
		return div;
	else	return '';
}
function output(div,s)				//	Scrive la stringa "s" nella "div"
{
	if ( typeof(div) == 'object' && div['tagName']=='DIV' )	//   solo se "div"
	{
		if ( typeof(s) != 'string' ) s = s.toString();	//   stringa comunque
		if ( document.all )
			div.innerHTML = s;		//   Explorer
		else
		{
			div.document.write(s);	//	Netscape
			div.document.close();
		}
	}
}
function stringa(s)				//	Assicura che "s" sia una stringa
{
	if ( typeof(s) != 'string' ) s = s + '';
	return s;
}
function log(x,b)					//	Logaritmo in base b
{
	x = numero(x);
	b = numero(b);
	if ( b <= 0 || b == 1 ) b = Math.E;
	return Math.log(x) / Math.log(b);
}
function AllNumeric(s)				//	Stringa numerica
{
	var re = /^\d+$/;				//	^ = inizio stringa; \d+ = solo cifre; $ = fine stringa
	s = stringa(s)
	return re.test(s);
}
function replicate(s,n)				//	Restituisce la stringa "s" ripetuta "n" volte
{
	var c, i;
	s = stringa(s);
	n = numero(n);
	for ( c = '', i = 1; i <= n; i++ ) c = c + s;
	return c;
}
function space(n)					//	Restituisce "n" spazi
{
	return replicate( ' ', numero(n));
}
/*
function padr(s,n,c)				//	Allunga "s" fino a "n" caratteri usando "c" (default BLANK)
{
	s = stringa(s);
	n = numero(n);
	if ( typeof(c) == 'undefined' || typeof(c) != 'string' ) c = ' ';
	while ( s.length < n ) s = s + c;
	return s;
}
function padl(s,n,c)				//	Come prima ma i caratteri sono aggiunti a sinistra
{
	s = stringa(s);
	n = numero(n);
	if ( typeof(c) == 'undefined' || typeof(c) != 'string' ) c = ' ';
	while ( s.length < n ) s = c + s;
	return s;
}
function padc(s,n,c)				//	Come prima ma la stringa risulta centrata
{
	s = stringa(s);
	n = numero(n);
	if ( typeof(c) == 'undefined' || typeof(c) != 'string' ) c = ' ';
	return padl( padr( s,( n - s.length ) / 2, c), n, c);
}
*/
function parentheses(s)				//	Mette "s" tra parentesi (convertendo comunque in stringa)
{
	s = stringa(s);
	return '(' + s + ')';
}
function ex(x)					//	Visualizza la variabile "x" (usando ";" al posto degli spazi)
{
	var ex = parentheses( x);
	return ex.replace(/\s/g,':');		//	\s = single whitespace; g = global
}
function str(n,p,d)				//	Restituisce il numero "n" su "p" posizioni, con "d" decimali
{
	var c, punto, inizio, i;
	d = numero(d);
	p = numero(p); if ( !p ) p = 10;
	if ( typeof(n)+typeof(p)+typeof(d) != replicate('number',3) )
		c = '';
	else
	{
		c = n.toString();
		punto = c.search(/[.]/);
		inizio = 0;
		if (punto)
			inizio = c.length - punto - 1;
		else
			c = c + '.';
		for ( i = inizio + 1; i <= d; i++ ) c = c + '0';	//	Aggiunge i decimali
		c = c.padl(p);								//	Spazi iniziali per completare la lunghezza
	}
	return c;
}
function strZero(n,p,d)				//	Come prima, ma include gli zeri non significativi
{
	var x = str(n,p,d), re, meno;
	n = numero(n);
	if ( n < 0 )
	{
		meno = x.indexOf('-');		//	Per i negativi, porta il "-" all'inizio
		if ( meno >= 0 )
		{
			re = new RegExp( space(meno)+'-');
			x = x.replace(re,'-'+space(meno));
		}
	}
	return x.replace(/\s/g,'0');		//	Zeri al posto dei BLANK
}
function trunc(n)					//	Parte intera di un numero
{
	var c;
	if ( typeof(n) != 'number' )
		c = 0;
	else
		c = n >= 0 ? Math.floor(n) : Math.ceil(n);
	return c;
}
function DayName(DayNumber)
{
	var Day=new Array();
	if ( typeof( Language) == 'undefined' || Language.toLowerCase() == 'english' )
	{
		Day[0]="Sunday";
		Day[1]="Monday";
		Day[2]="Tuesday";
		Day[3]="Wednesday";
		Day[4]="Thursday";
		Day[5]="Friday";
		Day[6]="Saturday";
	}
	else
	{
		Day[0]="Domenica";
		Day[1]="Lunedì";
		Day[2]="Martedì";
		Day[3]="Mercoledì";
		Day[4]="Giovedì";
		Day[5]="Venerdì";
		Day[6]="Sabato";
	}
	return Day[DayNumber];
}
function MonthName(MonthNumber)
{
	var Month=new Array();
	if ( typeof( Language) == 'undefined' || Language.toLowerCase() == 'english' )
	{
		Month[ 0]="January";	
		Month[ 1]="February";
		Month[ 2]="March";
		Month[ 3]="April";
		Month[ 4]="May";
		Month[ 5]="June";
		Month[ 6]="July";
		Month[ 7]="August";
		Month[ 8]="September";
		Month[ 9]="October";
		Month[10]="November";
		Month[11]="December";
	}
	else
	{
		Month[ 0]="Gennaio";
		Month[ 1]="Febbraio";
		Month[ 2]="Marzo";
		Month[ 3]="Aprile";
		Month[ 4]="Maggio";
		Month[ 5]="Giugno";
		Month[ 6]="Luglio";
		Month[ 7]="Agosto";
		Month[ 8]="Settembre";
		Month[ 9]="Ottobre";
		Month[10]="Novembre";
		Month[11]="Dicembre";
	}
	return Month[MonthNumber];
}
function resto( dividendo, divisore)
{
	var r;
	dividendo = numero(dividendo);
	divisore = numero(divisore);
	if ( ! divisore )
		r = 0;
	else
	{
		dividendo = Math.floor( Math.abs(dividendo));
		divisore = Math.floor( Math.abs(divisore));
		r = dividendo - Math.floor( dividendo / divisore ) * divisore;
	}
	return r;
}
/*
	L'epatta è l'età della luna (in giorni) al "giorno zero" dell'anno
*/
function epatta( anno)
{
	var e;
	anno = numero(anno);
	if ( anno <= 1582 )
		e = ( 8 + anno % 19 * 11 ) % 30;
	else	e = ( 38 + anno % 19 * 11 - trunc( anno / 100 ) + trunc( anno / 400 ) + trunc( ( 8 * trunc( anno / 100 ) + 13 ) / 25 ) ) % 30;
		   // 38 per avere epatta > 0 anche in anni tipo 1957 che danno risultato < 0
	return e;
}
/*
   Calcolo della data di Pasqua in un anno qualsiasi.
   Essa e' la prima domenica dopo il plenilunio pasquale, che a sua volta
   e' la prima luna piena a partire dal 21 marzo, equinozio di primavera.
   Eccezioni gregoriane: se dal calcolo risulta Pasqua il 26 aprile, si
   celebra il 19; se risulta il 25 aprile e il resto della divisione
   dell'anno per 19 risulta maggiore di 10 allora si celebra il 18.
   La prima eccezione serve a non far cadere la Pasqua dopo il 25 aprile,
   la seconda serve a diversificare i calcoli nel periodo (metonico) di 19 anni.

   alcune date:
   20/04/1924
   12/04/1925
   29/03/1282
   13/04/1327

	1970		1980		1990		2000		2010
0	29/03	06/04	15/04	23/04	04/04
1	11/04	19/04	31/03	15/04	24/04
2	02/04	11/04	19/04	31/03	08/04
3	22/04	03/04	11/04	20/04	31/03
4	14/04	22/04	03/04	11/04	20/04
5	30/03	07/04	16/04	27/03	05/04
6	18/04	30/03	07/04	16/04	27/03
7	10/04	19/04	30/03	08/04	16/04
8	26/03	03/04	12/04	23/03	01/04
9	15/04	26/03	04/04	12/04	21/04
*/
function pasqua(a)
{
	a = numero(a);
	var d = new Date( a, 2, 21, 0, 0, 0, 0);					//	Equinozio di primavera (marzo=2)
	d.setHours(0);
	d.setDate( d.getDate() + ( 29 - ( epatta(a) + 6 ) % 30 ));	//	Plenilunio primaverile
	d.setDate( d.getDate() + ( 7 - d.getDay()));					//	Domenica successiva
	if ( a > 1582 && d.getMonth() == 3 )						//	In aprile (mese = 3):
		if ( d.getDate() > 25 )								//	- non puo' superare il 25
			d.setDate( d.getDate() - 7 );						//	- altra eccezione per il 25
		else	if ( d.getDate() == 25 && d.getFullYear() % 19 > 10 )
				d.setDate( 18);
	return d;
}
function allchars(s)
{
	var i, x='';
	s = stringa(s);
	for ( i=0; i<s.length; i++) x+= ex(i)+ex(s.charAt(i))+ex(s.charCodeAt(i)) + ( i==s.length-1?'':' ');
	return x;
}
function indexOf(s,sub,n)		//	Restituisce posizione n.a ricorrenza di "sub" in "s"
{
	var i,p;
	s = stringa(s);
	sub = stringa(sub);
	n = numero(n);
	if ( !n ) n = 1;
	for ( p=-1, i=1; i <= n; i++ ) p = s.indexOf(sub,p+1);
	return p;
}
