<!--
function isFormOK(strWhichForm){
var bRadio
	if (strWhichForm == 'bmi') {
		if (document.calculator.bmi_weight.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your weight.');
			return false;
		}
		else {
			if (isNaN(document.calculator.bmi_weight.value)){
				alert('Please enter numeric value of your weight.');
				return false;				
			}
		}
		if (document.calculator.bmi_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "" && document.calculator.bmi_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your height.');
			return false;
		}	
		else {
			if (isNaN(document.calculator.bmi_height_1.value) || isNaN(document.calculator.bmi_height_2.value)){
				alert('Please enter numeric value of your height.');
				return false;				
			}
		}	 
		
		if (document.calculator.bmi_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.bmi_height_1.value = 0 ;
		}
		if (document.calculator.bmi_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.bmi_height_2.value = 0 ;
		}	
		if (document.calculator.unit[0].checked == true){
			var intValToFt = parseInt(document.calculator.bmi_height_2.value/12);
			document.calculator.bmi_height_2.value = parseInt(document.calculator.bmi_height_2.value%12);				
			document.calculator.bmi_height_1.value = parseInt(document.calculator.bmi_height_1.value) + intValToFt;
		}
   		
	}
	
	else if (strWhichForm == 'health_risk'){
	
	if(document.calculator.thisHRPage.value=="1") {
	
		if (document.calculator.bmi_weight.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your weight.');
			return false;
		}
		else {
			if (isNaN(document.calculator.bmi_weight.value)){
				alert('Please enter numeric value of your weight.');
				return false;				
			}
		}
		if (document.calculator.bmi_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "" && document.calculator.bmi_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your height.');
			return false;
		}	
		else {
			if (isNaN(document.calculator.bmi_height_1.value) || isNaN(document.calculator.bmi_height_2.value)){
				alert('Please enter numeric value of your height.');
				return false;				
			}
		}	 
		
	 //waist
		
		if (document.calculator.HRisk_waist.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your waist circumference.');
			return false;
		}
		else {
			if (isNaN(document.calculator.HRisk_waist.value)){
				alert('Please enter numeric value of your waist circumference.');
				return false;				
			}
		}
		
	 //hip
		
		if (document.calculator.HRisk_hip.value.replace(/^\s*/, '').replace(/\s*$/, '') == ""){
			alert('Please enter your hip circumference.');
			return false;
		}
		else {
			if (isNaN(document.calculator.HRisk_hip.value)){
				alert('Please enter numeric value of your hip circumference.');
				return false;				
			}
		}
		
		
		if (document.calculator.bmi_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.bmi_height_1.value = 0 ;
		}
		if (document.calculator.bmi_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.bmi_height_2.value = 0 ;
		}	
		if (document.calculator.unit[0].checked == true){
			var intValToFt = parseInt(document.calculator.bmi_height_2.value/12);
			document.calculator.bmi_height_2.value = parseInt(document.calculator.bmi_height_2.value%12);				
			document.calculator.bmi_height_1.value = parseInt(document.calculator.bmi_height_1.value) + intValToFt;
		}
	
	}
	
	}
	
	else if (strWhichForm == 'due_date'){
		if (document.calculator.p_month.selectedIndex == 0) {
			alert('Please select a month.');
			return false;			
		}
		if (document.calculator.p_day.selectedIndex == 0) {
			alert('Please select a day.');
			return false;			
		}
		if (document.calculator.p_year.selectedIndex == 0) {
			alert('Please select a year.');
			return false;			
		}				
	}
	/*
	else if (strWhichForm == "cold_or_flu") {
		bRadio = false;
	    for (var j=0;j< document.calculator.cold_2.length;j++) {
	        if (document.calculator.cold_2[j].checked)
				bRadio = true;
	    }		
		if (bRadio == false) {
			alert('Please choose "How quickly did your symptoms come on?"');
			return false;			
		}
	}
	*/
	else if (strWhichForm == "stroke_quiz"){
		if (document.calculator.Q5[0].checked) {
			if (!(document.calculator.Q6[0].checked || document.calculator.Q6[1].checked)) {
				alert("Please complete the quiz by selecting a response to:\n \r Question #5's second question\n \r Answering the question(s) will allow for a more accurate rist score.");
				return false;
			}
		}
		if (document.calculator.Q6[0].checked) {
			if (!(document.calculator.Q7[0].checked || document.calculator.Q7[1].checked)) {
				alert("Please complete the quiz by selecting a response to:\n \r Question #5's third question\n \r Answering the question(s) will allow for a more accurate rist score.");
				return false;
			}
		}
		if (document.calculator.Q5[1].checked || document.calculator.Q5[2].checked) {
			if (document.calculator.Q6[0].checked || document.calculator.Q6[1].checked) {
				alert('Please check Question 5.');
				return false;
			}
		}
		if (document.calculator.Q6[1].checked) {
			if (document.calculator.Q7[0].checked || document.calculator.Q7[1].checked) {
				alert('Please check Question 5.');
				return false;
			}
		}
		if (document.calculator.Q8[0].checked) {
			if (!(document.calculator.Q9[0].checked || document.calculator.Q9[1].checked)) {
				alert("Please complete the quiz by selecting a response to:\n \r Question #6's second question\n \r Answering the question(s) will allow for a more accurate rist score.");
				return false;
			}
		}
		if (document.calculator.Q8[1].checked || document.calculator.Q8[2].checked) {
			if (document.calculator.Q9[0].checked || document.calculator.Q9[1].checked) {
				alert('Please check Question 6.');
				return false;
			}
		}
	
		if (document.calculator.Q10[0].checked) {
			if (!(document.calculator.Q11[0].checked || document.calculator.Q11[1].checked)) {
				alert("Please complete the quiz by selecting a response to:\n \r Question #7's second question\n \r Answering the question(s) will allow for a more accurate rist score.");
				return false;
			}
		}
		if (document.calculator.Q10[1].checked || document.calculator.Q10[2].checked) {
			if (document.calculator.Q11[0].checked || document.calculator.Q11[1].checked) {
				alert('Please check Question 7.');
				return false;
			}
		}
	
		if (document.calculator.Q14[0].checked) {
			if (!(document.calculator.Q15[0].checked || document.calculator.Q15[1].checked || document.calculator.Q15[2].checked)) {
				alert("Please complete the quiz by selecting a response to:\n \r Question #10's second question\n \r Answering the question(s) will allow for a more accurate rist score.");
				return false;
			}
		}
		if (document.calculator.Q14[1].checked || document.calculator.Q14[2].checked) {
			if (document.calculator.Q15[0].checked || document.calculator.Q15[1].checked || document.calculator.Q15[2].checked) {
				alert('Please check Question 10.');
				return false;
			}
		}
	
	}

	
	else if (strWhichForm == "cholesterollevels") {
	
		if (document.calculator.gender[0].checked == false && document.calculator.gender[1].checked == false) {	
			alert('Please enter your gender.');
			return false;		
   		}
		
		if (document.calculator.age.selectedIndex == 0) {
			alert('Please select your age range.');
			return false;		
   		}
		
		if (document.calculator.ldl.selectedIndex == 0) {
			alert('Please select your total cholesterol level.');
			return false;		
   		}
		
		if (document.calculator.hdl.selectedIndex == 0) {
			alert('Please select your level of HDL (good) cholesterol.');
			return false;		
   		}
		
		if (document.calculator.sbp.selectedIndex == 0) {
			alert('Please select your systolic blood pressure.');
			return false;		
   		}
		
		if (document.calculator.smoke[0].checked == false && document.calculator.smoke[1].checked == false) {	
			alert('Please enter whether you smoke.');
			return false;		
   	}
	}
	
		else if (strWhichForm == "heart_disease") {
		//gender
		if (document.calculator.gender[0].checked == false && document.calculator.gender[1].checked == false) {			
			alert('Please enter your gender.');
			return false;
		}
		
		//age
		if (isNaN(document.calculator.age.value) || document.calculator.age.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
				alert('Please enter numeric value of your age.');
				return false;				
		}
		else if (document.calculator.age.value < 30 || document.calculator.age.value > 74) {
				alert('This tool is intended for people aged 30-74.');
				return false;				
		}
		
		//level of LDL 
		if (isNaN(document.calculator.ldl.value) || document.calculator.ldl.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
				alert('Please enter numeric value of level of LDL.');
				return false;
		}
		else {
			if (document.calculator.ldl_radio[0].checked == true) { // measured in mmol/L
				if (document.calculator.ldl.value < 0 || document.calculator.ldl.value > 15.5) {
					alert('Please enter a LDL value between 0 and 15.5 (mmol/L).');
					return false;
				}				
			}
			else { // measured in mg/dL
				if (document.calculator.ldl.value < 0 || document.calculator.ldl.value > 600) {
					alert('Please enter a LDL value between 0 and 600 (mg/dL).');
					return false;
				}
			}
		}
		
		//level of HDL 
		if (isNaN(document.calculator.hdl.value) || document.calculator.hdl.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
				alert('Please enter numeric value of level of HDL.');
				return false;				
		}
		else {
			if (document.calculator.hdl_radio[0].checked == true) { // measured in mmol/L
				if (document.calculator.hdl.value < 0 || document.calculator.hdl.value > 5) {
					alert('Please enter a HDL value between 0 and 5 (mmol/L).');
					return false;
				}
			}
			else { // measured in mg/dL
				if (document.calculator.hdl.value < 0 || document.calculator.hdl.value > 200) {
					alert('Please enter a HDL value between 0 and 200 (mg/dL).');
					return false;
				}
			}
		}
		
		// systolic blood pressure
		if (isNaN(document.calculator.SBP.value) || document.calculator.SBP.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
				alert('Please enter numeric value of systolic blood pressure.');
				return false;				
		}
		else {
			if (document.calculator.SBP.value < 0 || document.calculator.SBP.value > 300) {
					alert('Please enter a systolic blood pressure value between 0 and 300.');
					return false;
			}
		}
		
		// diastolic blood pressure
		if (isNaN(document.calculator.DBP.value) || document.calculator.DBP.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
				alert('Please enter numeric value of diastolic blood pressure.');
				return false;				
		}
		else {
			if (document.calculator.DBP.value < 0 || document.calculator.DBP.value > 300) {
					alert('Please enter a diastolic blood pressure value between 0 and 300.');
					return false;
			}
		}
		
		// Do you have diabetes?
		if (document.calculator.diabetes[0].checked == false && document.calculator.diabetes[1].checked == false ) {			
			alert('Please complete all questions.');
			return false;
		}
		
		// Do you smoke?
		if (document.calculator.smoke[0].checked == false && document.calculator.smoke[1].checked == false) {			
			alert('Please complete all questions.');
			return false;
		}
	
	document.calculator.submit();
}
	
	
	else if (strWhichForm == "ideal_weight_range") {
		if (document.calculator.ideal_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "" && document.calculator.ideal_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			alert('Please enter your height.');
			return false;			
		}
		else if (document.calculator.ideal_height_1.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.ideal_height_1.value = 0 ;
		}
		else if (document.calculator.ideal_height_2.value.replace(/^\s*/, '').replace(/\s*$/, '') == "") {
			document.calculator.ideal_height_2.value = 0 ;
		}			
		else {
			if (isNaN(document.calculator.ideal_height_1.value) || isNaN(document.calculator.ideal_height_2.value)){
				alert('Please enter numeric value of your height.');
				return false;				
			}
		}					
		if (document.calculator.unit[0].checked == true){
			var intValToFt = parseInt(document.calculator.ideal_height_2.value/12);
			document.calculator.ideal_height_2.value = parseInt(document.calculator.ideal_height_2.value % 12);						
			document.calculator.ideal_height_1.value = parseInt(document.calculator.ideal_height_1.value) + intValToFt;
		}
   				
	}
	return true;
}



	
function changeUnit(){
	if (document.calculator.unit_weight){
		if (document.calculator.unit[1].checked) {	
			document.calculator.unit_weight.value = "kg";			
		}
		else if (document.calculator.unit[0].checked) {	
			document.calculator.unit_weight.value = "lbs";		
		}
	}
	if (document.calculator.unit[1].checked) {	
		document.calculator.unit_height1.value = "m";
		document.calculator.unit_height2.value = "cm";				
	}
	else if (document.calculator.unit[0].checked) {	
		document.calculator.unit_height1.value = "ft";
		document.calculator.unit_height2.value = "in";				
	}	
	
}


function checkDay() {
var NewOpt
var Daytotal = new Array(12) 

	Daytotal[1] = 31
	Daytotal[2] = 28
	Daytotal[3] = 31
	Daytotal[4] = 30
	Daytotal[5] = 31
	Daytotal[6] = 30
	Daytotal[7] = 31
	Daytotal[8] = 31
	Daytotal[9] = 30
	Daytotal[10] = 31
	Daytotal[11] = 30
	Daytotal[12] = 31
	
	if (document.calculator.p_year.selectedIndex > 0) {
		var p_year = document.calculator.p_year.options[document.calculator.p_year.selectedIndex].value;
		if (p_year/4 !=  Math.floor(p_year/4))	Daytotal[2] = 28;
		if (p_year/4 ==  Math.floor(p_year/4))	Daytotal[2] = 29;		
  	}
    var selMonth = document.calculator.p_month.options[document.calculator.p_month.selectedIndex].value;
	if (selMonth != "") {
  		var TotalDaysInSelect = document.calculator.p_day.length - 1;
		if (TotalDaysInSelect > eval(Daytotal[selMonth])) {
		    for (i=1; i<=(TotalDaysInSelect-eval(Daytotal[selMonth])); i++)
		    {
		      document.calculator.p_day.options[document.calculator.p_day.options.length - 1] = null
			}
	    }  

	    if (eval(Daytotal[selMonth]) > TotalDaysInSelect){
	      for (i=1; i<=(eval(Daytotal[selMonth])-TotalDaysInSelect); i++)
	      {
	        NewOpt = new Option(document.calculator.p_day.options.length, document.calculator.p_day.options.length);		
          //  document.calculator.p_day.add(NewOpt); 		
			document.calculator.p_day.options[document.calculator.p_day.options.length] = NewOpt;	
	      }
	    }
	    if (document.calculator.p_day.selectedIndex < 0) document.calculator.p_day.selectedIndex = 0;
	}
	
	else if (strWhichForm == "health_risk") {
	
	}
}

//-->