// JavaScript Document
function verifyPreConsultation ( )
{

var theMessage = "Please complete the following: \n-----------------------------------\n";
var noErrors = theMessage

// Make sure a selection list is used
var listCheck = document.appointmentForm.title.selectedIndex;
if (document.appointmentForm.title.options[listCheck].value=="0") {
theMessage = theMessage + "\n --> Your Title";
}
// make sure field is not blank
if (document.appointmentForm.firstName.value=="") {
theMessage = theMessage + "\n --> Your FirstName";
}
// make sure field is not blank
if (document.appointmentForm.lastName.value=="") {
theMessage = theMessage + "\n --> Your LastName";
}
// make sure field is not blank
if (document.appointmentForm.age.value=="") {
theMessage = theMessage + "\n --> Your Age";
}

// validate an e-mail address
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.appointmentForm.email.value)){
theMessage = theMessage + "\n --> Enter a valid e-mail address";
}
// Make sure a selection list is used
var listCheck = document.appointmentForm.patient_status.selectedIndex;
if (document.appointmentForm.patient_status.options[listCheck].value=="0") {
theMessage = theMessage + "\n --> Please select patient status";
}
//
// Checking if at least one period button is selected. Or not. 
isChecked=false

for(var i=0;i<document.forms["appointmentForm"]["problem[]"].length;i++){
if(document.forms["appointmentForm"]["problem[]"][i].checked){
isChecked=true
}
}

if(isChecked==""){
theMessage = theMessage + "\n --> Do you have any of the following problems?";
}

// Checking if at least one period button is selected. Or not. 
isChecked=false

for(var i=0;i<document.forms["appointmentForm"]["I_am_interested_in[]"].length;i++){
if(document.forms["appointmentForm"]["I_am_interested_in[]"][i].checked){
isChecked=true
}
}

if(isChecked==""){
theMessage = theMessage + "\n --> I am interested in:";
}

// make sure field is not blank
if (document.appointmentForm.Additional_comments_or_questions.value=="") {
theMessage = theMessage + "\n --> Please enter details of your main concerns, what changes you would like to your teeth and smile and any other questions";
}
// Make sure a selection list is used
var listCheck = document.appointmentForm.how_did_you_hear_about_us.selectedIndex;
if (document.appointmentForm.how_did_you_hear_about_us.options[listCheck].value=="0") {
theMessage = theMessage + "\n --> Please complete survey ";
}
//checkbox
//if ( document.appointmentForm.I_agree_to_the_terms_and_conditions.checked == false ){
//theMessage = theMessage + "\n --> Please check to agree with our Terms & Conditions box";
//}



// If no errors, submit the form
if (theMessage == noErrors) {
return true;

} else {

// If errors were found, show alert message
alert(theMessage);
return false;
}
}
// End -->


