// 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 Validator(theForm)
{

  var checkOK = "0123456789-.,";
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";

  //.............................................................................................
  // added required field checks
	if (!isNotEmpty(theForm.slrName))
	{
		alert("Please enter the Seller Name.");
		theForm.slrName.focus();
		return (false);
	}

	if (!isNotEmpty(theForm.slrPhone))
	{
		alert("Please enter a Seller Phone number that we may reach you at.");
		theForm.slrPhone.focus();
		return (false);
	}
	
	if (!isNotEmpty(theForm.slrEmail))
	{
		alert("Please enter a Seller Email address.");
		theForm.slrEmail.focus();
		return (false);
	}
	
	if (!isEMailAddr(theForm.slrEmail))
	{
		alert("Please verify the format of the Seller email address.");
		theForm.slrEmail.focus();
		return (false);
	}
	
	if (!isNotEmpty(theForm.slrPropAddr))
	{
		alert("Please enter a Seller Property Address.");
		theForm.slrPropAddr.focus();
		return (false);
	}
	
	
  // all required fields entered; ok to continue...
  
  //..............................................................................................
  //....data type validations for rest of form go here....
  // nothing else to check really
  
  // if at this point, should be valid; check captcha and return result;
  //return cap_valid(event);
  
  // using reCaptcha in calling form instead; return true at this point;
  return (true);  
  
}

function Validator3p(frm3p)
{

  var checkOK = "0123456789-.,";
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";

  //.............................................................................................
  // added required field checks
  frm3p.ContactName.focus();
  
	if (!isNotEmpty(frm3p.ContactName))
	{
		alert("Please enter the Contact Name.");
		frm3p.ContactName.focus();
		allValid=false;
		return (false);
	}

	if (!isNotEmpty(frm3p.ContactEmail))
	{
		alert("Please enter an Email address.");
		frm3p.ContactEmail.focus();
		allValid=false;
		return (false);
	}
	
	if (!isEMailAddr(frm3p.ContactEmail))
	{
		alert("Please verify the format of the email address.");
		frm3p.ContactEmail.focus();
		allValid=false;
		return (false);
	}
		
  // all required fields entered; ok to continue...
  
  //..............................................................................................
  //....data type validations for rest of form go here....
  // nothing else to check really
  //alert("end of Validator3p");
  //return (true);  
    
  // if at this point, should be valid; check captcha and return result;
  //return cap_valid(event);
  
  // using reCaptcha in calling form instead; return true at this point;
  return (allValid);
  
}