
var nu_validNums='0123456789.';var nu_validInt='0123456789';function nu_draw(parent){var prefix="wlfg";var imgpath="http://content.nutracheck.co.uk/media/images/frames/profile/"
var objp=document.getElementById(parent);var nutracheck_personal=document.createElement("div");nutracheck_personal.id="nutracheck_personal";var _nu_r=escape(document.referrer);var _nu_l=escape(document.location);var _nu_t=(new Date()).getTime();var tr=document.createElement("img");tr.src='http://www.nutracheck.co.uk/tracker?r='+_nu_r+'&l='+_nu_l+'&u='+objp.id+'&t='+_nu_t;nutracheck_personal.appendChild(tr);var hdr=document.createElement("img");hdr.src=imgpath+prefix+"_header2.gif";var fdr=document.createElement("img");fdr.src=imgpath+prefix+"_footer.gif";var fsignin=document.createElement("form");fsignin.name="nu_fsignin";fsignin.id="nu_fsignin";fsignin.method="post";fsignin.action="http://www.nutracheck.co.uk/frames/profile/wlfg_post.jsp"
fsignin.target="_new";var min_weight=document.createElement("input");min_weight.name="min_weight";min_weight.id="nu_min_weight";min_weight.type="hidden";var max_weight=document.createElement("input");max_weight.name="max_weight";max_weight.id="nu_max_weight";max_weight.type="hidden";var ismetric=document.createElement("input");ismetric.name="ismetric";ismetric.type="hidden";ismetric.value="0";ismetric.id="nu_ismetric";var personal_small=document.createElement("div");personal_small.id="nu_personal_small";var page_1=document.createElement("div")
page_1.id="nu_page_1";var page_2=document.createElement("div")
page_2.id="nu_page_2";var br="<div class='break'><img src='http://content.nutracheck.co.uk/images/spacer.gif' height='1' width='1' /></div>";var pp1a="<div class='personal_box'><p style='margin-left:13px;'>Age&nbsp;<input class='text' type='text' name='txtage' size='3' value='' maxlength='2' onkeypress='return nu_validateKeyPress(event,nu_validInt);'/>&nbsp;years</p><table class='labels'  style='margin-left:11px;'><tr><td><input  class='text' name='optsex' type='radio' value='f' ></td><td>female&nbsp;</td><td><input class='text' name='optsex' type='radio' value='m' ></td><td>male</td></tr></table><p class='nopadding'><a href='javascript:nu_changeMeasure(true,null)' id='nu_measurechange'>change to metric</a></p></div>";var pp1b="<div class='personal_box' id='profile_personal_1b' ><table style='margin-left:5px;width:130px;'><tr><td><h4>Height</h4></td><td><input class='text'  type='text' name='txtheight1' size='1' maxlength='2' value='' onchange='nu_changeTarget()' onkeypress='return nu_validateKeyPress(event,nu_validInt);' style='width:28px;'/></td><td>&nbsp;<label id='nu_heightlabel1' class='labels'>&nbsp;ft&nbsp;</label></td><td><input class='text'  type='text' name='txtheight2' size='1' maxlength='3' value='' onchange='nu_changeTarget()' onkeypress='return nu_validateKeyPress(event,nu_validInt);' style='width:28px;'/></td><td>&nbsp;<label id='nu_heightlabel2' class='labels'>ins</label></td></tr><tr><td><h4>Weight</h4></td><td><input class='text' type='text' name='txtweight1' size='1' maxlength='4' value='' onchange='nu_changeTarget()' onkeypress='return nu_validateKeyPress(event,nu_validNums);' style='width:28px;' /></td><td>&nbsp;<label id='nu_weightlabel1' class='labels'>&nbsp;st&nbsp;</label></td><td><input id='nu_txtweight2' class='text'  type='text' name='txtweight2' size='1' maxlength='2' value='' onchange='nu_changeTarget()' onkeypress='return nu_validateKeyPress(event,nu_validInt);' style='width:28px;'/></td><td>&nbsp;<label id='nu_weightlabel2' class='labels'>lbs</label></td></tr></table></div>";var pp1c="<div class='personal_box'><h4 style='font-size:10px;'>Select your activity level<a href=\"javascript:nu_popup('/popups/activitylevel.html','Activity Levels',270,450,'scrollbars=no');\"><img style='position:relative;left:0px;top:3px;margin:0px;padding:0px;' height='16' width='19' title='Activity level descriptions'  border='0' src='http://content.nutracheck.co.uk/images/lowres/info.gif'></a></h4><table cellpading='0' cellspacing='0' border='0'><tr><td><p class='labels'>Work</p></td><td> <select name='cmbwork' size='1'><option value='1'>Light</option><option value='2'>Moderate</option><option value='3'>Moderate\Heavy</option></select></td></tr><tr><td><p class='labels'>Leisure</p></td><td> <select name='cmbex' size='1'><option  value='1'>Inactive</option><option value='2'>Moderately Active</option><option value='3'>Very Active</option></select></td></tr></table></div>";var pp1d="<div class='personal_box'><p id='q6'>What is your overall goal?</p><table class='labels'><tr><td><input onclick='nu_changeTarget()' class='text' name='optgoal' type='radio' value='1' class='radio'></td><td>lose weight</td></tr><tr><td><input class='text' name='optgoal' onclick='nu_changeTarget()' type='radio' value='2' ></td><td>maintain weight</td></tr></table></div>";var pp1e="<div class='personal_box'><p>What is your goal weight?</p><p><select name='cmbtarget' class='goal'></select></p><input type='hidden' name='optgoal' value='1' /><input type='hidden' name='C1' value='4' /></div>";var pp1f="<div class='personal_box' ><p style='text-align:left'>Weekly weight loss?</p><table class='labels'><tr><td><input class='text' type='radio' name='C1' value='1'></td><td><label id='nu_weightloss1' class='labels'>0.5 lb</label></td><td><input class='text' type='radio' name='C1' value='2' ></td><td><label id='nu_weightloss2' class='labels'>1 lb</label></td></tr><tr><td><input class='text' type='radio' name='C1' value='3' ></td><td><label id='nu_weightloss3' class='labels'>1.5 lb</label></td><td><input class='text' type='radio' name='C1' value='4' ></td><td><label id='nu_weightloss4' class='labels'>2 lb</label></td></tr></table></div>";var showresults="<div class='submit'><a href='#' onclick='return nu_isValidForm1a()'><img src='"+imgpath+prefix+"_continue.gif' border='0' /></a></div>";var aboutyou="<h4>About You</h4><div id='page_2a'><table><tr><td><input name='chkpregnant' type='checkbox' value=''></td><td><p class='labels'>&nbsp;I am pregnant</td></tr><tr><td><input name='chkbreast' type='checkbox' value=''></td><td><p class='labels'>&nbsp;I am breastfeeding</td></tr></table></div><div id='page_2b'><table><tr><td valign='top'><input  type='checkbox' name='eatingdisorder' value='1'></td><td><p class='labels'>&nbsp;I have a recognised eating disorder</td></tr></table></div>"
var showresults2="<div class='submit'><input name='save' type='image' src='"+imgpath+prefix+"_continue.gif' onclick='return nu_isValidForm2()'></div>";page_1.innerHTML=pp1a+pp1b+br+pp1e+br+showresults+br;page_2.innerHTML=pp1c+aboutyou+showresults2;personal_small.appendChild(page_1);personal_small.appendChild(page_2);fsignin.appendChild(personal_small);fsignin.appendChild(min_weight);fsignin.appendChild(max_weight);fsignin.appendChild(ismetric);nutracheck_personal.appendChild(hdr);nutracheck_personal.appendChild(fsignin);nutracheck_personal.appendChild(fdr)
objp.appendChild(nutracheck_personal);nu_loadTargetWeight()}
function nu_loadTargetWeight()
{var f;var minTarget;var maxTarget;var numItems=0;var selectednum=-1;var weight,percentage;f=document.forms["nu_fsignin"]
nu_listClear(f.cmbtarget)
minTarget=parseInt(nu_minWeight(nu_getHeight(f),nu_isMetric(f)));maxTarget=parseInt(nu_maxWeight(nu_getHeight(f),nu_isMetric(f)));addOption=new Option("Select Goal Weight","Select Goal Weight");f.cmbtarget.options[numItems++]=addOption;if(minTarget==0||maxTarget==0)return;var i,kg,g;weight=nu_getWeight(f);if(nu_isMetric(f))
{minTarget=minTarget*1000;maxTarget=maxTarget*1000;if((weight-weight/5)>minTarget)
{minTarget=weight-weight/5;maxTarget=weight;}
if((weight)<maxTarget)
maxTarget=weight
for(i=minTarget;i<=maxTarget;i=i+200){percentage=-Math.floor((weight-i)*100/weight);kg=i/1000;addOption=new Option(kg+' Kg   ('+percentage+'% loss)',i);f.cmbtarget.options[numItems++]=addOption;}
i--}
else
{minTarget=nu_Convert_kg_lbs(minTarget);maxTarget=nu_Convert_kg_lbs(maxTarget);if((weight-weight/5)>minTarget)
{minTarget=weight-weight/5;maxTarget=weight;}
if((weight)<maxTarget)
maxTarget=weight
minTarget=Math.floor(minTarget)
maxTarget=Math.floor(maxTarget)
for(i=minTarget;i<=maxTarget;i++){percentage=Math.floor((weight-i)*100/weight);addOption=new Option(Math.floor(i/14)+'st '+(i%14)+'lbs   ('+percentage+'% loss)',i);f.cmbtarget.options[numItems++]=addOption;}
i--;}
nu_setminweight(f,minTarget);nu_setmaxweight(f,i);if(selectednum==-1)selectednum=0;f.cmbtarget.selectedIndex=selectednum;}
function nu_listClear(cmb)
{for(var i=cmb.options.length-1;i>=0;i--){cmb.options[i]=null;}
cmb.selectedIndex=-1;}
function nu_minWeight(height,metric)
{if(metric)
return parseInt((18.5*height*height/10000)+0.99)
else
return parseInt((18.5*nu_Convert_in_cm(height)*nu_Convert_in_cm(height)/10000+0.99))}
function nu_maxWeight(height,metric)
{if(metric)
return parseInt(24.99*height*height/10000)
else
return parseInt(24.99*nu_Convert_in_cm(height)*nu_Convert_in_cm(height)/10000)}
function nu_getWeight(f)
{if(nu_isMetric(f))
{if(f.txtweight1.value=='')return 0
return(parseInt(f.txtweight1.value)*1000)}
else
{if(f.txtweight1.value=='')return 0
return(parseInt(f.txtweight1.value)*14)+parseInt(f.txtweight2.value==''?0:f.txtweight2.value);}}
function nu_getHeight(f)
{if(f.txtheight1.value=='')f.txtheight1.value="0"
if(f.txtheight2.value=='')f.txtheight2.value="0"
if(nu_isMetric(f))
{return(parseInt(f.txtheight1.value)*100)+parseInt(f.txtheight2.value)}
else
{return(parseInt(f.txtheight1.value)*12)+parseInt(f.txtheight2.value);}}
function nu_isMetric(f)
{var obj=f.nu_ismetric;if(obj!=null)
{if(obj.value=="1")
return true;else
return false;}
alert("not found");return false;}
function nu_Convert_lbs_kg(lbs)
{return parseInt(lbs*0.4536);}
function nu_Convert_kg_lbs(kg)
{return parseInt(kg/0.4536);}
function nu_Convert_in_cm(inchs)
{return parseInt(inchs*2.54);}
function nu_validateKeyPress(e,validSet)
{var key;var keychar;if(window.event||!e.which)
key=e.keyCode;else if(e)
key=e.which;else
return true;if(key<32)return true;keychar=String.fromCharCode(key);validSet+=String.fromCharCode(8);if(validSet.indexOf(keychar)<0)
return false;return true;}
function nu_changeMeasure(resetdata,imperial)
{var f;f=document.forms["nu_fsignin"];if(imperial==null)
{if(nu_isMetric(f))
imperial=false;else
imperial=true;}
nu_changeMeasure1(f,imperial);if(resetdata)
{if(imperial)
{var h=parseInt(f.txtheight1.value)*12+parseInt(f.txtheight2.value);var w=parseInt(f.txtweight1.value)*14+parseInt(f.txtweight2.value==''?0:f.txtweight2.value);if(isNaN(h))h=0;if(isNaN(w))w=0;var mh1,mh2;h=h*2.54;h=h+.5;mh1=h/100;mh2=h%100;w=w*0.45359237;f.txtweight1.value=w;f.txtweight2.value="";f.txtheight1.value=parseInt(mh1);f.txtheight2.value=parseInt(mh2);}
else{var h=parseInt(f.txtheight1.value)*100+parseInt(f.txtheight2.value);var w=f.txtweight1.value*2.204622622+.5;var ih1,ih2,iw1,iw2;if(isNaN(h))h=0;if(isNaN(w))w=0;h=(h*0.393700787);ih1=h/12;ih2=h%12;iw1=parseInt(w/14);iw2=w-(14*iw1);f.txtheight1.value=parseInt(ih1);f.txtheight2.value=parseInt(ih2);f.txtweight1.value=parseInt(iw1);f.txtweight2.value=parseInt(iw2);}}
nu_loadTargetWeight();}
function nu_changeMeasure1(f,imperial)
{var obj;if(!imperial)
{nu_changeText('nu_heightlabel1','ft');nu_changeText('nu_heightlabel2','ins');nu_changeText('nu_weightlabel1','st');nu_changeText('nu_weightlabel2','lbs');nu_showHideLayers('nu_weightlabel2','show');nu_showHideLayers('nu_txtweight2','show');nu_changeText('nu_measurechange','change to metric');nu_changeText('nu_weightloss1','1/2 lb');nu_changeText('nu_weightloss2','1 lb');nu_changeText('nu_weightloss3','1 1/2 lb');nu_changeText('nu_weightloss4','2 lb');nu_setmetric(f,0);}
else
{nu_changeText('nu_heightlabel1','m');nu_changeText('nu_heightlabel2','cm');nu_changeText('nu_weightlabel1','kg');nu_showHideLayers('nu_weightlabel2','hide');nu_showHideLayers('nu_txtweight2','hide');nu_changeText('nu_measurechange','change to imperial');nu_changeText('nu_weightloss1','0.23 kg');nu_changeText('nu_weightloss2','0.46 kg');nu_changeText('nu_weightloss3','0.69 kg');nu_changeText('nu_weightloss4','0.92 kg');nu_setmetric(f,1);}}
function nu_changeText(id,newtext)
{var f,obj;if((obj=nu_findObj(id))!=null)
{obj.innerHTML=newtext;}}
function nu_findObj(theObj,theDoc)
{var p,i,foundObj;if(!theDoc)theDoc=document;if((p=theObj.indexOf("?"))>0&&parent.frames.length)
{theDoc=parent.frames[theObj.substring(p+1)].document;theObj=theObj.substring(0,p);}
if(!(foundObj=theDoc[theObj])&&theDoc.all)foundObj=theDoc.all[theObj];for(i=0;!foundObj&&i<theDoc.forms.length;i++)
foundObj=theDoc.forms[i][theObj];for(i=0;!foundObj&&theDoc.layers&&i<theDoc.layers.length;i++)
foundObj=nu_findObj(theObj,theDoc.layers[i].document);if(!foundObj&&document.getElementById)foundObj=document.getElementById(theObj);return foundObj;}
function nu_showHideLayers(name,visStr)
{var i,visStr,obj,args=nu_showHideLayers.arguments;if((obj=nu_findObj(name))!=null)
{if(obj.style)
{obj=obj.style;if(visStr=='show')visStr='visible';else if(visStr=='hide')visStr='hidden';}
obj.visibility=visStr;}}
function nu_changeTarget()
{var f;var height,weight;var ismaintain=false;f=document.forms["nu_fsignin"]
if(f.optgoal[1])
if(f.optgoal[1].checked)ismaintain=true;if(ismaintain)
{nu_listClear(f.cmbtarget)
addOption=new Option("Select Goal Weight","Select Goal Weight");f.cmbtarget.options[0]=addOption;weight=nu_getWeight(f);if(weight!=0)
{if(nu_isMetric(f))
{addOption=new Option(f.txtweight1.value+'kg ',weight);f.cmbtarget.options[1]=addOption;}
else
{addOption=new Option(f.txtweight1.value+'st '+f.txtweight2.value+'lbs',weight);f.cmbtarget.options[1]=addOption;}
f.cmbtarget.selectedIndex=1;}
else
f.cmbtarget.selectedIndex=0;if(f.optgoal[1]){f.C1[0].disabled=true;f.C1[1].disabled=true;f.C1[2].disabled=true;f.C1[3].disabled=true;}}
else
{if(f.optgoal[1]){f.C1[0].disabled=false;f.C1[1].disabled=false;f.C1[2].disabled=false;f.C1[3].disabled=false;}
nu_loadTargetWeight()}}
function nu_isValidForm1a()
{var height,weight;var f=document.forms["nu_fsignin"];if(!nu_checkAge(f))return false;if(!nu_checkSex(f))return false;if(!nu_checkHtWt(f))return false;if(!nu_checkTarget(f))return false;document.getElementById('nu_page_1').style.display='none';document.getElementById('nu_page_2').style.display='block';return false;}
function nu_checkAge(f){if(f.txtage.value=='')
{alert('Please enter your age.');return false;}
if(parseInt(f.txtage.value)<18)
{alert('You must be over 18.');return false;}
return true;}
function nu_checkSex(f){if(f.optsex[0]){if(!(f.optsex[0].checked||f.optsex[1].checked))
{alert('Please enter your sex');return false;}}
return true;}
function nu_checkHtWt(f){height=nu_getHeight(f);weight=nu_getWeight(f);if(!nu_isMetric(f))
{if((height<51)||(height>94))
{alert("Please re-enter height!");return false;}
if(weight>352)
{alert("Based on the targets you have entered, it is advisable to consult with your GP before starting a weight loss and/or exercise programme, therefore our system will not allow you to continue registering at this time.");return false;}
if(weight<88)
{alert("Your weight is too low!");return false;}}
else
{if(f.txtheight1.value=="")
{alert("Please re-enter height!");return false;}
if((height<130)||(height>240))
{alert("Please re-enter height!");return false;}
if((weight>160000))
{alert("Based on the targets you have entered, it is advisable to consult with your GP before starting a weight loss and/or exercise programme, therefore our system will not allow you to continue registering at this time.");return false;}
if((weight<40000)||(weight>160000))
{alert("Please re-enter weight!");return false;}}
return true;}
function nu_checkTarget(f){if(f.cmbtarget.length==1)
{alert("Our system has been unable to calculate a target weight. This is usually due to you entering an incorrect weight/height or to your Body Mass Index being lower than the acceptable level for further weight loss to be recommended, hence why registration with our service is prevented. If you have an issue with your weight, please consult your doctor. ");return false;}
if(f.cmbtarget.selectedIndex<=0)
{alert('Please enter a target weight');return false;}
var bmi,targetweight,targetbmi;targetweight=f.cmbtarget.value;if(!nu_isMetric(f))
{bmi=(weight*703*10/height/height)/10;targetbmi=(targetweight*703*10/height/height)/10;}
else
{bmi=(weight*10)/(height*height);targetbmi=(targetweight*10)/(height*height);}
if(bmi<=18.5||targetbmi<=18.5)
{alert("Our system has calculated that your Body Mass Index is lower than the acceptable level for further weight loss to be recommended, hence why registration with our service is prevented. If you have an issue with your weight, please consult your doctor.");return false;}
return true;}
function nu_isValidForm2()
{var f=document.forms["nu_fsignin"];if(f.chkbreast.checked)
{alert('You are advised to consult your GP before starting any weight loss and/or exercise programme, therefore our system cannot allow you to continue with the registration process at this time.');return false;}
if(f.chkpregnant.checked)
{alert('You are advised to consult your GP before starting any weight loss and/or exercise programme, therefore our system cannot allow you to continue with the registration process at this time.');return false;}
if(f.eatingdisorder.checked)
{alert('You are advised to consult your GP before starting any weight loss and/or exercise programme, therefore our system cannot allow you to continue with the registration process at this time.');return false;}
return true;}
function nu_popup(theURL,winName,width,height,features){var window_width=width;var window_height=height;var newfeatures=features;var window_top=(screen.height-window_height)/2;var window_left=(screen.width-window_width)/2;newWindow=window.open(''+theURL+'','Window','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+','+newfeatures+'');if(newWindow)
newWindow.focus();}
function nu_setminweight(f,value)
{if(f.min_weight)
f.min_weight.value=value;else
f.nu_min_weight.value=value;}
function nu_setmaxweight(f,value)
{if(f.max_weight)
f.max_weight.value=value;else
f.nu_max_weight.value=value;}
function nu_setmetric(f,value)
{if(f.ismetric)
f.ismetric.value=value;else
f.nu_ismetric.value=value;}