// Function to pad an integer with a leading zero if it only has one digit.
function LZ(x) { return(x<0||x>9?"":"0")+x }

// Function which will return true if the current date is in Daylight Saving Time, false if not.
function isDST(now)
{
	var mth = now.getMonth()+1;
	var date = now.getDate()-0;

	if(mth > 2 && mth < 11) {
		if(mth == 3) {
			if(date > 24) return false;
			else return true;
		} else if(mth == 10) {
			if(date < 29) return false;
			else return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}

function loadPMEThumbnail() 
{
	var now=new Date();
	var offsetUTC = now.getTimezoneOffset();
	offsetUTC = offsetUTC * 60 * 1000;
	now.setTime(now.getTime()+offsetUTC);
	// 540 or 600 minutes depending on DST (9 or 10 hours) * 60 seconds * 1000 millisecions
	var offsetEST = (isDST(now)?540:600) * 60 * 1000;
	now.setTime(now.getTime() + offsetEST);
	// Now have Aus EST time.

	var year=now.getYear();
	// Mozilla defines date from 1900, IE explicitly.
	if (year < 2000) { year=1900+(year-0); }
	var month=LZ(now.getMonth()+1);
	var date=LZ(now.getDate());
	//var H=LZ(now.getHours());
	//var m=LZ(now.getMinutes());
	//var s=LZ(now.getSeconds());
	//alert(year+ " " + month + " " + date + " " + H + " " + m + " " + s);
	document.getElementById('PMEThumb').innerHTML = "<a href=\"/jsp/watl/rainfall/pme.jsp\">  <img src=\"/fwo/IDYPME03/" + year + month + date + "12/PME24_aus_thumb.png\" border=\"0\" alt=\"Preview image of forecast rainfall\"  title=\"Preview image of forecast rainfall for today\"/></a>";

}


