function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function radioVal(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return "";
}

function antispam(name,domain) {
    	document.location = "mailto:" + name + "@" + domain;
	}

//howManyChecked('myform','cb_industry',6,1,'Industry');
function howManyChecked(whichForm,whichCheckBoxArray,myMax,myMin,whichQuestion)
/*
  This function takes 5 paramaters:
  whichForm -- the NAME of the form to be validated, a string
  whichCheckBoxArray -- the NAME of the checkbox to be checked, a string
  myMax -- the most you want the user to be able to check, an integer
  myMin -- the least you want the user to be able to check, an integer
  whichQuestion -- a short description of the question, a string
  
  example use:
  howManyChecked('myform','cb_industry',6,1,'Industry');
*/
{
	var _countChecked = 0;
	var err = 0;
	/* iterate through all the elements in the checkbox array */
	for(i=1;i<document[whichForm][whichCheckBoxArray].length;i++)
	{
		/* and check to see if each is checked */
		if(document[whichForm][whichCheckBoxArray][i].checked==true)
			/* if it is, increment a counter */
			{ _countChecked++; }
	}
	/* is the count too high? */
	if(_countChecked > myMax)
		{ alert('Limit '+myMax+' checks for '+whichQuestion);
			err = 1;}
	/* of is the count too low */
	else if(_countChecked < myMin)
		{ alert('You must fill out at least '+myMin+' entry(s) for '+whichQuestion);
			err = 1;}
	if (err == 1) { 
	return true; 
	}
	else { 
	return false; 
	}
}