// This is used by weekly climate watch pages

var now = new Date();
		 
year0 = now.getYear();
//alert("year0="+year0);

if (year0 < 1000)
	year0 = year0 + 1900;
	
month0 = now.getMonth();
date0 = now.getDate();
 
month = month0;
year = year0;
date = date0;

month--;  // display last month and older data
if (date<0)  // only until past 10th of this month
	month--;

if (month<0) {
	month = month + 12;
	year--;
}
		 

//alert("year="+year+" month="+month+" date="+date);

Years = new Array();
Years.length = 0;
for(count = 0; count < year-1999; count++)
	Years[count] = 2000 + count;

Months = new Array("January","February","March","April","May","June","July",
 "August","September","October","November","December");        
 
		 
// browser specific
if (navigator.appName == "Netscape") {
	mnhili = document.monthlyhighlights;
	rcntmaps = document.recentmaps;
} else {
	mnhili = document.all.monthlyhighlights;
	rcntmaps = document.all.recentmaps;
}
		
initializeForm()
//getlink()

function initializeForm() {

	// fill first form
	mnhili.Year.length = 0;
//alert("Years.length="+Years.length);
	for(count = 0; count < Years.length; count++) {
		if (count == year - 2000) {  // set current year as default
			mnhili.Year.options[count] = new Option(Years[count],"",1,1);
			mnhili.Year.options[count].selected = 1;
//alert("default Year="+Years[count]);
		} else {
			mnhili.Year.options[count] = new Option(Years[count],"",0,0);
			mnhili.Year.options[count].selected = 0;
//alert("Year="+Years[count]);
		}
	}
//alert("mnhili.Year.selectedIndex="+mnhili.Year.selectedIndex);
	fillMonths();
	
}

function fillMonths()	{
	mnhili.Month.length=0;
//alert("Months.length="+Months.length);
//alert("mnhili.Year.selectedIndex="+mnhili.Year.selectedIndex);
	for(count = 0; count < Months.length; count++) {
		if ( mnhili.Year.selectedIndex == year - 2000)
			if ( month == count) {  // show recent month as default for current year
				mnhili.Month.options[count] = new Option(Months[count],"",1,1);
				mnhili.Month.options[count].selected = 1;
				break;
			} else
				mnhili.Month.options[count] = new Option(Months[count],"");
		else
			if ( count == 0 ) { // show first month as default for past years
				mnhili.Month.options[count] = new Option(Months[count],"",1,1);
				mnhili.Month.options[count].selected = 1;
			} else
				mnhili.Month.options[count] = new Option(Months[count],"");
	}
}
		
function getlink()
{
	var linkot;
	
	if (mnhili.Year.selectedIndex<10)
		yy = "0" + mnhili.Year.selectedIndex;
	else
		yy = mnhili.Year.selectedIndex;
		
	if (mnhili.Month.selectedIndex+1<10)
		mm = "0" + (mnhili.Month.selectedIndex + 1);
	else
		mm = mnhili.Month.selectedIndex + 1;
			
	linkto = "../"+yy+mm+"/climwatch."+yy+mm+".htm";

	return linkto;
}

