/* JavaScript to automatically update a web page at a certain time on a certain date

Created 21/06/2006
*/

/*

An example of using my code is to write in the HTMl:

<script> 
<!--
event(10,2,8,0,2,5,21,30,"Whatever you want to output");
-->
</script>

This will output "Whatever you want to output", from the 10th(10) of February(2) at 8am (8:00)
until the 2nd May at 9:30pm (21:30). 

Here are the function callings explained a bit more.

event(start day of the month, start month, start time hours, start time minutes, end day of the month, end month, end time hours, end time minutes "The text in speach marks");


**************************************************
Remember to put a semi-colon - ; - after each line!
***************************************************

*/

var theDate = new Date();

function event( start_day, start_month, start_time_hrs, start_time_mins, end_day, end_month, end_time_hrs, end_time_mins, String )
{	/*a funcatiuon to check the current date and time are within the given limits and then print the string if it is*/
	
	if ( (theDate.getMonth() < (start_month-1)) )
	{ /* if too early, don't do anything*/
		
		return 1;
	}
	
	
	
	if( ((theDate.getMonth() >= (start_month-1))) ) /* is the month greater than the month before the start month? */
	{	
		if( (theDate.getMonth() == (start_month-1)) ) /* is it the start month? */
		{
			if( (start_month != end_month) )
			{
				if( (theDate.getDate() == (start_day)) )
				{
					if( (theDate.getHours() == (start_time_hrs)) )
					{
						if( (theDate.getMinutes() >= (start_time_mins)) )
						{
							document.write(String);
							return 1;
						}
					}
					if( (theDate.getHours() > (start_time_hrs)) )
					{
						document.write(String);
						return 1;
					}
				}
				if( (theDate.getMonth() == (start_month-1)) )
				{
					if( (theDate.getDate() > (start_day)) )
					{
						document.write(String);
						return 1;
					}
				}
			}
			
			if( (start_month == end_month) )
			{
				if( (theDate.getDate() >= (start_day)) && (theDate.getDate() <= (end_day)) )
				{
					if( (start_day != end_day) )
					{
						if( (theDate.getDate() == (start_day)) )
						{
							if( (theDate.getHours() == (start_time_hrs)) )
							{
								if( (theDate.getMinutes() >= (start_time_mins)) )
								{
									document.write(String);
									return 1;
								}
							}
							else if( (theDate.getHours() > (start_time_hrs)) )
							{
								document.write(String);
								return 1;
							}
						}
						if( (theDate.getDate() > (start_day)) )
						{
							if( (theDate.getDate() < (end_day)) )
							{
								document.write(String);
								return 1;
							}
							if( (theDate.getDate() == (end_day)) )
							{
								if( (theDate.getHours() < (end_time_hrs)) )
								{
									document.write(String);
									return 1;
								}
								if( (theDate.getHours() == (end_time_hrs)) )
								{
									if( (theDate.getMinutes() < (end_time_mins)) )
									{
										document.write(String);
										return 1;
									}
									else
									{
										return 1;
									}
								}
							}
						}
					}
					if( (start_day == end_day) )
					{
						if( (theDate.getHours() >= (start_time_hrs)) )
						{
							if( (theDate.getMinutes() >= (start_time_mins)) )
							{
								if( (theDate.getHours() < (end_time_hrs+1)) )
								{
									document.write(String);
									return 1;
								}
								if( (theDate.getHours() == (end_time_hrs)) )
								{
									if( (theDate.getMinutes() < (end_time_mins)) )
									{
										document.write(String);
										return 1;
									}
								}
							}
						}
					}
				}
			}
		}
		if( (theDate.getMonth() == (end_month-1)) )
		{
			if( (start_month != end_month) )
			{
				if( (theDate.getDate() < (end_day)) )
				{
					document.write(String);
					return 1;
				}
				if( (theDate.getDate() == (end_day)) )
				{
					if( (theDate.getHours() < (end_time_hrs)) )
					{
						document.write(String);
						return 1;
					}
					if( (theDate.getHours() == (end_time_hrs)) )
					{
						if( (theDate.getMinutes() < (end_time_mins)) )
						{
							document.write(String);
							return 1;
						}
					}
				}
			}
		}
	}
	return 1;
}
