var FB_nb_day_delay = 0;

function fillDate(){
	
	var nbm = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
		
	build_year_select();
   
	MD = new Date();
			
	nday = MD.getDate();
	aday = MD.getDay();
	amois = MD.getMonth();
	ayear = takeYear(MD);
	cur_year = ayear;
			
	nday += FB_nb_day_delay;

	if(nday > nbm[amois])
	{   		
		nday -= nbm[amois];
		amois++;
		if(amois > 11) { 
			ayear++;
			amois = 0;
		} 
	}
		
	indexDay = nday - 1;
	indexMois = amois;
	indexYear = ayear - cur_year;
		
	if(indexDay < 0 || indexDay > 30)
		indexDay = 0;
	if(indexMois < 0 || indexMois > 11)
		indexMois = 0;
	if(indexYear < 0 || indexYear > 1)
		indexDay = 0;

 //document.getElementByName("days").selectedIndex = indexDay;
document.Book.days.selectedIndex = indexDay;
document.Book.months.selectedIndex = indexMois;
document.Book.years.selectedIndex = indexYear;

}
fillDate();
// build year select
function build_year_select() {
		
var cur_date = new Date();

var cur_year = takeYear(cur_date);

cur_y = new Option(cur_year, cur_year, true, true);
document.Book.years.options[0] = cur_y;
if(document.Book.years != null) {
	cur_yb = new Option(cur_year, cur_year, true, true);
	document.Book.years.options[0] = cur_yb;
}
	
}
function takeYear(theDate)
{
        x = theDate.getYear();
        var y = x % 100;
        y += (y < 38) ? 2000 : 1900;
        return y;
}
