function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;}
function CheckField(TheValue,Type, CheckType, Length) {
	var tempcheck = 1;var ponerror="";
	if(TheValue.length < Length ){ponerror += "- " + Type +" does not contain enough characters.\n";	}
	return ponerror}
function CheckNum(TheNumber,Type, NumLength) {
	var Integers = "0123456789";var integercounter=0;var ponerror="";
	for (i =0; i <= TheNumber.length -1; i++) {if (Integers.indexOf(TheNumber.charAt(i)) != -1) {integercounter++;} 	}
	if ( integercounter <= NumLength-1){ponerror += "- " + Type +" does not have the correct number of digits\n";}
	return ponerror;}
function MM_validateForm() { //v4.0
  var i,p,q,nm,z,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) {p=val.indexOf('@');z=val.lastIndexOf('.');
        if (p<1 || p==(val.length-1) || z<1 || z > (val.length-4)) errors+='- '+nm+' must contain an e-mail address.\n';
      	else if (val.search(/[^a-zA-Z0-9@._-]/) != -1) errors+='- '+nm+' contains invalid characters.\n';	  
	  } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
	MM = (document.healthform.BirthMonth);
	DD = (document.healthform.BirthDay);
	YY = (document.healthform.BirthYear);
	State = (document.healthform.State);	
	OC = (document.healthform.Occupation);
	errors += CheckField((document.healthform.FirstName.value),'FirstName',0,2);
	errors += CheckField((document.healthform.LastName.value),'LastName',0,2);	
	errors += CheckField((document.healthform.City.value),'City',0,2);
	errors += CheckField((document.healthform.Address.value),'Address',0,5);
	if (OC[OC.selectedIndex].value == "") errors += "- Occupation is required\n";
	if (State[State.selectedIndex].value == "") errors += "- State is required\n";
	if (MM[MM.selectedIndex].value == "" || DD[DD.selectedIndex].value == "" || YY[YY.selectedIndex].value == "") errors += "- Date of birth is required\n";
	errors += CheckNum((document.healthform.HomePhoneArea.value + document.healthform.HomePhoneFirst.value + document.healthform.HomePhoneLast.value),'HomePhone',10);	
	errors += CheckNum((document.healthform.Zip.value),'ZipCode',5);errors += CheckNum((document.healthform.Weight.value),'Weight',2);
	if (errors) {
		alert('Please validate the following fields before continuing:\n\n'+errors);
		document.MM_returnValue = (errors == '');
	}else {
		document.healthform.action="HC03_1_23/STP1.asp";
		document.healthform.submit();
		document.healthform.send.disabled = 1;
		document.healthform.send.value = "Submitting Request";}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
