<!-- // 

// 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. 

// START js for hide/show divClass code, to supress/reveal sota menu
function showHide_divClass_onClick(hideOrShow,divClass)
{
  var tmp = document.getElementsByTagName('div');
	for (var i=0;i<tmp.length;i++)
	{
		if(tmp[i].className == divClass)
		{
		  // tmp[i].style.display = (tmp[i].style.display == 'none') ? 'block' : 'none';  // toggles visiblity status
		  if(hideOrShow == 'show')
		  { tmp[i].style.display = 'block'; }
		  else // hide
		  { tmp[i].style.display = 'none'; }
		}
	}
} 
// END js for hide/show divClass code, to supress/reveal sota menu


///////////////// START checkboxesMinMaxChecked() //////////////
// works right w/ multiple checkboxes of the same name!!!!	
function checkboxesMinMaxChecked(formName,fieldName,displayName,minChecked,maxChecked)
  {
	// 	used to tell how many checkboxes with the same specified name have been checked
	var checkbox_name = fieldName;	
	// set var checkbox_choices to zero
	var checkbox_choices = 0;
    eval("var numelements = document." + formName + ".elements.length;");
	// Loop from zero to the one minus the number of form elements
	for (counter = 0; counter < numelements; counter++)
	{
		// document.forms[0].elements[counter].name
	    eval("var this_FieldName = document." + formName + ".elements[" + counter + "].name;");
		if (this_FieldName==checkbox_name)	
			{			
				eval("var this_FieldChecked = document." + formName + ".elements[" + counter + "].checked;");
				
				// increment checkbox_choices if checkbox checked
				if (this_FieldChecked)
				{ 
				  checkbox_choices = checkbox_choices + 1;
				}
			}
	} 

	if (checkbox_choices < minChecked)
	{
      alert('You must select a minimum of ' + minChecked + ' items for ' + displayName + '.');
	  return false;			
	}
	else if (checkbox_choices > maxChecked)
	{
	  alert('You must select a no more than ' + maxChecked + ' items for ' + displayName + '.');
	  return false;			
	}	
	else
	{
		return true;
	}
 }
 ///////////////// END checkboxesMinMaxChecked() //////////////

//'############################################
//' 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;
}
// -->






