// JavaScript Document
	function isValidDate(day,month,year)
	{
		var dteDate;

		//set up a Date object based on the day, month and year arguments
		//javascript months start at 0 (0-11 instead of 1-12)
		dteDate=new Date(year,month,day);

		/*
		Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. 
		We'll use this to our advantage by creating the date object and then comparing it to the details we put it. 
		If the Date object is different, then it must have been an invalid date to start with...
		*/

		return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
	}

	function checkEmail(emField)
	{
		var fieldValue = emField.value;  // store field's value in variable, "fieldValue"

		if(fieldValue != "")
		{  //if field is not empty
			var atSymbol = 0;
			
			for(var a = 0; a < fieldValue.length; a++)
			{ //loop through field value string
				if(fieldValue.charAt(a) == "@")
				{ //look for @ symbol and for each @ found, increment atSymbol variable by 1
					atSymbol++;
				}
			}
	
			if(atSymbol > 1)
			{ // if more than 1 @ symbol exists
				return false;
			}
				
			if(atSymbol == 1 && fieldValue.charAt(0) != "@")
			{  // if @ symbol was found, and it is not the 1st character in string
				var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2); //look for period at 2nd character after @ symbol
				var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false; // "."  immediately following 1st "." ? 
						  
			//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
				if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)==".")
				{
					return false;
				}
				  		  
			}
			else
			{  // no @ symbol exists or it is in position 0 (the first character of the field)
				return false; // then cancel
			}
		}
		else
		{  // if field is empty
			return false;  // then cancel
		}
			
		return true;
	}

	function toUnicode(elmnt,content){
		if (content.length==elmnt.maxLength){
			next=elmnt.tabIndex
			if (next<document.forms[0].elements.length){
				document.forms[0].elements[next].focus()
			}
		}
	}

	function startForm(){
		document.forms[0].elements[0].focus()
	}

	function validate1(){ 
		if (document.reqShow.name.value == '')
		{
			alert('You must provide your name.');
			document.reqShow.name.focus();
			return false;
		}

		if (document.reqShow.street.value == '')
		{
			alert('You must enter your present street address.');
			document.reqShow.street.focus();
			return false;
		}

		if (document.reqShow.city.value == '')
		{
			alert('You must enter your present city.');
			document.reqShow.city.focus();
			return false;
		}

		if (document.reqShow.state.selectedIndex == 0)
		{
			alert('You must select your present state.');
			document.reqShow.state.focus();
			return false;
		}
		
		if (document.reqShow.zip.value == '')
		{
			alert('You must enter your present zip code.');
			document.reqShow.zip.select();
			return false;
		}
		else
		{
			if (isNaN(document.reqShow.zip.value))
			{
				alert('You must enter a valid zip code.');
				document.reqShow.zip.select();
				return false;
			}
		}

		if ((isNaN(document.reqShow.phone1.value)) || (document.reqShow.phone1.value.length < 3))
		{
			alert('You must enter a valid phone number.');
			document.reqShow.phone1.select();
			return false;
		}
		
		if ((isNaN(document.reqShow.phone2.value)) || (document.reqShow.phone2.value.length < 3))
		{
			alert('You must enter a valid phone number.');
			document.reqShow.phone2.select();
			return false;
		}

		if ((isNaN(document.reqShow.phone3.value)) || (document.reqShow.phone3.value.length < 4))
		{
			alert('You must enter a valid phone number.');
			document.reqShow.phone3.select();
			return false;
		}

		if (document.reqShow.email.value == '')
		{
			alert('You must enter your email address.');
			document.reqShow.email.focus();
			return false;
		}
		else
		{
			if (!checkEmail(document.reqShow.email))
			{
				alert('You must provide a valid email address.');
				document.reqShow.email.select();
				return false;
			}
		}

		if ((document.reqShow.cell1.value != '') || (document.reqShow.cell2.value != '') || (document.reqShow.cell3.value != ''))
		{
			if ((isNaN(document.reqShow.cell1.value)) || (document.reqShow.cell1.value.length < 3))
			{
				alert('You must enter a valid phone number.');
				document.reqShow.cell1.select();
				return false;
			}
		
			if ((isNaN(document.reqShow.cell2.value)) || (document.reqShow.cell2.value.length < 3))
			{
				alert('You must enter a valid phone number.');
				document.reqShow.cell2.select();
				return false;
			}

			if ((isNaN(document.reqShow.cell3.value)) || (document.reqShow.cell3.value.length < 4))
			{
				alert('You must enter a valid phone number.');
				document.reqShow.cell3.select();
				return false;
			}
		}
				
		var choice = false;
		
		for (i=0; i<document.reqShow.pet.length; i++)
		{
			if (document.reqShow.pet[i].checked)
				choice = true; 
		}
		
		if (!choice)
		{
			alert("You must state whether or not you have any pets.");
			document.reqShow.pet[0].focus();
			return false;
		}
		else
		{
			if (document.reqShow.pet[0].checked)
			{
				if (document.reqShow.pettype.value == '')
				{
					alert('You must state what type of pet(s) you have.');
					document.reqShow.pettype.focus();
					return false;
				}
			}
		}

		if (document.reqShow.mimonth.value == '')
		{
			alert('You must enter a valid month.');
			document.reqShow.mimonth.focus();
			return false;
		}
		else
		{
			if (isNaN(document.reqShow.mimonth.value))
			{
				alert('You must enter a valid month (1 - 12).');
				document.reqShow.mimonth.select();
				return false;
			}
			else
			{
				if ((document.reqShow.mimonth.value < 1) || (document.reqShow.mimonth.value > 12))
				{
					alert('You must enter a valid month (1 - 12).');
					document.reqShow.mimonth.select();
					return false;
				}
			}
		}

		if (document.reqShow.miday.value == '')
		{
			alert('You must enter a valid day (1 - 31).');
			document.reqShow.miday.focus();
			return false;
		}
		else
		{
			if (isNaN(document.reqShow.miday.value))
			{
				alert('You must enter a valid day (1 - 31).');
				document.reqShow.miday.select();
				return false;
			}
			else
			{
				if ((document.reqShow.miday.value < 1) || (document.reqShow.miday.value > 31))
				{
					alert('You must enter a valid day (1 - 31).');
					document.reqShow.miday.select();
					return false;
				}
			}
		}
		if (document.reqShow.miyear.value == '')
		{
			alert('You must enter a valid year.');
			document.reqShow.miyear.focus();
			return false;
		}
		else
		{
			if (isNaN(document.reqShow.miyear.value))
			{
				alert('You must enter a valid year.');
				document.reqShow.miyear.select();
				return false;
			}
		}
		if (!isValidDate(document.reqShow.miday.value, document.reqShow.mimonth.value - 1, document.reqShow.miyear.value))
		{
			alert('You must enter a valid date.');
			document.reqShow.mimonth.select();
			return false;
		}
		
		if (document.reqShow.bestdatetime.value == '')
		{
			alert('You must enter a best date/time for your showing.');
			document.reqShow.bestdatetime.focus();
			return false;
		}
		
		return true;
	}