<!-- // 

// This is a common JS file to be included in the header section of those pages using JS.
// Once a JS file is loaded into the browser's memory, it stays cached during the session.
// Place JS functions that may be called more than once here. 

//'############################################
//' 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
}
// -->







