// JavaScript Document
var urlAddress = "http://www.somersetinn.com/";
var pageName = "Somerset Inn";

function addToFavorites()
{      if (window.external)
            { window.external.AddFavorite(urlAddress,pageName);  } 
	   else 
			{ alert("Sorry! Your browser doesn't support this function.");  }
}

function highlightButton(s) {
if ("INPUT"==event.srcElement.tagName)
event.srcElement.className=s
}

//This part sets the day, month, and year.
todaysDate = new Date();
theDay = todaysDate.getDate();
theMonth = todaysDate.getMonth();
theYear = todaysDate.getYear();

//This part forces the dates from the first part into each field with a corresponding name.
function setDates()
	{
		numDay = theDay;
		numMonth = theMonth;
		numArriveDay = theDay - 1;
		document.highlight.bad[numArriveDay].selected = true;
		document.highlight.bam[numMonth].selected = true;
		document.highlight.bdd[numDay].selected = true;
		document.highlight.bdm[numMonth].selected = true;
		}

/* This script is slightly different from the one shown on this page. It doesn't
return any value, but instead writes the outcome of the check into the textarea. */

var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
//var monthLengtha = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function checkDate(name)
{
var dateExists = true;
	var x = document.forms[0].elements;
	var day = parseInt(x["bad"].options[x["bad"].selectedIndex].value);
	var month = parseInt(x["bam"].options[x["bam"].selectedIndex].value);
	var year = parseInt(x["bay"].options[x["bay"].selectedIndex].value);

	if (!day || !month || !year)
	{	alert('Please fill in a complete date');
		return;	}
		
	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;

	if (day > monthLength[month-1])
		dateExists = false;

	monthLength[1] = 28;

	document.forms[0].results.value = 'Date exists? ' + ((dateExists) ? 'Yes' : 'No') + '\n';
	if (!dateExists) return;

	var now = new Date();
	now = now.getTime(); //NN3

	var dateToCheck = new Date();
	dateToCheck.setYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();

	var futureDate = (now < checkDate);
	var pastDate = (now > checkDate);

if((pastDate == false) && (futureDate == false))
{return true;}

if((pastDate == false) && (futureDate == false))
{return true;}

if(pastDate == true)
{alert("You have selected invalid date. Please select a valid date.");
return false;}

}
// -->
