var dateMsg, ssMsg, shortdateMsg, shortCCdateMsg;
dateMsg = "Please use the mm/dd/yyyy format for dates.";
currentdateMsg = "Please enter the current date in mm/dd/yyyy format.";
ssMsg = "Invalid Social Security #";
shortdateMsg = "Please use the mm/yy format for the Credit Card expiration date.";
shortCCdateMsg = "Please use the mm/yy format for the Credit Card expiration date.";
phoneMsg = "Invalid phone number.  Please use the format xxx-yyy-zzzz.";
faxMsg = "Invalid fax number.  Please use the format xxx-yyy-zzzz.";
futuredateMsg = "Please use the mm/yyyy format and the date must be in the future.";



function checkEC(form) {
  // user cannot be blank (Patient)
  // question cannot be blank (tMessage)
  // if billing (mECFeeYes), $ (mECFeeAmount) > 0

  if (form.submitBtn) {
	form.submitBtn.disabled = true;
  }  
  
  p = form.Patient.value;
  m = form.tMessage.value;
  f = form.mECFeeAmount.value;
  n = form.mECFee[1].checked;
  s = form.stdamount.value;
   
  if (p.length == 0) {
    alert("Please select a person to send the message to.");
    if (form.submitBtn) {
	  form.submitBtn.disabled = false;
    } 
    return false;
  }
  
  if (m.length == 0) {
    alert("Please type in your question/response.");
    if (form.submitBtn) {
	  form.submitBtn.disabled = false;
    } 
    return false;
  } 

  if (n == true && f.length != 0 && isNaN(f)) {
    alert("The fee must be a number.");
    if (form.submitBtn) {
	  form.submitBtn.disabled = false;
    } 
    return false;
  }
  
  if (n == true && f < 0) {
    alert("The fee must be 0 or greater.");
    if (form.submitBtn) {
	  form.submitBtn.disabled = false;
    } 
    return false;
  }  
    
  if (n == true & f > s) {
	alert("The fee cannot be greater than your standard fee ($" + s + ")");
    if (form.submitBtn) {
	  form.submitBtn.disabled = false;
    } 
	return false;
  }  
    
  return true;
}




function postSession(form) {
  // amount must be greater than 0
  a = form.amount.value;
  b = form.laInsuranceStatus.options[form.laInsuranceStatus.selectedIndex].value;
  
    if (form.submitBtn) {
	  form.submitBtn.disabled = true;
    }   
  
  stdamount = form.stdamount.value;
  amount = form.amount.value;
  
  if (stdamount.length > 0 && amount.length > 0) {
    if (parseFloat(amount) > parseFloat(stdamount)) {
      alert("You cannot charge the client more than your standard fee.");  
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }     
      return false;
    } 
  }
 
  if (a.length == 0) {
    alert("You must enter a fee.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (isNaN(a)) {
    alert("You must enter a valid fee.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (a < 0) {
    alert("The fee must be 0 or greater.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
    
  if (b == "") {
    alert("Please choose whether or not it is an insurance transaction.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
    
  return true;
}




function postGroupSession(form,totCount) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = true;
      }   

 for (i=1; i < totCount+1; i++) {
  // amount must be greater than 0
  a = eval('form.amount' + i + '.value');
  b = eval('form.laInsuranceStatus' + i + '.options[form.laInsuranceStatus' + i + '.selectedIndex].value');
  
  stdamount = eval('form.stdamount' + i + '.value');
  amount = eval('form.amount' + i + '.value');
  
  if (stdamount.length > 0 && amount.length > 0) {
    if (parseFloat(amount) > parseFloat(stdamount)) {
      alert("You cannot charge the client more than your standard fee.");    
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
      return false;
    } 
  }
 
  if (a.length == 0) {
    alert("You must enter a fee.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (isNaN(a)) {
    alert("You must enter a valid fee.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (a < 0) {
    alert("The fee must be 0 or greater.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
    
  if (b == "") {
    alert("Please choose whether or not it is an insurance transaction.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
 }
    
 return true;
}




function searchForm(form) {
  //    if (form.submitBtn) {
  //    form.submitBtn.disabled = true;
  //    }   

  // make sure search word is not blank
  a = form.searchFor.value;
  
  if (a.length == 0) {
    alert("Search term cannot be blank.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkEM(form) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = true;
      }   
      
  // make sure reply is not blank
  m = form.tMessage.value;
  
  allowsubmit = 0;
  
  if (m.length == 0) {
    alert("You must enter a reply.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    allowsubmit = 1;
    //return false;
  }
  
  if (f.tMessage.value.length > 8000) {
		alert('Please limit your response to less than 8000 characters.  You are currently at ' + f.tMessage.value.length + ' characters.');
		allowsubmit = 1;
  }
  
  if ( allowsubmit == 1 ) {
		return false;
	} else {
		return true;	
  }
  
}




function checkPhone(p) {
   
  p = p.replace(/-/g,"");
  p = p.replace(/\(/g,"");
  p = p.replace(/\)/g,"");
  p = p.replace(/\[/g,"");
  p = p.replace(/\]/g,"");
  p = p.replace(/_/g,"");
  p = p.replace(/\s*/g,"");
  
  if (p.length < 10 || (p.length >= 10 && isNaN(p.substr(0,10)))) {
    return false;
  }
}

function checkSSNumber(z) {
  z = z.replace(/\s*/g,"");
  z = z.replace(/-/g,"");
  if (isNaN(z) || z.length != 9) {
    return false;
  }
  return true;
}



function checkDate(z) {
  
  errorFound = 0;
  
  dArray = z.split("/");
    
  if (dArray.length < 3) {
    errorFound = 1;
  } else {
    m = dArray[0];
    day = dArray[1];
    y = dArray[2];
  }

  if (errorFound != 1) {
    if (m < 1 || m > 12) {
      errorFound = 1;
    }
 
    if (day < 1 || day > 31) {
      errorFound = 1;
    }
  
    if (y.length !=2 && y.length != 4) {
      errorFound = 1;
    }
  }
  
  if (errorFound == 1) {
    return false;
  }
  
  return true;
}



function checkRolodex(form) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = true;
  //    }   

  // vname required
  n = form.vName.value;
  s = form.lcState.options[form.lcState.selectedIndex].value;
  
  if (n.length == 0) {
    alert("You must enter a name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (s.length == 0) {
    alert("You must enter a state.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}



function checkToDo(form) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = true;
  //    }   
      
  // vToDo required
  n = form.vToDo.value;
  z = form.dDueBy.value;
  
  if (n.length == 0) {
    alert("You must enter a task.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (checkError(checkDate(z),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  return true;
}

function checkFees(form) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = true;
  //    }   

  // check all fees
  a = form.mECFee.value.replace(/\s*/g,"");
  b = form.mOnlineIndFee.value.replace(/\s*/g,"");
  c = form.mOnlineGroupFee.value.replace(/\s*/g,"");
  d = form.mFaceIndFee.value.replace(/\s*/g,"");
  e = form.mFaceGroupFee.value.replace(/\s*/g,"");
  
  if (a.length == 0 || b.length == 0 || c.length == 0 || d.length == 0 || e.length == 0) {
    alert("All fee amounts must be valid.  Do not use dollar signs.  Use 0 instead of leaving a field blank.")
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;   
  }
  
  if ((a != 0 && !parseFloat(a)) || (b != 0 && !parseFloat(b)) || (c != 0 && !parseFloat(c))|| (d != 0 && !parseFloat(d)) || (e != 0 && !parseFloat(e))) {
    alert("All fee amounts must be valid.  Do not use dollar signs.  Use 0 instead of leaving a field blank.")
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (a < 0 || b < 0 || c < 0 || d < 0 || e < 0) {
    alert("All fee amounts must be zero or greater.")
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
 
  return true;
}



function checkDetailed(form) {
  //    if (form.submitBtn) {
  //	   form.submitBtn.disabled = true;
  //    }   
 
  // check vTargetDate, vAchievedDate
  a = form.vTargetDate.value;
  b = form.vAchievedDate.value;
  c = form.vTitle.value;
  d = form.vRank.value;
  
  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
 
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c.length > 20) {
    alert("The Problem Title cannot exceed 20 characters.")
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (d.length > 0 && (!parseInt(d) || parseInt(d) < 1 || parseInt(d) > 10)) {
    alert("Severity must be a number between 1 and 10.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
}



function checkMedication(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // check vMedication, vDate, vDosage
  a = form.vMedication.value;
  b = form.vDate.value;

  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (a.length == 0) {
    alert("Please enter the medication.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}



function checkProgress(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   
      
  // check dCreated
  a = form.dCreated.value;
  
  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}  



function checkOutcome(form) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = true;
  //    }   
      
  // check dLastContact, dClosing
  a = form.dLastContact.value
  b = form.dClosing.value
  
  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}



function checkHCFASecondary(form) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = true;
  //    }   
      
  // check vSecondaryDOB
  a = form.vSecondaryDOB.value

  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}



function checkHCFAClient(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   
      
  a = form.vHospitalStartDate.value;
  b = form.vHospitalEndDate.value;
  c = form.vCurrentIllnessDate.value;
  d = form.vPreviousIllnessDate.value;
  e = form.vUnableStartDate.value;
  f = form.vUnableEndDate.value;
  g = form.dSigDate.value;
  h = form.vWorkReturnDate.value;
  
  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c.length > 0 && checkError(checkDate(c),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (d.length > 0 && checkError(checkDate(d),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }      
  
  if (e.length > 0 && checkError(checkDate(e),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  if (f.length > 0 && checkError(checkDate(f),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  if (g.length > 0 && checkError(checkDate(g),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (h.length > 0 && checkError(checkDate(h),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}



function checkHCFAInsured(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   
      
  // check two dates and the SS #
  // vInsuredSSNumber, vInsuredDOB, dInsuredSigDate
  a = form.vInsuredSSNumber.value;
  b = form.vInsuredDOB.value;
  c = form.dInsuredSigDate.value;
  
  if (a.length > 0 && checkError(checkSSNumber(a),ssMsg) == 1) { 
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c.length > 0 && checkError(checkDate(c),dateMsg) == 1) { 
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}



function checkError(e,m) {
  if (e == false) {
    alert(m);
    return 1;
  }
}



function checkPaymentInfo(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // vSSNumber, vDOB
  a = form.vSSNumber.value;
  b = form.vDOB.value;
  ph = form.vPhoneHome.value;
  pw = form.vPhoneWork.value;

  if (a.length > 0 && checkError(checkSSNumber(a),ssMsg) == 1) { 
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  if (ph.length > 0 && checkError(checkPhone(ph),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (pw.length > 0 && checkError(checkPhone(pw),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}



function checkSummary(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // start, end
  a = form.start.value;
  b = form.end.value;
  
  if (a.length == 0 || b.length == 0) {
    alert("Please enter Start and End dates");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  if (checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }     
}



function checkInsuranceInfo(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // start, end
  a = form.vHolderPhone.value;
  b = form.vPhone.value;
  
  if (a.length > 0 && checkError(checkPhone(a),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  if (b.length > 0 && checkError(checkPhone(b),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }   
  
  x = form.iClientPct.value;
  y = form.iInsurancePct.value;
  c = form.iCopayClient.value;
  d = form.iCopayInsurance.value;
  e = form.iCopayTotal.value;
  
  if (x.length > 0 && y.length > 0) {
    if (parseFloat(x) + parseFloat(y) != 100) {
      alert("Client % and Insurance % must equal 100");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
      return false;
    }
  }
    
  if (c.length > 0 && !parseFloat(c)) {
    alert("The Client Co-pay amount must be a valid amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (d.length > 0 && !parseFloat(d)) {
    alert("The Insurance Co-pay amount must be a valid amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (e.length > 0 && !parseFloat(e)) {
    alert("The Total Amount Insurance Allows must be a valid amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
}



function checkTrans(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // dTransactionDate
  a = form.dTransactionDate.value;
  b = form.vPaymentDate.value;
  
  if (checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }   
  
  if (b.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}



function checkClientInfo(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  // client status, patient status, first name, last name, SS#, birth date
  //a = form.laClientStatus.options[form.laClientStatus.selectedIndex].value;
  b = form.laPatientStatus.options[form.laPatientStatus.selectedIndex].value;
  c = form.vFirstname.value;
  d = form.vLastname.value;
  u = form.vUsername.value;
  e = form.vSSNumber.value;
  f = form.vDOB.value;
  ph = form.vPhoneHome.value;
  pw = form.vPhoneWork.value;
  
  //if (a.length == 0) {
  //  alert("Please choose a Patient Type.");
  //  return false;
  //}
  
  if (b.length == 0) {
    alert("Please choose a Client Type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (c.length == 0) {
    alert("Please enter a First Name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
    
  if (d.length == 0) {
    alert("Please enter a Last Name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  

  if (u.length == 0) {
    alert("Please enter a Username.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  

  if (form.vPassword) {
   if (form.vPassword.value.length == 0) {
    alert("Please enter a password for the client; this will allow the user to log on to HelpHorizons.com");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
   }
   if (form.vPassword.value != form.vConfirm.value) {
    alert("Please make sure the password matches the confirmation; this will allow the user to log on to HelpHorizons.com");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
   }
  }   

	if (e.length > 0) {
		if (checkError(checkSSNumber(e),ssMsg) == 1) {
			if (form.submitBtn) {
				form.submitBtn.disabled = false;
			}   
			return false;
		}
	}
  
  
    var State = form.lcState.options[form.lcState.selectedIndex].value;
    var Country = form.lcCountry.options[form.lcCountry.selectedIndex].value;
    
    if (Country == '') {
      alert("You must select a Country.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
      return false;
    } else if (Country == 'US') {
		if (State == '') {
			alert("You must select a State.")
			if (form.submitBtn) {
			  form.submitBtn.disabled = false;
			}   
			return false;
		} 
    } else {
		if (State != '') {
			alert("The State field can only be specified when United States was selected as a country.")
			if (form.submitBtn) {
			  form.submitBtn.disabled = false;
			}   
			return false;
		} 
    }  
  
  
  if (ph.length > 0 && checkError(checkPhone(ph),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (pw.length > 0 && checkError(checkPhone(pw),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length > 0 && checkError(checkDate(f),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  return true;
}





function checkCommunicate(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   
      
  // Name, Email, suggestions
  a = form.Name.value;
  b = form.Email.value;
  c = form.suggestions.value;
  
  if (a.length == 0) {
    alert("Please enter your name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b.length == 0) {
    alert("Please enter your e-mail address.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c.length == 0) {
    alert("Please enter your suggestions.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkAppt(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  p = form.pzPatient.options[form.pzPatient.selectedIndex].value;
  
  //a = form.laMonth.options[form.laMonth.selectedIndex].value;
  //b = form.laDay.options[form.laDay.selectedIndex].value;
  //c = form.liYear.options[form.liYear.selectedIndex].value;
  
  d = form.liHour.options[form.liHour.selectedIndex].value;
  e = form.liDuration.options[form.liDuration.selectedIndex].value;
  f = form.laSessionType.options[form.laSessionType.selectedIndex].value;
  CT = form.laChatTechnology.options[form.laChatTechnology.selectedIndex].value;
  g = form.vEvent.value;
  h = form.laRecurrence.options[form.laRecurrence.selectedIndex].value;
  //i = form.vRecurrenceStart.value;
  
  
  //j = form.vRecurrenceEnd.value;
  
  
  o = form.laOfficeCode.options[form.laOfficeCode.selectedIndex].value;
  
  if (p == "group" && f != 2 && f != 4) {
    alert("If you are selecting a 'Group Session', you must choose an appropriate Type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  //if (a.length == 0) {
  //  alert("Please enter the month.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  //if (b.length == 0) {
  //  alert("Please enter the day.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  //if (c.length == 0) {
  //  alert("Please enter the year.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  if (d.length == 0) {
    alert("Please enter the hour.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (e.length == 0) {
    alert("Please enter the duration.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length == 0) {
    alert("Please enter the session type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    
  
  if (CT.length == 0) {
	if (f == 1 || f == 2) {
		alert("Please specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   
		return false;
	}
  } else {
	if (f == 1 || f == 2) {
		// fine
	} else {
		alert("You can only specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   
		return false;
	}
  }  

  if (g.length == 0) {
    alert("Please enter the title of the appointment.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  //if (i.length > 0 && checkError(checkDate(i),dateMsg) == 1) {
  //  return false;
  //}
  
  //if (j.length > 0 && checkError(checkDate(j),dateMsg) == 1) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //} 
  
  //if (i.length > 0 && j.length == 0) {
  //  alert("You must enter an End Date if you enter a Start Date");
  //  return false;
  //}

  //if (j.length > 0 && i.length == 0) {
  //  alert("You must enter a Start Date if you enter an End Date");
  //  return false;
  //} 
  
  if ((f == 3 || f == 4) && o == "") {
    alert("You must choose a location for face-to-face meetings.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}



function checkAppt2(form) {
  //    if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
 //    }   

  //a = form.m.options[form.m.selectedIndex].value;
  //b = form.d.options[form.d.selectedIndex].value;
  //c = form.y.options[form.y.selectedIndex].value;
  z = form.h.options[form.h.selectedIndex].value;
  y = form.i.options[form.i.selectedIndex].value;
  f = form.stype.options[form.stype.selectedIndex].value;
  CT = form.laChatTechnology.options[form.laChatTechnology.selectedIndex].value;
  g = form.e.value;
  h = form.recurrence.value;
  //i = form.rStart.value;
  //j = form.rEnd.value;
  o = form.office.value;
  
  //if (a.length == 0) {
  //  alert("Please enter the month.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }       
  //  return false;
  //}
  
  //if (b.length == 0) {
  //  alert("Please enter the day.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  //if (c.length == 0) {
  //  alert("Please enter the year.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }       
  //  return false;
  //}
  
  if (z.length == 0) {
    alert("Please enter the hour.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (y.length == 0) {
    alert("Please enter the duration.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (f.length == 0) {
    alert("Please enter the session type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }    

  if (CT.length == 0) {
	if (f == 1 || f == 2) {
		alert("Please specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   		
		return false;
	}
  } else {
	if (f == 1 || f == 2) {
		// fine
	} else {
		alert("You can only specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   		
		return false;
	}
  }  

  if (g.length == 0) {
    alert("Please enter the title of the appointment.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  } 
  
  //if (i.length > 0 && checkError(checkDate(i),dateMsg) == 1) {
  //  return false;
  //}
  
  //if (j.length > 0 && checkError(checkDate(j),dateMsg) == 1) {
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //} 
  
  //if (i.length > 0 && j.length == 0) {
  //  alert("You must enter an End Date if you enter a Start Date");
  //  return false;
  //}

  //if (j.length > 0 && i.length == 0) {
  //  alert("You must enter a Start Date if you enter an End Date");
  //  return false;
  //}  
  
  if ((f == 3 || f == 4) && o == "") {
    alert("You must choose a location for face-to-face meetings.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkChat(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  cg = form.laChatGroup.options[form.laChatGroup.selectedIndex].value;
  a = form.laTopic.options[form.laTopic.selectedIndex].value;
  b = form.vChat.value;
  c = form.tDescription.value;
  d = form.dDateTime.value;
  e = form.iDuration.value;
  f = form.time.value;
  
  if (cg == '1' && a == '0') {
    alert("Please select a topic.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (b.length == 0) {
    alert("Please enter the chat subject.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c.length == 0) {
    alert("Please enter the description.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (checkError(checkDate(d),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (e.length == 0) {
    alert("Please enter the duration.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length == 0) {
    alert("Please enter the time.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;     
}




function checkAdv(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

  a = form.advert.value;

  if (a.length == 0) {
    alert("Please enter your advertisement.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  return true;
}





function checkProfile1(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  a = form.vUsername.value.replace(/\s*/g,"");
  b = form.vPassword.value.replace(/\s*/g,"");
  c = form.vConfirm.value.replace(/\s*/g,"");
  d = form.vLastname.value;
  e = form.vFirstname.value;
  
  a1 = form.vWorkAddress1.value;
  ci = form.vWorkCity.value;
  zip = form.vWorkZipCode.value;
  f = form.lcWorkState.options[form.lcWorkState.selectedIndex].value;
  f1 = form.lcWorkCountry.options[form.lcWorkCountry.selectedIndex].value;

  g = form.vPracticeNumber.value;
  y = form.vStateExpDate.value;
  h = form.tStateReason.value.replace(/\s*/g,"").replace(/\r*/g,"");
  i = form.vInsuranceCarrier.value;
  j = form.vInsuranceNumber.value;
  z = form.vInsuranceExpDate.value;
  y1 = form.iYear1.value;
  y2 = form.iYear2.value;
  y3 = form.iYear3.value;
  pw = form.vPhoneWork.value;
  fax = form.vFax.value;
  
  //vDOB = form.vDOB.value;
  ag = form.laAgeGroup.options[form.laAgeGroup.selectedIndex].value;
  mi = form.cMiddleInitial.value;
  
  email = form.vEmail.value;
  confirmEmail = form.vConfirmEmail.value;
 
  
	// set the current date/time fields for timezone detection
	var mydate = new Date();
	var mm = mydate.getMinutes();
	if (mm < 10) {
		mm = '0' + mm;
	}	
	form.currentTime.value = mydate.getHours() + ':' + mm;
	
	var yy = mydate.getYear();
	if (yy < 120) {
		yy += 1900;
	}
	
	form.currentDay.value = mydate.getMonth()+1 + "/" + mydate.getDate() + "/" + yy;
	if  (mydate.getHours() < 12) {
		form.ampm.value = 'am';
	} else {
		form.ampm.value = 'pm';
	}      
	
  if (a.length == 0) {
    alert("Please enter your username.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (b.length == 0) {
    alert("Please enter your password.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (b != c) {
    alert("Please make sure your password matches the confirmation password.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  // new logic - 3/14/2001 by AShaw
  if (b.toLowerCase() == a.toLowerCase()) {
    alert("Your password cannot be the same as your username.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }   

  if (b.toLowerCase() == d.toLowerCase()) {
    alert("Your password cannot be the same as your last name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    

  if (b.toLowerCase() == e.toLowerCase()) {
    alert("Your password cannot be the same as your first name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  

  if (b.toLowerCase() == ci.toLowerCase()) {
    alert("Your password cannot be the same as your city.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (b.length < 6) {
    alert("Your password must be at least 6 characters.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  if (d.length == 0) {
    alert("Please enter your last name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (e.length == 0) {
    alert("Please enter your first name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    

  if (ag.length == 0) {
    alert("Please provide your age group.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    

  if (email == '') {
    alert("Please enter your e-mail address.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (email != confirmEmail) {
    alert("Please make sure your email address matches the confirmation.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
    
  if (mi.length > 1) {
    alert("Please limit your middle initial to one character only.  Do not use a period at the end.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (a1.length == 0) {
    alert("Please enter your work address.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (ci.length == 0) {
    alert("Please enter your work city.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length == 0) {
    alert("Please select your work state.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (f1.length == 0) {
    alert("Please select your work country.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (zip.length == 0) {
    alert("Please enter your work zip code.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if ( (g.length == 0 || y.length == 0) && h.length == 0) {
    alert("You must either type in your State License information or give a reason for not having it.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (i.length == 0 || z.length == 0 || j.length == 0) {
    alert("You must type in all your Insurance information.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (pw.length > 0 && checkError(checkPhone(pw),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  

  if (fax.length > 0 && checkError(checkPhone(fax),faxMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (y1.length > 0 && isNaN(y1)) {
    alert("Please enter a valid year for receiving a degree.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (y2.length > 0 && isNaN(y2)) {
    alert("Please enter a valid year for receiving a degree.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (y3.length > 0 && isNaN(y3)) {
    alert("Please enter a valid year for receiving a degree.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  return true;
}




function checkShortCCDate(z) {
 
  errorFound = 0;
  
  dArray = z.split("/");
     
  if (dArray.length < 2) {
    errorFound = 1;
  } else {
    m = dArray[0];
    y = dArray[1];
  }

  if (errorFound != 1) {
    if (m < 1 || m > 12) {
      errorFound = 1;
    }
  
    if (y.length != 2) {
      errorFound = 1;
    }
  }
  
  if (errorFound == 1) {
    return false;
  }
  
  return true;
}




function checkShortDate(z) {
 
  errorFound = 0;
  
  dArray = z.split("/");
     
  if (dArray.length < 2) {
    errorFound = 1;
  } else {
    m = dArray[0];
    y = dArray[1];
  }

  if (errorFound != 1) {
    if (m < 1 || m > 12) {
      errorFound = 1;
    }
  
    if (y.length != 2 && y.length != 4) {
      errorFound = 1;
    }
  }
  
  if (errorFound == 1) {
    return false;
  }
  
  return true;
}




function checkFutureShortDate(z) {
 
  todaysDate = new Date();
 
  errorFound = 0;
  
  dArray = z.split("/");
     
  if (dArray.length < 2) {
    errorFound = 1;
  } else {
    m = dArray[0];
    y = dArray[1];
  }

  if (errorFound != 1) {
    if (m < 1 || m > 12) {
      errorFound = 1;
    }
  
    if (y.length != 4) {
      errorFound = 1;
    }
    
    if (todaysDate.getYear() > y) {
	  errorFound = 1;
    }
    
    if (todaysDate.getYear() == y && todaysDate.getMonth() > m) {
	  errorFound = 1;
    }
  }
  
  if (errorFound == 1) {
    return false;
  }
  
  return true;
}




function verify_ccard(inNumber, type)
{
        total = 1*0;
        tmp = 1*0;

        number = "";

        // make sure there are only numbers in the string...
        for(i = 0; i < inNumber.length; i++)
        {
                if(inNumber.charAt(i) >= "0" && inNumber.charAt(i) <= "9")
                {
                        number = number + inNumber.charAt(i);
                }
        }

        if(number.length < 13) return 10; // too short for anything

        first = "" + number.charAt(0);
        second = "" + number.charAt(1);
        third = "" + number.charAt(2);
        firstTwo = first + second;
        firstFour = firstTwo + third + number.charAt(3);

        if(type == "2")
        {
                if(first != "5" || second < "1" || second > "5")
                        return 11;// invalid Mastercard prefix
                if(number.length != 16)
                        return 21;
        }
        else if(type == "1")
        {
                if(first != "4")
                        return 12;// invalid Visa prefix
                if(number.length != 13 && number.length != 16)
                        return 22;
        }
        else if(type == "3")
        {
                if(first != "3" || (second != "4" && second != "7"))
                        return 13;// invalid American Express Prefix
                if(number.length != 15) 
                        return 23;
        }
		else 
		{
			return 29;
		}

        // now check the credit card suffix and length vs. the type

    
         // do the check sum
        for(loc = number.length - 2; loc >= 0; loc -= 2)
        {
                total += 1 * number.charAt(loc +1);
                tmp = number.charAt(loc) * 2;
                if(tmp > 9) total += 1;
                total += tmp%10;
        }
        if(number.length % 2 > 0)
        total += 1 * number.charAt(0);


        return (total % 10);
}




function isCreditCard(num,type) {
        errorStrings = new Array(
                "Hee Hee.  No error here!", //0
                "Check sum failed", //1
                "Check sum failed", //2
                "Check sum failed", //3
                "Check sum failed", //4
                "Check sum failed", //5
                "Check sum failed", //6
                "Check sum failed", //7
                "Check sum failed", //8
                "Check sum failed", //9
                "Number of digits must be greater than 12", //10
                "Master Card prefix must be 51-55", //11
                "Visa prefix must be 4", //12
                "American Express prefix must be 34 or 37", //13
                "Discover prefix must be 6011", //14
                "Diner's Club/Carte Blanche prefix must be 36, 38, or 300-305", //15
                "enRoute prefix must be 2014 or 2149", //16
                "JCB prefix must be 3, 2131 or 1800", //17
                "Why are you reading my source?", //18
                "Are you just a glutton for punishment?", //19
                "Insert comment here.", //20
                "Number of digits must be 16 for Master Card", //21
                "Number of digits must be 13 or 16 for Visa", //22
                "Number of digits must be 15 for American Express", //23
                "Number of digits must be 16 for Discover ", //24
                "Number of digits must be 14 for Diner's Club/Carte Blanche", //25
                "Number of digits must be 15 for enRoute", //26
                "Number of digits must be 16 for JCB with prefix of 3", //27
                "Number of digits must be 15 for JCB with prefix of 2131 or 1800", //28
                "Please select a credit card") //29

        if((reason = verify_ccard(num, type)) == 0)
        {
                return 0;
        }
        else
        {
                alert("Card Number Invalid. " + errorStrings[reason] + ".");
                return reason;
        }
}




function checkCCInfo(form) {
 //     if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
  //    }   
      
  a = form.vNameOnCard.value;
  b = form.laCreditCardType.options[form.laCreditCardType.selectedIndex].value;
  c = form.vCreditCardNumber.value;
  d = form.vCreditCardExpiration.value;

  if (a.length == 0) {
    alert("Please enter the name on the card.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (b.length == 0) {
    alert("Please enter the credit card type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (isCreditCard(c,b) > 0) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (checkError(checkFutureShortDate(d),futuredateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  return true;
}




function checkPayCCInfo(form) {
 //     if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
  //    }   

  a = form.vNameOnCard.value;
  b = form.laCreditCardType.options[form.laCreditCardType.selectedIndex].value;
  c = form.vCreditCardNumber.value;
  d = form.vCreditCardExpiration.value;
  e = form.vMerchantAccountNumber.value;
  f = form.vMerchantPhone.value;
  g = form.vAuthorizationNumber.value;
  
  if (a.length == 0) {
    alert("Please enter the name on the card.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (b.length == 0) {
    alert("Please enter the credit card type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (isCreditCard(c) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 

  if (checkError(checkShortDate(d),shortdateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  if (e.length == 0) {
    alert("Please enter your account number.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length == 0) {
    alert("Please enter your phone number.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (g.length == 0) {
    alert("Please enter the authorization number.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkProfile2a_noCC(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

	e = form.vHintQuestion.value;
	f = form.vHintAnswer.value;

	if (e.length == 0) {
		alert("Please enter your hint question.");
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   		
		return false;
	}

	if (f.length == 0) {
		alert("Please enter your hint answer.");
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   		
		return false;
	}
	  
	return true;
}




function checkProfile2a(form) {
  //    if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
  //    }   
      
  a = form.laCreditCardType.options[form.laCreditCardType.selectedIndex].value;
  b = form.vCreditCardNumber.value;
  c = form.vNameOnCard.value;
  d = form.dCCExpDate.value;
  e = form.vHintQuestion.value;
  f = form.vHintAnswer.value;

  if (a.length == 0) {
    alert("Please enter your credit card type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (isCreditCard(b,a) > 0) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }     
    return false;
  }  
  
  if (c.length == 0) {
    alert("Please enter your name on card.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (checkError(checkFutureShortDate(d),futuredateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    

  if (e.length == 0) {
    alert("Please enter your hint question.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (f.length == 0) {
    alert("Please enter your hint answer.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkProfile2b(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

  a = form.tBio.value.replace(/\s*/g,"").replace(/\r*/g,"");

  if (a.length == 0) {
    alert("Please enter your bio.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (a.length > 1500) {
    alert("The bio cannot exceed 1500 characters");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkWordCount(z) {
  alert("Current character count: " + z.value.length);
  return true;
}




function checkTopic(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   
      
  a = form.Name.value;
  //b = form.Description.value;
  
  if (a.length == 0) {
    alert("Please enter a topic name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  //if (b.length == 0) {
  //  alert("Please enter a description.");
  //  return false;
  //}
  
  return true;
}



function checkTimeZone(form) {
  //    if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
  //    }   
      
  a = form.currentTime.value;
  b = form.ampm.value;
  c = form.currentDay.value;

  if (checkError(checkDate(c),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }     
    return false;
  }  

  aArray = a.split(":");
     
  if (aArray.length != 2) {
    alert("Invalid time.  Please use hh:mm format.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } else {
    h = aArray[0];
    m = aArray[1];
    if (h < 1 || h > 12) {
      alert("Invalid time.  Please use hh:mm format.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
      return false;
    }
    if (m < 0 || m > 59) {
      alert("Invalid time.  Please use hh:mm format.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
      return false;
    } 
  }
  
  if (b.length == 0) {
    alert("Please select am/pm.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkConsumerAppt(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   

  //a = form.laMonth.options[form.laMonth.selectedIndex].value;
  //b = form.laDay.options[form.laDay.selectedIndex].value;
  //c = form.liYear.options[form.liYear.selectedIndex].value;
  //d = form.liHour.options[form.liHour.selectedIndex].value;
  e = form.liDuration.options[form.liDuration.selectedIndex].value;
  f = form.laSessionType.options[form.laSessionType.selectedIndex].value;
  CT = form.laChatTechnology.options[form.laChatTechnology.selectedIndex].value;
  g = form.vEvent.value;
  //o = form.laOfficeCode.value;
  
  //if (a.length == 0) {
  //  alert("Please enter the month.");
  //  return false;
  //}
  
  //if (b.length == 0) {
  //  alert("Please enter the day.");
  //  return false;
  //}
  
  //if (c.length == 0) {
  //  alert("Please enter the year.");
  //  return false;
  //}
  
  //if (d.length == 0) {
  //  alert("Please enter the hour.");
  //  return false;
  //}
  
  if (e.length == 0) {
    alert("Please enter the duration.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length == 0) {
    alert("Please enter the session type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }    
  
  if (CT.length == 0) {
	if (f == 1 || f == 2) {
		alert("Please specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   
		return false;
	}
  } else {
	if (f == 1 || f == 2) {
		// fine
	} else {
		alert("You can only specify the chat technology for online sessions.")
		if (form.submitBtn) {
		  form.submitBtn.disabled = false;
		}   
		return false;
	}
  }  
  

  if (g.length == 0) {
    alert("Please enter the event.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  //if ((f == 3 || f == 4) && o == "") {
  //  alert("You must choose a location for face-to-face meetings.");
  //  return false;
  //}
  
  return true;
}




function checkReport(form) {
 //     if (form.submitBtn) {
 //	    form.submitBtn.disabled = true;
 //     }   
      
  a = form.start.value;
  b = form.end.value;

  if (a.length == 0 || b.length == 0) {
    alert("Please enter both start and end dates.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
  
  if (checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  if (checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }     
}




function checkBillingSearch(form) {
  //    if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
  //    }   
      
  a = form.startdate.value;
  b = form.enddate.value;

  if (a.length > 0 && checkError(checkDate(a),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
  
  if (b.length > 0 && checkError(checkDate(b),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  } 
}




function checkCabinet(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

  a = form.vPhoneWork.value;
  //b = form.vMerchantPhone.value;
  c = form.laFederalTax.options[form.laFederalTax.selectedIndex].value;
  d = form.vTaxNumber.value;
  e = form.vBillingname.value;
  f = form.vSSNumber.value
  
  if (e.length == 0) {
    alert("Please enter a billing name.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }       
    return false;
  }
    
  if (a.length > 0 && checkError(checkPhone(a),phoneMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  //if (b.length > 0 && checkError(checkPhone(b),phoneMsg) == 1) {
  //    if (form.submitBtn) {
  //    form.submitBtn.disabled = false;
  //    }     
  //  return false;
  //}  
  
  if (c == "") {
    alert("You must choose a Federal Tax type (SSN or EIN).");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c == "1" && f.length != 0) {
    alert("Note:  Because you selected SSN as your Federal Tax type, your Social Security number will be used as your Tax Number.");
  }
  
  if (c == "1" && f.length == 0) {
    alert("If you select SSN as your Federal Tax type, you must enter your Social Security number.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c == "2" && d.length == 0) {
    alert("If you select EIN as your Federal Tax type, you must type in a Federal Tax number.")
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c == "2" && d.length > 0 && d.length != 9) {
    alert("Invalid EIN Federal Tax number.  Please type in your nine-digit number.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
}




function checkTransMath(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

  a = form.mAmountTotal.value;
  b = form.mAmountDueClient.value;
  c = form.mAmountDueIns.value;
  d = form.mAmountPaidClient.value;
  e = form.mAmountPaidIns.value;
  f = form.mAmountWriteoff.value;
  g = form.mAmountAdjustment.value;
  
  if (a.length == 0) {
    document.form1.mAmountTotal.value = 0;
    a = document.form1.mAmountTotal.value;
  }
  
  if (b.length == 0) {
    document.form1.mAmountDueClient.value = 0;
    b = document.form1.mAmountDueClient.value;
  }
  
  if (c.length == 0) {
    document.form1.mAmountDueIns.value = 0;
    c = document.form1.mAmountDueIns.value;
  }  
  
  if (d.length == 0) {
    document.form1.mAmountPaidClient.value = 0;
    d = document.form1.mAmountPaidClient.value;
  }  
  
  if (e.length == 0) {
    document.form1.mAmountPaidIns.value = 0;
    e = document.form1.mAmountPaidIns.value;
  }  
  
  if (f.length == 0) {
    document.form1.mAmountWriteoff.value = 0;
    f = document.form1.mAmountWriteoff.value;
  }  
  
  if (g.length == 0) {
    document.form1.mAmountAdjustment.value = 0;
    g = document.form1.mAmountAdjustment.value;
  }  
  
  if (!parseFloat(a) && a != 0) {
    alert("Please make sure the Billable Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (!parseFloat(b) && b != 0) {
    alert("Please make sure the Amount Due-Client Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (!parseFloat(c) && c != 0) {
    alert("Please make sure the Amount Due-Insurance Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (!parseFloat(d) && d != 0) {
    alert("Please make sure the Amount Paid-Client Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (!parseFloat(e) && e != 0) {
    alert("Please make sure the Amount Paid-Insurance Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length > 0 && !parseFloat(f) && f != 0) {
    alert("Please make sure the Writeoff Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false; 
  }
  
  if (g.length > 0 && !parseFloat(g) && g != 0) {
    alert("Please make sure the Adjustment Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false; 
  }
  
  if (a < 0 || b < 0 || c < 0 || d < 0 || e < 0) {
    alert("Please make sure every dollar value is greater than or equal to zero.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (f.length > 0 && f < 0) {
    alert("The Writeoff Amount cannot be a negative amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (g.length > 0 && g < 0) {
    alert("The Adjustment Amount cannot be a negative amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
     
  if (parseFloat(b) + parseFloat(c) + parseFloat(d) + parseFloat(e) != parseFloat(a)) {
    alert("The Amount-Due values and the Amount-Paid values do not equal the Billable Amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}




function checkSuggest(form) {
 //     if (form.submitBtn) {
//	    form.submitBtn.disabled = true;
   //   }   

  a = form.Email.value.replace(/\s*/g,"").replace(/\r*/g,"");
  
  if (a.length == 0) {
    alert("You must enter an e-mail address.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  return true;
}




function checkPayment(form) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = true;
      }   

  d = form.dPaymentDate.value;
  a = form.mAmount.value;
  o = form.mOldAmount.value;
  b = form.laPaymentType.options[form.laPaymentType.selectedIndex].value;
  c = form.laPaidBy.options[form.laPaidBy.selectedIndex].value;
  
  if (checkError(checkDate(d),dateMsg) == 1) {
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }   
  
  if (a == "") {
    alert("Please enter an Amount.  Do not use a dollar sign ($)");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (!parseFloat(a) && a != 0) {
    alert("Please make sure the Amount is a dollar value.  Do not use a dollar sign ($) before the value.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }  
  
  if (parseFloat(a) > parseFloat(o)) {
    alert("You cannot charge an amount greater than the fee you charged the client ($" + o + ")");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (a < 0) {
    alert("The Amount cannot be a negative amount.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (b == "") {
    alert("Please select a Payment Type.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (c == "") {
    alert("Please select an entry under Paid By.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  return true;
}





function checkAvailable(form) {
   //   if (form.submitBtn) {
	//    form.submitBtn.disabled = true;
   //   }   

  //a = form.laMonth.options[form.laMonth.selectedIndex].value;
  //b = form.laDay.options[form.laDay.selectedIndex].value;
  //c = form.liYear.options[form.liYear.selectedIndex].value;
  d = form.liHour.options[form.liHour.selectedIndex].value;
  e = form.liDuration.options[form.liDuration.selectedIndex].value;
  f = form.laAvailable.options[form.laAvailable.selectedIndex].value;
  
  //if (a.length == 0) {
  //  alert("Please enter the month.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  //if (b.length == 0) {
  //  alert("Please enter the day.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  //if (c.length == 0) {
  //  alert("Please enter the year.");
  //    if (form.submitBtn) {
  //	    form.submitBtn.disabled = false;
  //    }   
  //  return false;
  //}
  
  if (d.length == 0) {
    alert("Please enter the hour.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  if (e.length == 0) {
    alert("Please enter the duration.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }

  if (f.length == 0) {
    alert("Please enter the type of session you are available for.");
      if (form.submitBtn) {
	    form.submitBtn.disabled = false;
      }   
    return false;
  }
  
  return true;
}