	
		// array to hold month names for showing the answer to fourth Thursday with named months
	monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	function findFourth(form)
	{		
		var suffix;	
		testDate = new Date() // this will hold the information the user inputs
		ourDate = new Date()  // this is for comparison purposes for the sack of the language used; it is today.
		var tdim = "will be";	//set time dimension grammar to the future, the most likely enquiry...
		// First we check to make sure the input is valid for the working of the idea...
		// test entry for Month
		if (isNaN(form.month.value)) // if the entry is "Not a Number"...
		{
				alert("The entry for Month must be an integer between '1' and '12'. Please enter such an integer.")
				form.month.select()
				return;
		}
		if (form.month.value > 12 | form.month.value < 1) //if entry is a number but outside acceptable range...
		{
				alert("The value for the month may not be greater than 12 nor less than 1. Please enter a value between 1 and 12.")
				form.month.select()
				return;
		}	
		testDate.setMonth(form.month.value - 1); // OK, the input is valid so set Month from input. In Javascript months are counted from '0', so subtract 1.
						
	// test entry for Year
		if (isNaN(form.year.value)) //if entry is Not a Number...
		{
				alert("The value for Year must be an integer between 1582 and 9999. Please re-enter an acceptable value for 'Year'.")
				form.year.select()
				return;
		}
		if (form.year.value < 1582) //if entry is before introduction of the "modern" calendar...
		{
				alert("This reckoning only works since the introduction of the modern (Gregorian) calendar (~1582). Therefore only dates after that will be calculated. Please enter a year of at least 1582.")
				form.year.select()
				return;
		}	
		// OK, entry is valid so set Year from input
		testDate.setFullYear(form.year.value);
		
		// Now we work on the use of English... tense and suffixes...
		// The fourth Thursday MUST be between the 22nd and the 28th, so...						
		for(var i = 22; i < 29; i++)
		{
			// set the Date to the present value of the counter variable i
			testDate.setDate(i);   // we test each possible day (22 - 29) looking for one that _is_ a Thursday...

			if (testDate.getDay() == 4)	// If that date would produce a Thursday (==4, the day in the week (starting with Monday)) in that year...
			{
				// adjust the suffix for proper English usage
				if (testDate.getDate() == 22)
				{
					suffix = "nd"
				}
				else if (testDate.getDate() == 23)
				{
					suffix = "rd"
				}
				else
				{
					suffix = "th"
				}
					// and now a new interior 'if' starts...
				if (testDate.getFullYear() < ourDate.getFullYear()) // the year selected is in the past
				{
		                	tdim = "was"  
		        }
		        else if (testDate.getFullYear() == ourDate.getFullYear()) // the year is this year, but what about the month?
		        {
		             if (testDate.getMonth() < ourDate.getMonth()) // if the month is earlier, it is past tense
		             {
		                tdim = "was";
		             }	
					 else if (testDate.getMonth() == ourDate.getMonth()) // the month is this month, but what about the day?
					 {	
						if(testDate.getDate() < ourDate.getDate()) // the day was earlier: it's past tense
						{	
							tdim = "was"
						}
						else if (testDate.getDate() == ourDate.getDate())  // it's today! say so
						{
							tdim = "is today,"
						} //anything else we haven't covered must be in the future and tdim's default value is 'will be'
					}   // end of a severally nested 'else if'		
				}	// end of a less nested 'else if'

				// Show the result
				alert("The fourth Thursday in " + monthNames[testDate.getMonth()] + " " + testDate.getFullYear() + " " + tdim +" the " + i + suffix);

				// discontinue the function; we've already got our answer
				return;
			}	// end of the 'if' that tested whether the testDate was a Thursday
		} //end of the for loop
	
	} // end of the function
