function autotab(original,destination)
{
      if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
      {
            destination.focus();
      }
}
	function editDate(date)
	{
		var month = date.substring(4, 6);
		var day = date.substring(6, 8);
		var year = date.substring(0, 4);

		if (month  < 1 || month  > 12)
  		{
   			return ("M");
  		}
   		if (!editDay(day, month))
  		{
    			return ("D");
  		}
   		if (year < 1909 || year > 2008)
  		{
   			return ("Y");
  		}
		return ("OK");
	}
	function editDay(day, month)
	{
		var monthMax = new Array(31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);		

		if (day < 1 || day > monthMax[month])
		{
			return (false);
		}		
		return (true);
	}
	function editEmail(emailStr)
	{
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		
		if (matchArray == null)
		{
			alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];

		if (user.match(userPat) == null)
		{
		    alert("The username doesn't seem to be valid.");
		    return false;
		}
		var IPArray=domain.match(ipDomainPat);

		if (IPArray != null)
		{
			for (var i=1;i<=4;i++)
			{
				if (IPArray[i] > 255)
				{
					alert("Destination IP address is invalid!");
					return false;
				}
			}
			return true;
		}

		var domainArray=domain.match(domainPat);

//		if (domainArray==null)
//		{
//			alert("The domain name doesn't seem to be valid.");
//    			return false;
//		}
		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		var len=domArr.length;

		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
		{
			if (emailStr.length > 5)
			{
				if (emailStr.substring(emailStr.length - 5, emailStr.length) == ".name" || 
					emailStr.substring(emailStr.length - 5, emailStr.length) == ".info")
				{
				}
				else
				{			
   					alert("The email address must end in a three-letter\ndomain, or two letter country.");
   					return false;
   				}
   			}
			else
			{			
   				alert("The email address must end in a three-letter\ndomain, or two letter country.");
   				return false;
   			}
		}
		if (len < 2)
		{
   			alert("This address is missing a hostname!");
   			return false;
		}
		return true;
	}
	
	function form_Validator()
	{
		if (document.form.firstName.value.length < 1)
  		{
   			alert("Please enter a first name.");
   			document.form.firstName.focus();
   			document.form.firstName.select();
   			return (false);
  		}
  		if (document.form.lastName.value.length < 1)
  		{
   			alert("Please enter a last name.");
   			document.form.lastName.focus();
   			document.form.lastName.select();
   			return (false);
  		}
 		if (document.form.email.value.length < 1)
  		{
   			alert("Please enter an email address.");
   			document.form.email.focus();
  			document.form.email.select();
   			return (false);
  		}
  		if (document.form.confirmEmail.value.length < 1)
  		{
   			alert("Please enter a confirm email address.");
   			document.form.confirmEmail.focus();
  			document.form.confirmEmail.select();
   			return (false);
  		}
  		if (document.form.dentalPractice.value.length < 1)
  		{
   			alert("Please enter the Name of Dental Practice.");
   			document.form.dentalPractice.focus();
  			document.form.dentalPractice.select();
   			return (false);
  		}
  		if (document.form.owner.value.length < 1)
  		{
   			alert("Please enter the Name of Dental Practice Owner/Partner.");
   			document.form.owner.focus();
  			document.form.owner.select();
   			return (false);
  		}
 		if (document.form.address1.value.length < 1)
  		{
   			alert("Please enter an address 1.");
   			document.form.address1.focus();
   			document.form.address1.select();
   			return (false);
  		}
  		if (document.form.city.value.length < 1)
  		{
   			alert("Please enter a city.");
   			document.form.city.focus();
  			document.form.city.select();
   			return (false);
  		}
  		if (!(document.form.zipCode.value.length == 5))
  		{
   			alert("Please enter a 5 digit zip code.");
   			document.form.zipCode.focus();
   			document.form.zipCode.select();
   			return (false);
  		}
  		if (document.form.telephone1.value.length < 3)
 		{
			alert("Please enter a phone number area code.");
   			document.form.telephone1.focus();
   			document.form.telephone1.select();
    		return (false);
  		}
		if (document.form.telephone2.value.length < 3)
 	 	{
   			alert("Please enter a complete phone number.");
   			document.form.telephone2.focus();
   			document.form.telephone2.select();
    		return (false);
  		}
		if (document.form.telephone3.value.length < 4)
 	 	{
   			alert("Please enter a complete phone number.");
   			document.form.telephone3.focus();
   			document.form.telephone3.select();
    		return (false);
  		}
  		  	return (true);
	}
	function numericMask()
	{
		if (event.keyCode < 48 || event.keyCode > 57)
		{
			event.keyCode = 0;
		}
	}	
	function screenSetup()
	{
		document.form.firstName.focus();
		
		if (document.form.msg.value.length > 0)
		{
			alert(document.form.msg.value);
//			document.form.msg.value = "";
		}
	}	