function checkcontacts()
{
   if (checked())
   {
     if(validate())
     {
	checkcheck();
	document.form1.action='sendmail.php';
	document.form1.submit();		
     }
   }
}//checkcontacts

function checkcheck()
{
   if(document.form1.checkbox3.checked==1)
	document.form1.checkbox33.value="Selected";	
   else
	document.form1.checkbox33.value="Not Selected";

   if(document.form1.checkbox4.checked==1)
	document.form1.checkbox44.value="Selected";
   else
	document.form1.checkbox44.value="Not Selected";

   if(document.form1.checkbox5.checked==1)
	document.form1.checkbox55.value="Selected";
   else
	document.form1.checkbox55.value="Not Selected";

   return true;
}

function checked()
{
   if (document.form1.checkbox.checked==1 && document.form1.checkbox2.checked==1)
	return true;
   if (document.form1.checkbox.checked!=1 && document.form1.checkbox2.checked!=1)
   {
	alert (' Please select the checkboxs \n"I am representing an organization or business." \n "We support the principles outlined in the Platform below."' );
	return false;
   }
   if (document.form1.checkbox.checked==1 && document.form1.checkbox2.checked!=1)
   {
	alert (' Please select the checkbox "We support the principles outlined in the Platform below." ' );
	return false;
   }
   if (document.form1.checkbox.checked!=1 && document.form1.checkbox2.checked==1)
   {
	alert (' Please select the checkbox "I am representing an organization or business." ' );
	return false;
   }
	return false;
}//checked

function validate()
{
  if(!checkname('Organization')) 
	return false;
  if(!checkname('Person'))
	return false;
  if(!checkname('Title'))
	return false;
  if(!checkname('Address'))	
	return false;
  if(!checkname('csp'))	
	return false;
  if(!checkPhoneNumber())
	return false;
  if(!checkemail())
	return false;

return true;				
	
}//validate


function checkemail()
{
	var testresults=false;
	stre = document.form1.ea.value;	
	stre=trim(stre);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(stre))
		return true;
	alert("Please enter a valid email address");
	return (testresults)
}

function checkPhoneNumber()
{
	strp = eval('document.form1.pn.value');	
	var Chars = "0123456789-()";
	if((trim(strp)).length<=0)
	{
		alert("Please enter a valid phone #");
		return false;
	}
	strp=trim(strp);
	for(var l=0;l<strp.length;l++)
		if(Chars.indexOf(strp.charAt(l)) == -1)
		{
			alert("Please enter a valid phone #");
			return false;
		}
	return true;
}

function trim(received)
{
  return received.replace(/^\s+|\s+$/g,"");
}

function checkname(strr)
{	
	str=trim(eval('document.form1.'+strr+'.value'));
	if(str.length > 0)
	    return true;		
	else
	{
		if(strr=="csp")
		  alert("Please enter City, State, Zip ");
		else
		  alert("Please enter " + strr + " name ");
	}
	return false;	
}
