 function continue_onClick() 
 {
   if (checkForm() == true)
   {
	  /* document.form1.action="contact.cfm"; */
	  document.form1.target="_self";
	  document.form1.method="post";
	  document.form1.submit();
	}
 }
 
 function checkForm()
 {
	document.form1.first_name.value=nolrspaces(document.form1.first_name.value);
	document.form1.first_name.value=singlespace(document.form1.first_name.value);
	
	document.form1.last_name.value=nolrspaces(document.form1.last_name.value);
	document.form1.last_name.value=singlespace(document.form1.last_name.value);
	
	document.form1.phone.value=nolrspaces(document.form1.phone.value);
	document.form1.phone.value=singlespace(document.form1.phone.value);
	
	document.form1.from_email.value=nolrspaces(document.form1.from_email.value);
	document.form1.from_email.value=singlespace(document.form1.from_email.value);
	
    if (!(document.form1.first_name.value)) 
   	{
     	 alert('Please enter your first name.');
     	 return false;
   	}
	
    if (!(document.form1.last_name.value)) 
   	{
     	 alert('Please enter your last name.');
     	 return false;
   	}
	
	if (!(isdisplay(document.form1.first_name.value)) || !(isdisplay(document.form1.last_name.value)))
	{
		alert('Non-standard characters not permitted in name field.');
		return false;
	}
		
    if (!(document.form1.phone.value) && !(document.form1.from_email.value)) 
   	{
     	 alert('Please enter your phone number or email address.');
     	 return false;
   	}	
			
    if (document.form1.ValidationString.value == "")
    {
      alert("Please type the anti-spam code to continue.");
      return false;
    }
  
	else
	{			
      return true;
	}
 }


//'############################################
//' return digits in a string 
function getdigits(strdiglet)
{
	var outstring =new String
	for( j= 0;  j<strdiglet.length; j++)
		{		 
			if (( strdiglet.charCodeAt(j)>=48)&&( strdiglet.charCodeAt(j)<=57))
				{ outstring=outstring.concat(strdiglet.charAt(j));	}	
		}
return outstring;
}
//'############################################
//' phone number formatting (input 10 digits)
//' phoneformat2 returns ###-###-####
function phoneFormat(phone10)
{
var outstring=new String;
outstring=outstring.concat(phone10.substr(0,3));
outstring=outstring.concat('-');
outstring=outstring.concat(phone10.substr(3,3));
outstring=outstring.concat('-');
outstring=outstring.concat(phone10.substr(6,4));
return outstring;
}
//'############################################
function validemail(vemail)
// returns true if email address looks valid
{
if ( vemail.length<5 )
	{alert('e-mail address must be at least 5 characters long'); return false; }
else if ( vemail.indexOf('@')==0)
	{ alert('e-mail address 1st character can not be @'); return false; }
else if ( vemail.indexOf('@')<0)
	{ alert('e-mail address must have a @'); return false; }		
else if ( vemail.indexOf('@')!=vemail.lastIndexOf('@'))
	{ alert('e-mail address must have only 1 @'); return false; }
else if ( vemail.lastIndexOf('@')==(vemail.length-1))
	{ alert('e-mail address last character can not be @'); return false; }
else if ( vemail.lastIndexOf('.')==(vemail.length-1))
	{ alert('e-mail address last character can not be .'); return false; }	
else if ( vemail.lastIndexOf('@')>vemail.lastIndexOf('.'))
	{ alert('e-mail address must have a . somewhere after @'); return false; }
else if ( vemail.indexOf('.@')>-1 )
	{ alert('e-mail address can not have .@'); return false; }
else if ( vemail.indexOf('@.')>-1 )
	{ alert('e-mail address can not have @.'); return false; }		
else if ( vemail.indexOf('..')>-1 )
	{ alert('e-mail address can not have ..'); return false; }
else if ( vemail.indexOf(' ')>-1 )
	{ alert('e-mail address can not have embedded spaces'); return false; }		
else	{ return true; }
}
//'############################################
//' returns true if all characters in string are between space and ~ ascii (inclusive).
function isdisplay(strinx)
{
	var j=0;
	for( j= 0;  j<strinx.length; j++)
		{	
			if ( (strinx.charCodeAt(j)<32)||( strinx.charCodeAt(j)>126))
				{ return false;		}	
		}
	return true;
}
//'############################################
// allows only lf cr and ascii 32 to 126 in user inputs
function isdisplay2(strinx)
{
	var j=0;
	for( j= 0;  j<strinx.length; j++)
		{	
			if ( (strinx.charCodeAt(j)<32)||( strinx.charCodeAt(j)>126))
				{ if ( (strinx.charCodeAt(j)!=10)&&( strinx.charCodeAt(j)!=13))
						{ return false;	}
				}	
		}
	return true;
}	

//'############################################

//' strips all spaces out of a string
function nospaces(strinx)
{
	var j=0;
	var tmpstring =new String
	for( j= 0;  j<strinx.length; j++)
		{		 
			if ( strinx.charCodeAt(j)!=32)
				{ tmpstring=tmpstring.concat(strinx.charAt(j));	}	
		}
return tmpstring;
}
//'############################################
//' strip off leading and trailing spaces from string
function nolrspaces(strinx)
{
	while (strinx.charCodeAt(0)==32)
		{ strinx = strinx.substring(1, strinx.length); 
		}
	while (strinx.charCodeAt(strinx.length-1)==32)
		{ strinx = strinx.substring(0, strinx.length - 1); 
		}
//	  document.form1.password.value = strinx;
	return strinx;
}

//'############################################
function zip10format(strin)
	{ var strout=new String
		strout=strin.substr(0,5);
		strout=strout.concat('-');
		strout=strout.concat(strin.substr(5,4));
		return strout;
	}
//'############################################
// converts multiple spaces together in a string to one space.
function singlespace(strinx)
{
	var spc1=' ';
	var spc2='  ';
	while (strinx.indexOf(spc2)>=0)
		{
			strinx=strinx.replace(spc2,spc1);
		} 
return strinx;
}			
//'############################################
function nocommas(strinx)

{
	var comma=',';
	var blank='';
	while (strinx.indexOf(comma)>=0)
		{
			strinx=strinx.replace(comma,blank);
		} 
	return strinx;
}