// validates that the field value string has one or more characters in it
function isNotEmpty(elem) 
{
	var str = elem.value;
	if(str == null || str.length == 0) 
	{
		// field is empty
		// alert("Please fill in the required field.");
		return false;
	} 
	else 
	{
		// not empty
		return true;
	}
}

// validates that the entry is a positive or negative number
function isnumber(elem) 
{
	var str = elem.value;
	var oneDecimal = false;
	var oneChar = 0;
	// make sure value hasn't cast to a number data type
	str = str.toString()
	for (var i = 0; i < str.length; i++) 
	{
		oneChar = str.charAt(i).charCodeAt(0);
		// OK for minus sign as first character
		if (oneChar == 45) 
		{
			if (i ==0) 
			{
				continue;
			} 
			else 
			{
				alert ("Only the first character may be a minus sign.");
				return false;
			}
		}
		// OK for one decimal point
		if (oneChar == 46) 
		{
			if (!oneDecimal) 
			{
				oneDecimal = true;
				continue;
			} 
			else 
			{
				alert("Only one decimal is allowed in a number.");
				return false;
			}
		}
		// characters outside of 0 through 9 not OK
		if (oneChar < 48 || oneChar > 57) 
		{
			alert("Enter only numbers into the field.");
			return false;
		}
	}
	return true;
}

// validates that the entry is formatted as an email address
function isEMailAddr(elem) 
{
	try
	{
		var str = elem.value;
		var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		
		if (!str.match(re))
		{
			//alert("Verify the address format.");
			return false;
		}
		else
		{
			return true;
		}
	}
	catch (e)
	{
		alert("Caught exception:" + e.message);
		return false;
	}
}


function ValidatorFT(frmlogin)
{
// validation routine for Free Tools login page

   
  //.............................................................................................
  // added required field checks
  
  	//alert("in login validation routine");

	if (!isNotEmpty(frmlogin.FirstName))
	{
		alert("Please enter the First Name.");
		frmlogin.bisok="false";
		frmlogin.FirstName.focus();
		return false;
	}

	if (!isNotEmpty(frmlogin.EmailAddr))
	{
		alert("Please enter an Email address.");
		frmlogin.bisok="false";
		frmlogin.EmailAddr.focus();
		return false;
	}
	
	if (!isEMailAddr(frmlogin.EmailAddr))
	{
		alert("Please verify the format of the email address.");
		frmlogin.bisok="false";
		frmlogin.EmailAddr.focus();
		return false;
	}
	
	// all required fields entered; ok to continue...
	//alert("still here, test insert");
	 
  // nothing else to check really
  frmlogin.bisok="true";
  return true;  
}

function ValidatorGS(frmlogin)
{
// validation routine for Getting StartedPrivate Access login page

   
  //.............................................................................................
  // same validations as free tools check except that also need to 
  // need to check for phone # as well
  
  	//alert("in login validation routine");


	if (!isNotEmpty(frmlogin.Phone))
	{
		alert("Please enter the Phone #.");
		frmlogin.bisok="false";
		frmlogin.Phone.focus();
		return false;
	}

	// same validations as free tools check, use that routine;
	if (ValidatorFT(frmlogin))
	{
		return true;
	}
	else
	{
		return false;
	}
	
  // nothing else to check really; may add other validations later
  //return true;  
}

function ValidatorPA(frmlogin)
{
// validation routine for Private Access login page

   
  //.............................................................................................
  // added required field checks
  
  	//alert("in login validation routine");

	// same validations as free tools check, use that routine;
	if (ValidatorFT(frmlogin))
	{
		return true;
	}
	else
	{
		return false;
	}
	
  // nothing else to check really; may add other validations later
  //return true;  
}
