
/////////////////////////////////////////////////

// form field validation
function validateForm (form) {
  for (var e = 0; e < form.elements.length; e++) {
    var el = form.elements[e];

if (el.name == 'affiliate_org_address2' || el.name == 'affiliate_website_desc') {
	 } else {
    if (el.type == 'text' || el.type == 'textarea' ) { 
      if (el.value == '') {
        alert('Please fill out the text field ' + el.name);
        el.focus();
        return false;
      }
    }

    else if (el.type.indexOf('select') != -1) {
      if (el.selectedIndex == 0) {
        alert('Please select a value of the select field ' + el.name);
        el.focus();
        return false;
      }
    }

    else if (el.type == 'radio') {
      var group = form[el.name];
      var checked = false;
      if (!group.length)
        checked = el.checked;
      else
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
      if (!checked) {
        alert('Please check one of the radio buttons ' + el.name);
        el.focus();
        return false;
      }
    }
   }
  }
  return true;
}
// End

// email validation
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function checkEmail (field) {
  if (!isValidEmail(field.value)) {
    alert('Please enter email address in the correct format e.g. you\@yourisp.com');
    field.focus();
    field.select();
  }
}

// Begin open help window
function explain(msg) {
newwin = window.open('','help_window','scrollbars,top=150,left=150,width=350,height=250');
if (!newwin.opener) newwin.opener = self;
with (newwin.document)
{
open();
write('<html><head><title>Help</title><LINK HREF="/css/aff.css" REL="stylesheet" TYPE="text/css"> </head>');
write('<body onLoad="focus()"><p><input type=button style="background-color: COCOCO; border-color: 555555; border-width: 1; font-size: 10pt; font-family: arial;" value="Click to close when finished" onClick=window.close()></p>');
write('<p>' + msg + '</p>');
write('</body></html>');
close();
   }
}
//  End -->