function validate_appointment(theform){
	var useremail;
	var name = theform.Name;
	var phone = theform.Phone;
	var email = theform.Email;
	var feedback = theform.FeedBackDescription;

	useremail=isEmail(email.value);

	if (name.value==""){
		alert("Name cannot be blank.");
		name.focus();
		return false;
	}

	if (phone.value==""){
		alert("Phone cannot be blank.");
		phone.focus();
		return false;
	}

	if (useremail==false){
		alert("Please enter your proper email address.");
		email.focus();
		return false;
	}

	if (feedback.value==""){
		alert("Comments cannot be blank.");
		feedback.focus();
		return false;
	}
}

function validate_newsletter(theform){
	var useremail;
	var name = theform.Name;
	var email = theform.Email;

	useremail=isEmail(email.value);

	if (name.value==""){
		alert("Name cannot be blank.");
		name.focus();
		return false;
	}

	if (useremail==false){
		alert("Please enter your proper email address.");
		email.focus();
		return false;
	}
}

function validate_patientonlineform(theform){
	var useremail;
	var first = theform.First;
	var last = theform.Last;
	var optometrist = theform.Optometrist;
	var phone = theform.Phone;
	var email = theform.Email;
	var optpatientstatus = valButton(theform.PatientStatus);
	var feedback = theform.FeedBackDescription;

	useremail=isEmail(email.value);

	if (first.value==""){
		alert("First Name cannot be blank.");
		first.focus();
		return false;
	}

	if (last.value==""){
		alert("Last Name cannot be blank.");
		last.focus();
		return false;
	}

	if (optometrist.selectedIndex==0){
		alert("Please select your optometrist from the list.");
		optometrist.focus();
		return false;
	}

	if (phone.value==""){
		alert("Phone cannot be blank.");
		phone.focus();
		return false;
	}

	if (useremail==false){
		alert("Please enter your proper email address.");
		email.focus();
		return false;
	}

	if (optpatientstatus==null){
		alert("Please select if you're a current patient or new patient.");
		return false;
	}

	if (feedback.value==""){
		alert("Comments cannot be blank.");
		feedback.focus();
		return false;
	}
}

function validate_medicalonlineform(theform){
	var name = theform.Name;
	var optallergiestomedicines = valButton(theform.opt_AllergiesToMedicines);
	var allergiestomedicines = theform.txt_AllergiesToMedicines;
	var listofmedications = theform.txt_ListOfMedications;
	var overthecountereyedrops = theform.txt_OverTheCounterEyeDrops;
	var allmajorinjuries = theform.txt_AllMajorInjuries;
	var optpregnantornursing = valButton(theform.opt_PregnantOrNursing);
	var eyedisease = theform.txt_EyeDisease;
	var optdriving = theform.opt_Driving;
	var optvisualdifficultydriving = valButton(theform.opt_VisualDifficultyDriving);
	var visualdifficultydriving = theform.txt_VisualDifficultyDriving;
	var optsmoking = valButton(theform.opt_Smoking);
	var smoking = theform.txt_Smoking;
	var optdrinking = valButton(theform.opt_Drinking);
	var drinking = theform.txt_Drinking;
	var optillegaldrugs = valButton(theform.opt_IllegalDrugs);
	var illegaldrugs = theform.txt_IllegalDrugs;
	var optinfectedwith = valButton(theform.opt_InfectedWith);
	var optbirthcontrol = valButton(theform.opt_BirthControl);
	var birthcontrol = theform.txt_BirthControl;

	if (name.value==""){
		alert("Name cannot be blank.");
		name.focus();
		return false;
	}

	if (optallergiestomedicines==null){
		alert("Please select if you have any allergies or bad reaction to medicines or drugs.");
		return false;
	}
	else if (optallergiestomedicines.toLowerCase()=="yes"){
		if (allergiestomedicines.value==""){
			alert("Please indicate when and how severe.");
			allergiestomedicines.focus();
			return false;
		}
	}

	if (listofmedications.value==""){
		alert("List any medications you take.");
		listofmedications.focus();
		return false;
	}

	if (overthecountereyedrops.value==0){
		alert("Do you take over the counter eye drops? How often?");
		overthecountereyedrops.focus();
		return false;
	}

	if (allmajorinjuries.value==""){
		alert("List all major lnjuries, surgeries and/or hospitalizations you have had.");
		allmajorinjuries.focus();
		return false;
	}

	if (optpregnantornursing==null){
		alert("Please select if you are pregnant or nursing.");
		return false;
	}

	if (eyedisease.value==""){
		alert("List any of the following eye disease that you have had.");
		eyedisease.focus();
		return false;
	}

	var thetext=new Array()
	thetext[0] = "Blindness";
	thetext[1] = "Cataract";
	thetext[2] = "Crossed Eyes";
	thetext[3] = "Glaucoma";
	thetext[4] = "Macular Degeneration";
	thetext[5] = "Retinal Detachment";
	thetext[6] = "Arthritis";
	thetext[7] = "Cancer";
	thetext[8] = "Diabetes";
	thetext[9] = "Heart Disease";
	thetext[10] = "HighBlood Pressure";
	thetext[11] = "Kidney Disease";
	thetext[12] = "Lupus";
	thetext[13] = "Thyroid Disease";
	//thetext[14] = "Other Disease";

	var opt1 = valButton(theform.opt_Blindness);
	var opt2 = valButton(theform.opt_Cataract);
	var opt3 = valButton(theform.opt_CrossedEyes);
	var opt4 = valButton(theform.opt_Glaucoma);
	var opt5 = valButton(theform.opt_MacularDegeneration);
	var opt6 = valButton(theform.opt_RetinalDetachment);
	var opt7 = valButton(theform.opt_Arthritis);
	var opt8 = valButton(theform.opt_Cancer);
	var opt9 = valButton(theform.opt_Diabetes);
	var opt10 = valButton(theform.opt_HeartDisease);
	var opt11 = valButton(theform.opt_HighBloodPressure);
	var opt12 = valButton(theform.opt_KidneyDisease);
	var opt13 = valButton(theform.opt_Lupus);
	var opt14 = valButton(theform.opt_ThyroidDisease);
	//var opt15 = valButton(theform.opt_OtherDisease);

	var opt=new Array()
	opt[0] = opt1;
	opt[1] = opt2;
	opt[2] = opt3;
	opt[3] = opt4;
	opt[4] = opt5;
	opt[5] = opt6;
	opt[6] = opt7;
	opt[7] = opt8;
	opt[8] = opt9;
	opt[9] = opt10;
	opt[10] = opt11;
	opt[11] = opt12;
	opt[12] = opt13;
	opt[13] = opt14;
	//opt[14] = opt15;

	for (i = 0;  i <= 13;  i++){
		if (opt[i]==null){
			alert("Please select if you have "+thetext[i]+" history.");
			return false;
		}
	}

	if (optdriving==null){
		alert("Please select if you drive or not.");
		return false;
	}

	if (optvisualdifficultydriving==null){
		alert("Please select if you have visual difficulty in driving.");
		return false;
	}
	else if (optvisualdifficultydriving.toLowerCase()=="yes"){
		if (visualdifficultydriving.value==""){
			alert("Please indicate a brief description.");
			visualdifficultydriving.focus();
			return false;
		}
	}

	if (optsmoking==null){
		alert("Please select if you use tobacco products.");
		return false;
	}
	else if (optsmoking.toLowerCase()=="yes"){
		if (smoking.value==""){
			alert("Please indicate a type/amount/how long.");
			smoking.focus();
			return false;
		}
	}

	if (optdrinking==null){
		alert("Please select if you drink alcohol.");
		return false;
	}
	else if (optdrinking.toLowerCase()=="yes"){
		if (drinking.value==""){
			alert("Please indicate a type/amount/how long.");
			drinking.focus();
			return false;
		}
	}

	if (optillegaldrugs==null){
		alert("Please select if you use illegal drugs.");
		return false;
	}
	else if (optillegaldrugs.toLowerCase()=="yes"){
		if (illegaldrugs.value==""){
			alert("Please indicate a type/amount/how long.");
			illegaldrugs.focus();
			return false;
		}
	}

	if (optinfectedwith==null){
		alert("Please select if you ever been exposed to or infected with these sexual disease.");
		return false;
	}

	if (optbirthcontrol!=null){
		if (optbirthcontrol.toLowerCase()=="yes"){
			if (birthcontrol.value==""){
				alert("Please indicate if you have problems in birth control.");
				birthcontrol.focus();
				return false;
			}
		}
	}

	var thetext_=new Array()
	thetext_[0] = "Fever, weight loss / gain";
	thetext_[1] = "Skin";
	thetext_[2] = "Headaches";
	thetext_[3] = "Migraines";
	thetext_[4] = "Dry Eyes";
	thetext_[5] = "Sandy or Gritty Feeling";
	thetext_[6] = "Burning";
	thetext_[7] = "Excess Tearing / Watering";
	thetext_[8] = "Itching";
	thetext_[9] = "Blurred Vision (with glasses)";
	thetext_[10] = "Blurred Vision (with contacts)";
	thetext_[11] = "Mucous Discharge";
	thetext_[12] = "Redness";
	thetext_[13] = "Glare / Light Sensitivity";
	thetext_[14] = "Eye Pain or Soreness";
	thetext_[15] = "Chronic Infection of Eyes of Lid";
	thetext_[16] = "Sties / Chalazion / Hordeolum";
	thetext_[17] = "Flashes / Floaters / Haloes";
	thetext_[18] = "Previous trouble with glasses";
	thetext_[19] = "Allergies / Hay Fever";
	thetext_[20] = "Sinus Congestion";
	thetext_[21] = "Post-Nasal Drip";
	thetext_[22] = "Dry Throat / Mouth";
	thetext_[23] = "Asthma";
	thetext_[24] = "Bronchitis / Emphysema";
	thetext_[25] = "Diabetes";
	thetext_[26] = "Heart Pain";
	thetext_[27] = "High Blood Pressure";
	thetext_[28] = "Heart Problems";
	thetext_[29] = "Diarrhea";
	thetext_[30] = "Constipation";
	thetext_[31] = "Gentials, kidney, bladder";
	thetext_[32] = "Rheumatoid Arthritis";
	thetext_[33] = "Muscle, Joint, Arthritis Pain";
	thetext_[34] = "Anemia";
	thetext_[35] = "Bleeding Problems";
	thetext_[36] = "Thyroid / other glands";
	thetext_[37] = "Allergic / Immunologic";

	var opt1_ = valButton(theform.opt_1);
	var opt2_ = valButton(theform.opt_2);
	var opt3_ = valButton(theform.opt_3);
	var opt4_ = valButton(theform.opt_4);
	var opt5_ = valButton(theform.opt_5);
	var opt6_ = valButton(theform.opt_6);
	var opt7_ = valButton(theform.opt_7);
	var opt8_ = valButton(theform.opt_8);
	var opt9_ = valButton(theform.opt_9);
	var opt10_ = valButton(theform.opt_10);
	var opt11_ = valButton(theform.opt_11);
	var opt12_ = valButton(theform.opt_12);
	var opt13_ = valButton(theform.opt_13);
	var opt14_ = valButton(theform.opt_14);
	var opt15_ = valButton(theform.opt_15);
	var opt16_ = valButton(theform.opt_16);
	var opt17_ = valButton(theform.opt_17);
	var opt18_ = valButton(theform.opt_18);
	var opt19_ = valButton(theform.opt_19);
	var opt20_ = valButton(theform.opt_20);
	var opt21_ = valButton(theform.opt_21);
	var opt22_ = valButton(theform.opt_22);
	var opt23_ = valButton(theform.opt_23);
	var opt24_ = valButton(theform.opt_24);
	var opt25_ = valButton(theform.opt_25);
	var opt26_ = valButton(theform.opt_26);
	var opt27_ = valButton(theform.opt_27);
	var opt28_ = valButton(theform.opt_28);
	var opt29_ = valButton(theform.opt_29);
	var opt30_ = valButton(theform.opt_30);
	var opt31_ = valButton(theform.opt_31);
	var opt32_ = valButton(theform.opt_32);
	var opt33_ = valButton(theform.opt_33);
	var opt34_ = valButton(theform.opt_34);
	var opt35_ = valButton(theform.opt_35);
	var opt36_ = valButton(theform.opt_36);
	var opt37_ = valButton(theform.opt_37);
	var opt38_ = valButton(theform.opt_38);

	var opt_=new Array()
	opt_[0] = opt1_;
	opt_[1] = opt2_;
	opt_[2] = opt3_;
	opt_[3] = opt4_;
	opt_[4] = opt5_;
	opt_[5] = opt6_;
	opt_[6] = opt7_;
	opt_[7] = opt8_;
	opt_[8] = opt9_;
	opt_[9] = opt10_;
	opt_[10] = opt11_;
	opt_[11] = opt12_;
	opt_[12] = opt13_;
	opt_[13] = opt14_;
	opt_[14] = opt15_;
	opt_[15] = opt16_;
	opt_[16] = opt17_;
	opt_[17] = opt18_;
	opt_[18] = opt19_;
	opt_[19] = opt20_;
	opt_[20] = opt21_;
	opt_[21] = opt22_;
	opt_[22] = opt23_;
	opt_[23] = opt24_;
	opt_[24] = opt25_;
	opt_[25] = opt26_;
	opt_[26] = opt27_;
	opt_[27] = opt28_;
	opt_[28] = opt29_;
	opt_[29] = opt30_;
	opt_[30] = opt31_;
	opt_[31] = opt32_;
	opt_[32] = opt33_;
	opt_[33] = opt34_;
	opt_[34] = opt35_;
	opt_[35] = opt36_;
	opt_[36] = opt37_;
	opt_[37] = opt38_;

	for (i = 0;  i <= 37;  i++){
		if (opt_[i]==null){
			alert("Please select if you have "+thetext_[i]+" problem.");
			return false;
		}
	}
}

function doEnable(fmobj, obj){
	for (var i=0;i<fmobj.elements.length;i++){
		var e = fmobj.elements[i];
		if ((e.name.indexOf(obj)!=-1) && (e.type=='checkbox')){
			e.disabled=false;
		}

		if ((e.name.indexOf(obj)==-1) && (e.type=='checkbox')){
			e.disabled=true;
			e.checked=false;
		}
	}
}
