function validate_form()
{
  missing=false
  to_check=new Array("name",
  	       	      "address1",
		      "company",
		      "department",
		      "phone",
		      "email");
  while(field=to_check.pop())
  {
    if (!validate_field(field)) 
    {
      document.getElementById(field).style.backgroundColor="#ffeeee"
      missing=true
    }
    else
    {
      document.getElementById(field).style.backgroundColor="#ffffff"
    }
  }
  if (missing==true) 
  { 
    alert("Some mandatory fields are missing!");
    return false;
  }
  if (!verify_email(document.getElementById('email').value))
  { 
    document.getElementById('email').style.backgroundColor="#ffeeee"
    alert("Email address is invalid!");
    return false;
  }
  return true;
}


function do_subscribe(e)
{
  document.getElementById('mode').value="SUBSCRIBE";
  if (validate_form()) document.forms.namedItem('mail_form').submit();
}

function do_unsubscribe(e)
{
  document.getElementById('mode').value="UNSUBSCRIBE";
  if (validate_form()) document.forms.namedItem('mail_form').submit();
}

addEvent(document.getElementById('Subscribe'),'click',do_subscribe)
addEvent(document.getElementById('Unsubscribe'),'click',do_unsubscribe)
