
// body boost

function cal_bmi(lbs, ins) {
	h2 = ins * ins;
	bmi = lbs/h2 * 703
	f_bmi = Math.floor(bmi);
	diff  = bmi - f_bmi;
	diff = diff * 10;
	diff = Math.round(diff);
	if (diff == 10) {
		// Add up to next
		f_bmi += 1;
		 diff = 0;
	}
	bmi = f_bmi + "." + diff;
	return bmi;
}


function compute() {
	var f = document.bmiInput;
	var fi = parseInt(f.htf.options[f.htf.selectedIndex].value * 12);
	var ii = parseInt(f.hti.options[f.hti.selectedIndex].value);
	var i = fi + ii;
	w = f.wt.value;
	if (chkw(w)) {
		f.bmi.value = cal_bmi(w, i);
	} else {
		alert("Please enter a number for your weight.");
	}
}

function chkw(w) {
	if (isNaN(parseInt(w))) {
		return false;
	} else if (w < 0) {
		return false;
	} else {
		return true;
	}
}
				
				
function waisttohip(){
	
	var w=document.whform.wh1.value;
	var x=document.whform.wh2.value;				
	if (chkw(w) && chkw(x)) {
		results=eval(w)/ eval(x);
		results=Math.round(results*100)/100;
		var results=new String(results);
		document.whform.wh3.value=results
	} else {
		alert("Please enter numeric values in both fields");
	}
	
}



// Name  : selectPlan()
// author: Senthil nathan
// modified: Jaime Tanna, iVillage UK
// Description: Passes the appropriate diet plan selected to the dietintro page

function selectPlan(sForm)
{

    for (var i= 0; i < sForm.elements.length; i++)
	{

		var e = sForm.elements[i];

			if (e.type == "radio")
			{

				if (e.checked == true)
				{

					if(e.value == '1')
					{
						var choice = sForm.dietchoice.value;
						location.href = "http://www.tescodiets.com/dietprofile2/dietintro_partner.cfm?code=200100&dietchoice="+choice;
					}

					if(e.value == '3')
					{
						location.href  = "http://www.tescodiets.com/b2b/ivillage/";
				   }

				}// endif (e.checked == true)

			}//endif (e.type == "radio")
	} // end for

	return false;
}



// Name       : skip()
// Description: This method blur the focus
function skip () { this.blur(); }


// Name       : toggleSelect(select)
// Input      : radio button id
// Output	  : Enable/Disable
// Description: This method Enable/Disable when user click the radio button which associated with that particular dropdown

	function toggleSelect (select)
	{

			 if (!select.disabled)
			 {
				    select.disabled = true;
					    if (!document.all && !document.getElementById)
						{
					      select.oldOnFocus = select.onfocus ? select.onfocus : null;
					  select.onfocus = skip;
					    }
			 }
		     else
			 {
			    select.disabled = false;
				    if (!document.all && !document.getElementById)
					{
					      select.onfocus = select.oldOnFocus;
				    }
			 }
			 return;

    } // end toggleSelect (select)