<!--
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 == '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 == "tcl") {
		if(NoneWithCheck(document.calculator.gender)) {	
			alert('Please enter your gender.');
			return false;		
   	}
		if(WithoutSelectionValue(document.calculator.age)) {	
			alert('Please select your age range.');
			return false;		
   	}
		if(WithoutSelectionValue(document.calculator.ldl)) {	
			alert('Please select your total cholesterol level.');
			return false;		
   	}
		if(WithoutSelectionValue(document.calculator.hdl)) {	
			alert('Please select your level of HDL (good) cholesterol.');
			return false;		
   	}
		if(WithoutSelectionValue(document.calculator.sbp)) {	
			alert('Please select your systolic blood pressure.');
			return false;		
   	}
		if(NoneWithCheck(document.calculator.smoke)) {	
			alert('Please enter whether you smoke.');
			return false;		
   	}
	}
	
	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;
		}
   				
	}
	else if (strWhichForm == "heartdiseaserisk") {
		//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();
}

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;
	}
			
}

//-->