function calculate(frm )
{ // calculate

    // initalize the score to zero	
    var yourScore = 0
    var curValue = 0
    // Run through all the form fields and calculate the score

    for (var i=0; i < frm.elements.length; i++) 
    { // for 

        // Get the current field
        form_field = frm.elements[i]
	// check to see if it is a radio button or a check box

	if ( form_field.type == "radio" || form_field.type == "checkbox" )
	{ // type field check
        	// Get the field's name
	        form_name = form_field.name
		// print the field name - debugging purposes only
		//document.write(form_name + "<BR>");

		// If the field is checked, the the value for the field
		// Add that value into the total	
		if( form_field.checked )
		{	// field checked by user
			curValue = form_field.value;
			//document.write(curValue +"<BR>");
			// add the value to the total
			 yourScore += (curValue * 1)
		} // field checked by user
		
		//document.write( yourScore +"<BR>");
	} // type field check
	  
    }	// for


} // calculate

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter a username.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.background = 'Yellow'; 
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") 
    {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) 
    {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) 
    {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else 
    {
        fld.style.background = 'White';
    }
    return error;
}

function changeToMale()
{  
   var c= document.getElementById("hdtext").title="header=[<img src='idealwtm.jpg' style='vertical-align:middle'>] body=[Weight Table]><img src='scale.jpg' style='vertical-align:middle' width='53' height='19'>"
   var e= document.getElementById("quest22").innerHTML = "22. Have you had a prostrate exam from a doctor or Health Care Practitioner in the past 12 months?"
}

function changeToFemale()
{  
  var c= document.getElementById("hdtext").title="header=[<img src='idealwtw.jpg' style='vertical-align:middle'>] body=[Weight Table]><img src='scale.jpg' style='vertical-align:middle' width='53' height='19'>"
  var e= document.getElementById("quest22").innerHTML = "22. Have you had a breast exam or mammogram from a doctor or Health Care Practitioner in the past 12 months?"
}


function ValidateRadioButton(fld)
{
    var cnt = -1;

    for (var i=btn.length-1; i > -1; i--) 
    {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    
    if (cnt > -1) 
		return btn[cnt].value;
    else return null;
}




function calculatemyscore(frm )
{ // calculate
  

// response strings


// HIGH SCORE
var score_high_str = "Excellent overall Health based on your responses to the Free MyPH HealthChek© survey. \
We are proud of you for taking good care of your Health.  As a reward you will be allowed one free \
download of the My Preventive Health Nutritional and Cancer Prevention Tips©. \
Please click on the link below: www.MyPreventiveHealth.org.\n "

// GENERAL SUGGESTION 
var suggest_str_10_19 = "We suggest that at a minimum, you follow the recommendations for \
Cancer screening for your Age and your Sex from the American Cancer Society.  We also suggest that \
you review the Preventive Health suggestions for your Age and your Sex at www.MyPreventiveHealth.com. \
If you would like to join an ongoing discussion of a Health Topic that is of particular interest to you, \
please feel free to sign into our Preventive Health Blog, www.MyPHVoice.com. Continue to take good care of your health.\n";  

// SCORE 80 TO 89  
var score_80_89 = "Good health overall based on your responses to the HealthChek© survey. Please note the Specific \
Suggestions below. We are proud of you for taking good care of your Health.  As a reward you will be allowed one \
free download of the My Preventive Health Nutritional and Cancer Prevention Tips©. Please click on the link \
below: www.MyPreventiveHealth.org.\n";

//SCORE 70 TO 79
var score_70_79 = "Fair overall but you need to pay more attention to certain aspects of your health. \
Suggest you review your current health plan with your doctor or Health Care Practitioner. Please also review \
the cautions and suggestions listed below.\n";

// GENERAL ADVICE STRING  
var general_advice_str = "We suggest that at a minimum, you follow the recommendations for Cancer screening for \
your Age and your Sex from the American Cancer Society.  We also suggest that you review the Preventive Health \
suggestions for your Age and your Sex at www.MyPreventiveHealth.com.  If you would like to join an ongoing \
discussion of a Health Topic that is of particular interest to you,  please feel free to sign into our Preventive \
Health Blog, www.MyPHVoice.com.\n";
 
// SCORE 60 TO 69
var score_60_69 = "Fair overall but need to pay more attention to your health. Please review the cautions and \
suggestions listed below.\n";

// SCORE 0 TO 59 
var score_0_59 = "Suggest you work more closely with your Doctor or Health Care Practitioner to improve your \
overall state of Health. Please review the cautions and suggestions listed below.\n";

// AGE 10 TO 19  
var q1_10_19 = "<BR><b>Age 10 to 19.</B><BR>Congratulations on looking at a Preventive Health Program at such an early age. \
You are in an age group where you body is undergoing major changes and you may be producing large \
quantities of certain “Hormones”. Hormones are Chemicals that the body normally produce to regulate\
the function of the many organs in your body especially the development of your Male and Female organs. \
<BR><BR>Your major Health risks during this period are Obesity and death and disability caused by Accidents \
and Injuries.  You should always follow the safety rules for driving automobiles including \
the use Seatbelts. Avoid Alcohol and Drugs, especially when driving an automobile and do not drive as a \
passenger in an automobile that is being driven by someone who is under the influence of Drugs or Alcohol.\
<BR><BR>Avoid Obesity by paying careful attention to your body weight and your body composition.  Find an activity \
that you enjoy that gives you lots of exercise, fresh air and sunshine. This will help you avoid \
Obesity and strengthen your Heart, Lungs and Muscles.  Educate yourself and your family now about Healthy \
Food Choices, so that you will develop good eating habits for the rest of your life. Sexually transmitted  \
diseases present a major risk in your age group and you should take appropriate precautions.";

//  AGE 20 TO 39
var q1_20_39 = "<BR><b>Age 20 to 39.</b><br>Some areas of your body are still developing and you are still capable of producing lots of Growth Hormone (the Youth Hormone). Find an activity that you enjoy that gives you lots of exercise, fresh air \
and sunshine.  This will help you avoid the problem of  Obesity and will strengthen your Heart, Lungs and Muscles. \
If you want to continue looking “young”, try to obtain 7 to 8 hours of Sleep at night in order to optimize your\
body’s production of Growth Hormone.<br><br> Accidents and Injuries still represent a major risk for you. \
Avoid Alcohol and Drugs, especially when driving an automobile and do not drive as a passenger in an automobile \
that is being driven by someone who is under the influence of Drugs or Alcohol. Sexually transmitted \
diseases present a major risk in your age group and you should take appropriate precautions.";

// AGE 40 TO 49 
var q1_40_49 = "<BR><b>Age 40 to 69.</b><br>You are in an age group in which your body may be subject to major Hormonal Shifts including decreased production of Growth Hormone  and shifts in the production of your Male and Female Hormones.  This \
is a period when it may be useful to discuss a detailed Hormonal evaluation with  your doctor. <br><br>Cancer becomes \
more of a risk in this age group and it is very important for you to learn and follow the Cancer screening guidelines \
that are appropriate for your age and your sex.";

// ANSWER YES TO GUM DISEASE 
var q6a_yes = "<BR><b>Yes to Gum Infections or Dental Cavities</B><br>Chronic infections of the mouth and gums \
have been associated with an increased risk of Diabetes and Cancer.";

// ANSWER YES TO DENTAL FILLINGS
var q6b_yes  = "<br><b>Yes to Dental Fillings that contain “Silver Amalgam”.</b><br>Many of the old <silver-colored> Amalgams that were used in Dental Fillings in the past contained \
small amounts of Mercury.  Mercury can cause serious health problem when it leaks into the blood or into the \
tissues. If you have these fillings, you may want to discuss them with your Dentists at this time.";

// ANSWER YES TO HISTORY OF SMOKING
var q9_yes = "<br><b>Yes to History of Smoking.</b><br> Inhaling Cigarette Smoke either as a Primary user or as an innocent \
bystander  (Second Hand Cigarette smoke) has been associated with serious health consequences. \
You should consider quitting.  Nicotine is highly\ addictive and it is often difficult to quit on your own. \
There are many programs that can help wean you off cigarettes and you would be wise to discuss a cigarette quitting \
 program with your doctor as soon as possible.";

// ANSWER YES TO FAMILY HISTORY OF DIABETES 
var q14_yes = "<BR><b>Yes to History of Diabetes.</b><br> Poorly controlled Diabetes increases your risk of Strokes, Infections \
and Heart Disease, among other things.  You should work closely with your doctor or health care practitioner to keep you diabetes \ under control. Medical research has documented that Adult Onset Diabetes (Type 2 Diabetes) can often be controlled by working\
with your Doctor to lose 10 per cent of your body weight (usually excess body fat).";
  
// ANSWER YES TO DIABETES AND OVERWEIGHT
var q14_25_yes = "<BR><b>Yes to Diabetes AND Yes to more than 25 lbs overweight.</b><br> Poorly controlled Diabetes increases \
your risk of Strokes, Infections and Heart Disease, among other things.  Obesity (extra body fat) makes it much more difficult \
to control Diabetes.  Medical research has documented that  Adult Onset Diabetes (Type 2 Diabetes) can often be controlled by \
working with your Doctor to lose 10 per cent of your  body weight (usually excess body fat).";

 
var q15_16_yes = "<BR><b>Yes to History of Heart Disease.</b><br>Work closely with your Doctor or Health Care Practitioner to \
control factors such as your Blood Sugar, your Body Weight and Stress factors such as Chronic Fatigue, as all of these \
factors can affect the control of your Heart Disease.";
 
var q17_18_yes = "<BR><b>Yes to Positive Cancer History.</b><br> If you have had Cancer (any type), you may be at increased \
risk for developing a second Cancer in the same organ or Cancer  of a different organ.  You should work closely with your \
doctor and be especially careful to follow either the American Cancer Society’s Cancer Screening Program \
that is appropriate for your age and your sex or the program that your Doctor recommends. <br><br>There is evidence \
that a diet that contains a large percentage of leafy green vegetables and anti-oxidants may strengthen \
the body’s defenses again invading cancer cells. There is also some evidence that as a general rule, \
vegetarians appear to have a slightly decreased risk of developing cancer of certain organs.";
  
var q20_24_yes = "<BR><b>Yes to Chronic Infections (any type)?</b><br>Specialists in the field of Age Management believe that \
chronic infections of any type wear down the body’s immune system (defenses) over time and may cause the Body to Age faster \
than normal."

var q21C_less_50 = "<br><b>Yes to  Blood in Stools/ Toilet Paper and Age less than 50.</b> <br>Rectal bleeding (AT ANY AGE) may \
be an early sign of Colorectal cancer and should be immediately discussed with your Doctor or Health Care Practitioner. \
Colorectal Cancer is usually totally curable if diagnosed at an early stage. <br><br> The American Cancer Society, the \
National Institutes of Health and the Department of Health Services recommend that all patients over age 50 should be screened \
for colorectal cancer.";
 
var q21C_over_50 = "<br><b>Yes Blood in Stools/ Toilet Paper and Age greater than 50.</b><br>Rectal bleeding (AT ANY AGE) may be an early sign of Colorectal cancer and should be immediately \
   discussed with your Doctor or Health Care Practitioner.  Colorectal Cancer is usually totally curable if diagnosed at \
   an early stage.<br><br> The American Cancer Society recommends that all patients over Age 50 should be screened for Colorectal \
 Cancer whether or not you have seen blood in your stools.  Please remember that the most common symptom of early \
 (treatable)  Colorectal Cancer in this age group is NO SYMPTOMS.  Hence the importance of getting your Colon \
 screened at age 50 if it has not been done before.";
 
 var q25_cde = "<br><b>Yes to More than 25 lbs overweight for your Height.</b><br>You should be aware that excess body fat increases your risk of several diseases regardless of \
  your age.  This is especially true for increased fat around the abdominal area (often referred to as the \
  spare tire).  Increased risks of Obesity include: <br>·	Diabetes<br>·	Hypertension<br> ·	Increased Blood Fats \
  (LDL or Bad Cholesterol fraction)<br>·	Metabolic  Syndrome (Hover hyperlink)<br> ·	Cancer<br>·	Arthritis.  It is \
   difficult to imagine that excess body fat can contribute to all of these disorders, but it true.";
  
 var q27_sleep = "<br><b>Yes to Less than 7 – 8  hours of Sleep per day.</b><br>Many of the important repair functions of the body occur at night during restful sleep, e.g., repairs of the Gastro-intestinal \
  tract (Stomach, Small Intestines and Colon).  Many important Hormones, such as Growth Hormone and Melatonin are also produced at night during \
   restful sleep.  Lack of sleep over prolonged periods can result in disturbance of the normal pattern of function of these body systems \
   and result in various types of disease states.";
   
  var q28_exercise = "<br><b>No to Less than 30 minutes of vigorous Exercise per day.</b> <br>Exercise is important to maintain the strength and vigor of your Muscles, your Heart and your Blood Vessels. \
   Vigorous exercise increases your lung capacity and increases the oxygen supply to your brain, you organs and the tissues of your body.<br> \
   Vigorous exercise makes you sweat and this also cleanses (detoxifies) your body by getting rid of  some waste products through \
   the pores of your skin.  In young adults, vigorous exercise also stimulates Growth Hormone production, which helps to keep you \
   looking and feeling younger.  That is perhaps why many athletes look so pumped.";
   
   
var q30_a_cancer = "<br><b>Yes to Strong Family History of Cancer</b><br>Suggest you work closely with your Doctor to follow the recommendations of the American Cancer \
  Society for Cancer Screening based on your Age and Sex. <br>There is evidence that a diet that contains a large percentage of \
  leafy green vegetables and anti-oxidants may strengthen the body’s defenses again invading cancer cells.  There is also \
  some evidence that as a general rule, vegetarians appear to have a slightly decreased risk of developing cancer of \
  certain organs.";
  
var q32_aspirin = "<br><b>Yes to aspirin or blood thinners.</b><br>There is evidence that certain aspirin tablets may increase the risk of ulcers and bleeding from the \
 stomach walls, if taken on an empty stomach. Many doctors suggest that aspirin tablets be taken after a \
 large meal.Blood  thinners are often used by doctors to protect you from blood clots to the lungs[pulmonary embolus] \
 and  blood clots to the brain [strokes]. You must work closely with your doctors \
 to make sure your  blood does not become too thin. People on blood thinners should avoid smoking, using aspirins and \
 other medicines that are known to interfere with blood clotting. ";
 
var q35_3plusmeds = "<br><b>Yes to 3 or more prescription medicines</b><br>You indicated that you are on multiple prescriptions medications. You should work \
   closely with your  doctor to make sure these drugs do not interfere with each other. You should also remember \
   that poor control of your nutrition,   weight, and stress level could make it harder for many of your medicines \
   to work effectively.";
  
var q30_b_yes = "<br><b>Yes to Strong Family History of Diabetes</b><br>Recent studies in Obese teenagers suggest that dietary intake may play a strong role \
   in the development of  Type 2 (Adult Onset) Diabetes.  These and other studies suggest that you can reduce your \
   risk of developing  Adult Onset Diabetes Mellitus and the complications of Diabetes by modifying your diet to \
	maintain the Body Weight that is 'Ideal' for your Height.";
  
var q40_finances = "<br><b>Yes to Financial Pressures in your life now.</b><br>Health experts agree that Financial pressures in today’s society are exacerbating many \
   stress-relatedillnesses including Hypertension and Mental Illness. This problem appears to be a 2-way street. \
   On the one hand, many families are being facing bankruptcy because of the Stress caused by the expenses of \
   an unanticipated serious family illness.  On the other hand, the loss of a job or a house foreclosure situation \
   in the family can lead to Stress related illnesses, family disruption and divorce. <br><br>If you are feeling trapped by \
   your financial circumstances, you may want to consider consulting one of the free Financial Counseling Services \
   that are available from your County, City or State.";
   
var   q43_no_green_tea = "<br><b>No to daily Green Tea supplementation</b><br>Green Tea is a refreshing beverage that now comes in many flavors and \
 contains antioxidants that help protect your heart and blood vessels. Scientific research in both \
 Asia and the west is providing hard evidence for the health benefits  \
 long associated with drinking green tea. <br><br> In 1994 the Journal of the National Cancer Institute \
 published the results of an epidemiological study indicating that drinking green tea reduced \
 the risk of esophageal cancer in Chinese men and women by nearly sixty percent. University \
 of Purdue researchers recently concluded that a compound in green tea inhibits the growth of \
 cancer cells. There is also research indicating that drinking green tea regularly lowers total \
 Cholesterol levels, and can improve the ratio of good (HDL) cholesterol to bad (LDL) cholesterol. \
 <br><br>Some Weight Control specialists have recently suggested that a cup of Green Tea twice daily can \
 helps to suppress the appetite in improve compliance in patients who are on a calorie restricted \
 weight control diet.";
       
var q44_no_omega3 = "<br><b>No to Omega-3 daily intake.</b><br>Omega-3 fatty acids are essential to normal growth and development and they play a crucial role in brain function. \
 Omega-3 fatty acids cannot be manufactured by the body and must be obtained from food that we eat.  <br>Omega-3 fatty acids can be found  \
 in fish such as salmon, tuna, and halibut, some marine algae and krill.  Certain plants (including purslane), some seeds (including Chia seed)  \
 and certain nut oils also contain Omega-3 fatty acids.  Many western diets are low in Omega-3 acids and specialists that work in the field \
 of Preventive Health encourage patients to supplement their diet with a high quality organic Omega-3 supplement. <br> Unfortunately, many of the larger \
 fishes in the ocean are contaminated with Mercury and caution must be exercised if you plant to increase your fish intake to more than 2 to 3 times per week.";
 
var q45_no_vit_d3 = "<br><b>No to Vitamin D-3 supplement</b> <br>Vitamin D-3 is a fat soluble vitamin that promotes healthy teeth and bones in kids. It also promotes calcium absorption, \
  bone mass, building, the prevention of bone loss, and it protects against muscle weakness. It lowers the risk of colon, breast,  \
  and prostate cancers. It has been demonstrated to improve the functioning if the Immune system, improve rheumatoid arthritis and \
  prevent auto immune diseases.<br> Recent studies have suggested that despite Vitamin D supplementation of many foods, including Milk ,\
  Butter, Bread and some Cereals, Vitamin D levels are low in much of the American population.  Darker skinned races in living in  \
  temperate zone seem to be at higher risk and one study has demonstrated a marked deficiency in black teenagers. Some Health Care Providers \
  are now recommending Vitamin D-3 supplementation.  Please check with your Health Care Provider to see whether Vitamin D-3 supplementation is right for you.";
  
var q47_50_stress = "<br><b>Yes to Increased Stress Factors</b><br>**Managing stress is all about “taking charge” and achieving “balance” in your life: taking charge of your thoughts, your emotions, \
   your schedule, your environment, and the way you deal with problems. Your ultimate goal should be a balanced life, with time for work, relationships, \
   relaxation, and fun – plus the resilience to hold up under pressure and meet challenges head on.<br> ";
   
var stress1 = " **(Some suggestions taken from www.Helpguide.org)In a survey of My Preventive Health Clients, they \
   suggested the following options as ways of <clearing your head> (reducing your stress) when you feel like you are \
   reaching -the end of your rope:<br>·	Take a trip to the Mall and window shop for a couple of hours to clear your head<br>· \
   	Call a parent, grandparent or an experienced senior citizen in your life that will <listen>   to you and not lecture \
   	you. (Experience counts and chances are good that they will have successfully dealt with a similar problem in their life)";
  
	
var stress2 = "· Call up a friend and go for a walk or jog with him or her<br>· If you have a 'Prayer Group', \
call or visit a prayer partner and ask them to pray with you<br>· Rent a movie you have always wanted to see.\
Suggest a comedy or movie that makes you laugh·";

var stress3 = "· Listen to some of your favorite music for an hour or so to clear the cobwebs from your head. \
 <br>· Consider getting some Professional help to manage your situation, especially if the cost is not prohibitive.<BR>\
 Then, when you can think more clearly, sit and write down the main facts about the problem that you are facing \
 and write down a step-by-step plan to begin to tackle your problem head-on. It is very hard to begin to solve \
 a problem if you keep it all in your head and do not write it down on paper."

var stress4 =" You spend most of your time battling the demons in your head.<br><br> The coping strategies listed\
 below may temporarily reduce stress, but they cause more damage in the long run:\
 <br>· Smoking<br>· Drinking too much<br>· Overeating or under-eating<br>· Zoning out for hours in front of\
 the TV or computer<br>· Withdrawing from friends, family, and activities	<br>· Using pills or drugs to relax \
 <br>· Sleeping too much<br>·	Procrastinating<br>· Filling up every minute of the day to avoid facing problems<br>·	\
 Taking out your stress on others (lashing out, angry outbursts, physical violence directed at a Spouse\
 or at your children)";
 
  
    // initalize the score to zero	
    var ageCategory = 0;
    var under30 = 0;
    var yourScore = 0
    var curValue = 0
    var multValue=0
    var isSpecQ = 0
    var prev_name="dummy"
    var sFld;
    var form_field;
    var qst_name;
    var workingArray = Array(55);
    var answerArray = Array(100);	
    var iValue;
    var isHistoryDiabetes = 0;
    var message="";
    var message2="";
    var error ="";
    var q1Rep="";
    var q2Rep= "";
    var q3Rep=""; 
    var q4Rep="";
    var q10Rep="";
    var q25Rep="";
    var q27Rep="";
    var q35Rep="";
    var q37Rep="";
    var q38Rep="";
    var q41Rep="";
    var q42Rep="";
    var qRep;
    var questionAnswered = -1;
    for ( m = 0; m < 55; m++ )
    	workingArray[m] = "";
 

    for ( m = 0; m < 100; m++ )
    	answerArray[m] = "";
    
    // Run through all the form fields and calculate the score
   // special questions matrix, question with multiple options
    var spx1 = ["q2-a", "q3-a",  "q5-a", "q5-b", "q6-a", "q6-b",  "q7-a", "q7-b", "q8-a", "q8-b", "q8-c", "q19-a", "q19-b", "q20-a",
    			  "q20-b", "q21-a", "q21-b", "q21-c", "q23-a", "q23-b", "q26-a", "q26-b", "q26-c", "q30-a", "q30-b", "q30-c", "q32-a", "q32-b", 
                "q48-a", "q48-b", "q50-a", "q50-b", "q50-c" ]
	
    for (var i=0; i < frm.elements.length; i++) 
    { // main for loop
    
		/*************************** VALIDATE USER NAME AND EMAIL *************/
        // Get the current field
        form_field = frm.elements[i]
        if( form_field.type  == "text" && form_field.name =="T1")
        	error += validateUsername(form_field);
        if( form_field.type == "text" && form_field.name == "T2" )
        	error +=  validateEmail(form_field);
        if (error != "" ) 
        {
		alert("Some fields need correction:\n" + error);
   		return false;	
   	}
   	    
   

	if ( form_field.type == "radio" || form_field.type == "checkbox" )
	{ // type field check
            // Get the field's name
	    qst_name = form_field.name
	   
	    iValue = i;
	    // print the field name - debugging purposes only
	    if (form_field.checked)
	    	answerArray[i] = form_field.name + ": " + form_field.id;
	    
			
		// check for those multi answer questions
		for( var j=0; j < spx1.length; j++ )
		{  // for loop, see if this is one of the special questions
		     if ( qst_name == spx1[j] )
		     {// if qst_name, yes special question
			   var specStr = qst_name.substring(0, qst_name.indexOf("-")); 
			   qst_name = specStr; 
			   if( prev_name != qst_name )
			   {
				if( curValue > 2)
					curValue = 2;
				yourScore += (curValue * 1)		
				isSpecQ = 0;
                           }	
			   if( isSpecQ == 0 )
			   {  // new special question, initialize
				prev_name= qst_name
				curValue = 0
				questionAnswered = -1;
			    }	// new special question, initialize
			    isSpecQ = 1;
				
			    if( ( prev_name == qst_name ) && form_field.checked )
			    { // User checked one of the answers
					
				curValue += ( form_field.value *1);
				questionAnswered = curValue;
				// Find out what is checked and add special info for key questions
				
				qRep=form_field.id + "|";

				if( qst_name == "q2")
					workingArray[41] += qRep;
				if( qst_name == "q3")
					workingArray[42] += qRep;
				// QUESTION 6, GUM DISEASE, FILL IN RESPONSE FOR DISPLAY
				if( qst_name == "q6" )
				{
					if (spx1[j] == "q6-a" && form_field.value == "0") 
						workingArray[5] = q6a_yes;
					else if ( spx1[j] == "q6-b" && form_field.value == "0" )
						workingArray[6] = q6b_yes;
				}	
					
				// QUESTION 20, CHRONIC DISEASE,  FILL IN RESPONSE FOR DISPLAY
				if( qst_name == "q20" )
				{
					if (spx1[j] == "q20-a" && form_field.value == "0") 
						workingArray[12] =  q20_24_yes;
					else if ( spx1[j] == "q20-b" && form_field.value == "0" )
						workingArray[12] = q20_24_yes ;
				}	

				//*** QUESTION 21-c,BLOOD IN STOOL, PLUS AGE,  FILL IN RESPONSE FOR DISPLAY

				if( qst_name == "q21" )
				{				
					 if( spx1[j] == "q21-c" ) 
					 	if ( form_field.value == "1" ) // yes IS cHECKED
							if(ageCategory == 0 ) // REPORT BASED ON AGE
								workingArray[11] = q21C_less_50; 
							else
								workingArray[11] = q21C_over_50;
				}
					
				// QUESTION 30a, FAMILY HISTORY OF CANCER
				if( qst_name == "q30" )
				{
					if (spx1[j] == "q30-a" && form_field.value == "0") 
						workingArray[17] = q30_a_cancer ;
				}	
				// QUESTION 32, YES ASPIRIN OR BLOOD THINNERS
				if( qst_name == "q32" )
				{
					if (spx1[j] == "q32-a" && form_field.value == "0") 
						workingArray[18] = q32_aspirin ;
					else if ( spx1[j] == "q32-b" && form_field.value == "0" )
							workingArray[18] = q32_aspirin ;
				}	
					
				// QUESTION 48, DIVORCE
				if( qst_name == "q48" )
				{ // q48
					if( (spx1[j] == "q48-a" && form_field.value == "0") || 
						 (spx1[j] == "q48-b" && form_field.value == "0") )
					{
						workingArray[25] =  q47_50_stress; 
						workingArray[26] =  stress1;
						workingArray[27] =  stress2;
						workingArray[28] =  stress3;
						workingArray[29] =  stress4;
					}
				}// q48
					
				// QUESTION 50, FORECLOSURE
				if( qst_name == "q50" )
				{ // q50
					if( (spx1[j] == "q50-a" && form_field.value == "0") || 
						 (spx1[j] == "q50-b" && form_field.value == "0")||
						 (spx1[j] == "q50-c" && form_field.value == "0") )
					{ // get advice
						workingArray[25] =  q47_50_stress; 
						workingArray[26] =  stress1;
						workingArray[27] =  stress2;
						workingArray[28] =  stress3;
						workingArray[29] =  stress4;
					} // get advice
				}// q50
			    }// User checked one of the answers
				//document.write(qst_name + "<BR>");
				break;
		    }	// if, qst_name, yes special question
		}// forloop, check to see if this is a special question
		
		if( qst_name == "m1" )
		    curValue = 0;
		// *****  MAX VALUE FOR A QUESTION IS ONLY 2 POINTS, ADJUST TO 2 IF > THAN 2
		// SPECIAL QUESTION - SPLIT INTO SECTIONS CODE
		if( isSpecQ == 1 && (prev_name != qst_name) )
		{ // special question add
			if( questionAnswered == -1 ) // No answers selected for the question, notify user & exit
			{
				//alert("Some questions have not been answered. Please answer question: " + prev_name);
			//	break;
			//	return false;
			}
			if( curValue > 2)
				curValue = 2;
			yourScore += (curValue * 1)		
			isSpecQ = 0;
		} // special question add
		
		
		// --------------- FIND OUT WHAT IS CHECKED AND FILL THE ARRAY WITH ADVISE		
		// ----------------CALCULATE THE TOTALS 
		if( form_field.checked &&  isSpecQ == 0  )
		{	// if field checked by user
			var iAged = form_field.id;
			// ****************************** QUESTION 1, AGE
			if( form_field.name == "q1" )
			{ // HAS To BE Question 1
				workingArray[43] = iAged;
				ageCategory = 1; // Over 50

				if( iAged == "1" )
				{ // 10-19 age
					workingArray[3] = suggest_str_10_19; 
					workingArray[1] = q1_10_19;
					under30 = 1;
					ageCategory = 0; // Under 50;
				}
				else if( iAged ==  "2" )
				{	// 20-29
					workingArray[4] = q1_20_39;
					under30 = 1;
					ageCategory = 0; // Under 50;
				
				}
				else if( iAged == "3")
				{	// 30-39
					workingArray[4] = q1_20_39;
				  ageCategory = 0; // Under 50;
				}
				else 
				{ // 40+
					workingArray[4] = q1_40_49;
					if( iAged == "4" )
						ageCategory = 0; // Under 50;
				}
				
				
			} // HAS To BE Question 1

			if( form_field.name == "q4")
				workingArray[44]= form_field.id;
			if( form_field.name == "q10")
				workingArray[45] = form_field.id;
			if( form_field.name == "q25")
				workingArray[46] = form_field.id;
			if( form_field.name == "q27")
				workingArray[47] = form_field.id;
			if( form_field.name == "q35")
				workingArray[48] = form_field.id;
			if( form_field.name == "q37")
				workingArray[49] = form_field.id;
			if( form_field.name == "q38")
				workingArray[50] = form_field.id;
			if( form_field.name == "q41")
				workingArray[51] = form_field.id;
			if( form_field.name == "q42")
				workingArray[52]= form_field.id;

			// ************************** QUESTION 9, SMOKING
			if( form_field. name == "q9" )
				if( form_field.value == "0" )
					workingArray[7] = q9_yes; 
			
			// ******************** QUESTION 14, FAMILY HISTORY OF DIABETES
			if( form_field. name == "q14" )
				if( form_field.value == "1" )
				{
					workingArray[8] = q14_yes; 
					isHistoryDiabetes = 1;
				}
					
			// **************************** QUESTION 15, HEART ATTACK
			if( form_field. name == "q15" )
				if( form_field.value == "0" )
					workingArray[9] = q15_16_yes; 
					
			// ************************* QUESTION 16,HEART PROBLEMS
			if( form_field. name == "q16" )
				if( form_field.value == "1" )
					workingArray[9] = q15_16_yes; 
					
			// *** QUESTION 17, CANCER
			if( form_field. name == "q17" )
				if( form_field.value == "0" )
					workingArray[10] = q17_18_yes; 
					
			//*** QUESTION 18, CANCER TREATMENT
			if( form_field. name == "q18" )
				if( form_field.value == "1" )
					workingArray[10] = q17_18_yes; 
			
			
								
			// *** QUESTION 24,CHRONIC INFECTIONS
			if( form_field. name == "q24" )
				if( form_field.value == "0" )
					workingArray[12] = q20_24_yes; 
			
			//*** QUESTION 25,OVERWEIGHT BY MORE THAN 25
			if( form_field. name == "q25" )
				if( form_field.value == "0" || form_field.value == "1" )
				{
					workingArray[13] =  q25_cde; 
					if( isHistoryDiabetes == 1 )
						workingArray[14] = q14_25_yes 
				}
					
			// *** QUESTION 27, SLEEP 
			if( form_field. name == "q27" )
				if( form_field.value == "0" || form_field.value == "1" )
					workingArray[15] =  q27_sleep ; 
					
			// ***** QUESTION 28, EXERCISE
			if( form_field. name == "q28" )
				if( form_field.value == "0"  )
					workingArray[16] =  q28_exercise ; 
					
			// **** QUESTION 35, PERSCRIPTION MEDICINES
			if( form_field. name == "q35" )
				if( form_field.value == "0"  )
					workingArray[19] =  q35_3plusmeds  ; 
					
			// *****  QUESTION 40, FINANCIAL PRESSURES
			if( form_field. name == "q40" )
				if( form_field.value == "0"  )
					workingArray[20] =   q40_finances ; 
			
			// ***** QUESTION 43, GREEN TEA
			if( form_field. name == "q43" )
				if( form_field.value == "0"  )
					workingArray[21] =   q43_no_green_tea ; 
			
			// ***** QUESTION 44, OMEGA 3
			if( form_field. name == "q44" )
				if( form_field.value == "0"  )
					workingArray[22] =   q44_no_omega3  ; 
			
			// ****** QUESTION 45, VITAMIN D3
			if( form_field. name == "q45" )
				if( form_field.value == "0"  )
					workingArray[23] =  q45_no_vit_d3; 
			
			// ****** QUESTION 47, STRESS - MOVE
			if( form_field. name == "q47" )
				if( form_field.value == "0"  )
				{
					workingArray[25] =  q47_50_stress; 
					workingArray[26] =  stress1;
					workingArray[27] =  stress2;
					workingArray[28] =  stress3;
					workingArray[29] =  stress4;
				}
			
			// ****** QUESTION 49,STRESS - DEATH
			if( form_field. name == "q49" )
				if( form_field.value == "0"  )
				{
					workingArray[25] =  q47_50_stress; 
					workingArray[26] =  stress1;
					workingArray[27] =  stress2;
					workingArray[28] =  stress3;
					workingArray[29] =  stress4;
				}


			curValue = form_field.value;
			if( form_field.name == "m1" )
		    		curValue = 0;
			if ( form_field.name == "q22" && under30 =="1" && form_field.value== "0" )
				curValue =2;	
		
			//document.write(curValue +"<BR>");
			// add the value to the total
			 yourScore += (curValue * 1)
			 prev_name= form_field.name;
			 curValue=0;
			 isSpecQ = 0
		} // field checked by user
		else
		{
		// isSpecQ = 0;	
		// keep going
		    if( form_field.name == "m1" )
		    	curValue = 0;
		}	
	} // if field check by user
	  
    }	// main for loop

   var txtResults="";
   txtResults = "Your Total HealthChek(c) is " + yourScore	
   workingArray[0] = "Your Total HealthChek(c) is " + yourScore;
 	message = "";
 	if( yourScore == 100 )
	{
		workingArray[2] =  score_high_str + "<BR>";
		workingArray[3] = general_advice_str;

	}
	else if( yourScore > 89 )
	{
		workingArray[2] =  score_high_str + "<BR>";
		workingArray[3] = general_advice_str;

	}
	else if( yourScore > 79 )
	{
		workingArray[2] =  score_80_89 + "<BR>" 
		workingArray[3] = general_advice_str;

	}
	else if( yourScore > 69 )
	{
		workingArray[2] = score_70_79 + "<BR>" ;
		workingArray[3] = general_advice_str;
	}
	else if( yourScore > 59 )
	{
		workingArray[2] =  score_60_69 + "<BR>" ;
		workingArray[3] = general_advice_str;
	}
	else 
	{
		workingArray[2] = score_0_59 + "<BR>" ;
		workingArray[3] = general_advice_str;
	}
	
	for ( var m = 0; m < 40; m++ )
	{
		 if ( workingArray[m] != "" )
		 {
			// document.write( workingArray[m] + "<BR>" );
			 message += workingArray[m] +"<BR>";
		 }
	}
	for ( var m = 41; m < 53; m++ )
		if (workingArray[m] != "" )
			message2 += workingArray[m] +"<BR>";
		
	
		
  alert("**** THANK YOU FOR TAKING THE HEALTH SURVEY ****"  );
   // USE PHP to display these fields to the user
   // RESULTS 1
    document.getElementById("hid1").value = message ;
    document.getElementById("hid2").value = message2;
    document.getElementById("hid3").value = workingArray[43];   // q1
    document.getElementById("hid4").value = workingArray[41];   // q2
    document.getElementById("hid5").value = workingArray[42];   // q3
    document.getElementById("hid6").value = workingArray[44];   // q4
    document.getElementById("hid7").value = workingArray[45];   // q10
    document.getElementById("hid8").value = workingArray[46];   // q25
    document.getElementById("hid9").value = workingArray[47];   // q27
    document.getElementById("hid10").value = workingArray[48];  // q35

   // RESULTS 2
    document.getElementById("hid11").value = workingArray[49];  // q37
    document.getElementById("hid12").value = workingArray[50];  // q38
    document.getElementById("hid13").value = workingArray[51];  // q41
    document.getElementById("hid14").value = workingArray[52];  // q42
    document.getElementById("hid15").value = workingArray[14];
    document.getElementById("hid16").value = workingArray[15];
    document.getElementById("hid17").value = workingArray[16];
    document.getElementById("hid18").value = workingArray[17];
    document.getElementById("hid19").value = workingArray[18];
    document.getElementById("hid20").value = workingArray[19];
  
   // RESULTS 3  
   document.getElementById("hid21").value = workingArray[20];
   document.getElementById("hid22").value = workingArray[21];
   document.getElementById("hid23").value = workingArray[22];
   document.getElementById("hid24").value = workingArray[23];
   document.getElementById("hid25").value = workingArray[24];
   document.getElementById("hid26").value = workingArray[25];
   document.getElementById("hid27").value = workingArray[26];
   document.getElementById("hid28").value = workingArray[27];
   document.getElementById("hid29").value = workingArray[28];
   document.getElementById("hid30").value = workingArray[29];
   document.getElementById("hid31").value = workingArray[30];
   document.getElementById("hid32").value = workingArray[31];
   document.getElementById("hid33").value = workingArray[32];
   document.getElementById("hid34").value = workingArray[33];
   document.getElementById("hid35").value = workingArray[34];
  
} // calculate

