function days_lap(date1,date2) {
    var difference =
        Date.UTC(date1.getFullYear(),date1.getMonth(),date1.getDate(),0,0,0)
      - Date.UTC(date2.getFullYear(),date2.getMonth(),date2.getDate(),0,0,0);
    return difference/1000/60/60/24;
}

function hb1() {
    var     okt_mese   = 9
    var     okt_giorno = 22
    var     okt_durata = 15
    // ^^^^^^^^^^^^^^^^^^^^^^^^ cambiare solo queste vars
    
	var now = new Date()
	var okt = new Date( now.getFullYear() , okt_mese-1 , okt_giorno )
	var lap = days_lap ( okt, now )
    
    if ( lap < -okt_durata ) {
        okt = new Date( 1+now.getFullYear() , okt_mese-1 , okt_giorno )
        lap = days_lap ( okt, now )
    }

	p = document.getElementById( "mancano" );

	c = Math.random();
    if ( lap > 0 ) {
        if( c > 0.6 )	p.innerHTML = "secondo me, mancano grossomodo " + lap + " giorni all' oktoberfest";			else
        if( c > 0.3 )	p.innerHTML = "vi ricordo, cari amici, che tra " + lap + " giorni DOVETE partire per monaco";	else
                        p.innerHTML = lap + " giorni... solo " + lap + " giorni...";
    } else {
        p.innerHTML = "è cominciato l' Oktoberfest !!"
    }

	setTimeout( "hb1()", 60000 );
}

function lerp3fv( a, b, t ) {
	var c = new Array(3);
	c[0] = a[0] + t * (b[0] - a[0]);
	c[1] = a[1] + t * (b[1] - a[1]);
	c[2] = a[2] + t * (b[2] - a[2]);
	return c;
}

function hb2() {
	p = document.getElementById( "mancano" );
	with( Math ) {
		M2PI = 2 * PI;
		t = (new Date().getTime() % 20000) * M2PI / 20000;
		t = sin( t ) * 0.5 + 0.5;
		c = lerp3fv( a, b, t );
		p.style.color  = "rgb("+round(255*c[0])+","+round(255*c[1])+","+round(255*c[2])+")";
	}
	setTimeout( "hb2()", 1000/10 );
}

var	a = new Array( 1,1,1 );
var	b = new Array( 0.6,0.8,1 );

hb1();
hb2();


