/******************************************/
/*                                        */
/* Greetings                              */
/*                                        */
/******************************************/

var mydate=new Date()
var thisYear=mydate.getFullYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
//document.write(dayarray[day]+" "+daym+"  "+montharray[month]+" "+thisYear)
//document.writeln("&nbsp;&nbsp;&nbsp;" + dayarray[day]);
//document.writeln("<br>")
//document.writeln("<br>" + "&nbsp;&nbsp;&nbsp;" +daym + "  " + montharray[month] + " " +thisYear);

/*This statement Supplies the Seasonal Greeting*/

//text1 = "Merry Christmas and a Peaceful New Year";
//var newtext1 = text1.fontcolor("white").fontsize("4pt").italics();
image0 = '<img src="Images/European_robin_taking_off.jpg" border ="0" alt ="European Robin" width="96" height="131">';
image1 = '<img src="Images/European_goldfinches.jpg" border ="0"  alt = "European Goldfinches" width="96" height="131">';
image2 = '<img src="Images/Red_knots.jpg" border ="0" alt = "Red Knot" width="100" height="91">';
image3 = '<img src="Images/Chaffinch1a.jpg" border ="0" alt = "Chaffinch in snow" width="106" height="91">';

//var current_year = thisYear;
//var count = thisYear - current_year;
//var year_mod = count%3;
// var lastYear = thisYear - 1;
var year_mod = thisYear%4;
//var year_mod_last = year_mod - 1;
//alert("Count is: " + count +" and " + "Modulus of the year is: " + year_mod );
if(  ( ( daym>17 && daym<32 ) && montharray[month]=="December" ) ) /* || 
	 ( ( daym>0 && daym<4 ) && montharray[month]=="January" ) )//&& year_mod==0 )*/
	 
	 {
		 switch(year_mod)
		 {
			 case 0: document.write('<a href = javascript:robin();>' +image0 + '</a>'); break;
			 case 1: document.write('<a href = javascript:goldfinches();>' +image1 + '</a>'); break;
			 case 2: document.write('<a href = javascript:RedKnotts();>' +image2 + '</a>'); break;
			 case 2: document.write('<a href = javascript:chaffinch();>' +image3 + '</a>'); break;
			 default : alert("Invalid image");			 
		 }
	 }
	 
/* At the turn of the year this statement reduces the year by 1,  returning the year to the previous year
maintaining the same image*/

if( (daym>0 && daym<4 ) && montharray[month]=="January" )
	{
		thisYear = thisYear - 1; //decrements the year to the previous year
		year_mod = thisYear%4;
		switch(year_mod)
		{
			 case 0: document.write('<a href = javascript:robin();>' +image0 + '</a>'); break;
			 case 1: document.write('<a href = javascript:goldfinches();>' +image1 + '</a>'); break;
			 case 2: document.write('<a href = javascript:RedKnotts();>' +image2 + '</a>'); break;
			 case 2: document.write('<a href = javascript:chaffinch();>' +image3 + '</a>'); break;
			 default : alert("Invalid image");			 
		 }		
	}
/*

{
	document.write('<a href = javascript:robin();>' +image1 + '</a>');
}
if( ( ( daym>21 && daym<32 ) && montharray[month]=="December" ) || 
	 ( ( daym>0 && daym<4 ) && montharray[month]=="January" ) && year_mod==1)
{
	document.write('<a href = javascript:goldfinches();>' +image2 + '</a>');
}
if( ( ( daym>21 && daym<32 ) && montharray[month]=="December" ) || 
	 ( ( daym>0 && daym<4 ) && montharray[month]=="January" ) && year_mod==2)
{
	document.write('<a href = javascript:RedKnotts();>' +image3 + '</a>');
}
/*
if( daym>21 && daym<32 && montharray[month]=="December")
{
	document.write(newtext1);
}

if( daym>0 && daym<4 && montharray[month]=="January")
{
	document.write(newtext1);
}
*/