// include as [script language='javascript' src='mailto.js'][/script]

function chkSubmit(mlist)
{
  mess = "";

  with(document.testform)
  {
    chkemail = true; chkbody = true; comm = ", comments";

    if ( mlist=="Y" )
    {
      chk = getradval(dtick);
      if (chk=="E")	{chkbody=false;}
      if (chk=="P")	{chkemail=false;}
      comm = ", address";
    }

    if (dname.value=="")						{ mess += ", name"; }
    if (chkemail && (dfrom.value=="" || !is_email(dfrom.value)))	{ mess += ", email"; }
    if (chkbody && dbody.value=="")					{ mess += comm; }

    if (mess!="")
    {
      alert("Please enter your "+mess.replace(/(.*),(.*)$/,"$1 &$2 ").substr(2)); return(false);
    }
  }
return(true);
}

function is_email(str)
{
  at = str.indexOf("@");
  dot = str.indexOf(".",at+2);
  if (dot == -1 || at == -1)
  {
    return( false );
  }
  return( true );
}

function getradval(radobj)
{
  for (i = 0; i < radobj.length; i++ )
  {
    if (radobj[i].checked)      break;
  }
return(radobj[i].value);
}
