function calcalcIt(){oForm=document.calc;weight=parseInt(oForm.weight.value*1);age=parseInt(oForm.age.value*1);feet=parseInt(oForm.feet.value*1);inches=parseInt(oForm.inches.value*1);var a=parseInt(oForm.txtBF.value*1);if(!isNumeric(age,"Age:","age"))return false;else if(age<=12||age>80){alert("Age must be between 13 and 80");return false}if(!isNumeric(weight,"Weight:","weight"))return false;else if(weight<=40||weight>500){alert("Please enter a valid weight");return false}if(!isNumeric(feet,"Feet:","feet"))return false;else if(feet<4||feet>7){alert("Height must be between 4 and 7 feet");return false}if(!isNumeric(inches,"Inches:","inches"))return false;else if(inches>11){alert("Inches should be less than 12");return false}if(!isNumeric(a,"Body Fat %","txtBF"))return false;if(oForm.weighttype[0].checked)weight=weight/2.2;height=(feet*12+inches)*2.54;if(oForm.optFormula[2].checked){if(oForm.sex[0].checked){result=66.5+13.75*weight+5.003*height-6.775*age}else{result=655.1+9.563*weight+1.85*height-4.676*age}}else{if(oForm.optFormula[1].checked){var b=weight-weight*(a/100);result=21.6*b+370}else{if(oForm.sex[0].checked)result=5+10*weight+6.25*height-5*age;else result=-161+10*weight+6.25*height-5*age}}var d=result*oForm.activity.options[oForm.activity.selectedIndex].value;var e=false;if(oForm.activity.options[oForm.activity.selectedIndex].value==1)e=true;rockBottom=weight*2.2*8;var f='<br /><span class="cals">CALORIES/DAY</span>';if(!oForm.optResults[0].checked){d=d*4.184;rockBottom=rockBottom*4.184;f='<br /><span class="cals">kJ PER DAY</span>'}else{var g=Get("linkNutrient").href;if(g.indexOf("?")!=-1)g=g.substring(0,g.indexOf("?"));g+="?cals="+Math.round(d);Get("linkNutrient").href=g;Get("linkNutrient2").href=g}s=Math.round(d)+f;Get("answer").innerHTML=s;loseFat=d-d*.2;if(loseFat<rockBottom&&rockBottom<=d)loseFat=rockBottom;s=Math.round(loseFat)+f;Get("lose").innerHTML=s;var h=d-d*.4;if(h<rockBottom&&rockBottom<=d)h=rockBottom;s=Math.round(h)+f;Get("loseExt").innerHTML=s;var i=d+d*.2;s=Math.round(i)+f;if(e){Get("loseExt").innerHTML="-";Get("lose").innerHTML="-"}if(h==loseFat){Get("loseExt").innerHTML='<span class="cals">TOO LOW!</span>'}var j=new Array(1,.8,1.2,1,.9,1.1,1);var k=document.getElementById("zigResultsTable");var l;for(r=1;r<k.rows.length;++r){thisRow=k.rows[r];for(c=1;c<thisRow.cells.length;++c){if(c==1)l=d*j[r-1];if(c==2)l=loseFat*j[r-1];if(c==3)l=h*j[r-1];if(c==4)l=i*j[r-1];if(l<rockBottom)l=rockBottom;thisRow.cells[c].innerHTML=Math.ceil(l);if(e)thisRow.cells[c].innerHTML="-"}}return true}function addLoadEvent(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){b();a()}}}function printThis(a){var b=Get(a);if(document.getElementsByTagName){linkEl=document.getElementsByTagName("link");styleEl=document.getElementsByTagName("style")}printWindow=window.open("","printWindow","left=50,top=50,width=500,height=500,scrollbars=yes,"+"status=yes,resizable=yes");printWindow.opener=self;d=printWindow.document;d.open();d.writeln("<html><head><title>"+document.title+"</title>");if(linkEl){d.writeln("<link rel='stylesheet' type='text/css' href='"+linkEl[0].getAttribute("href")+"'/>")}if(styleEl&&styleEl.length>0){d.writeln("<style type='text/css'>"+styleEl[0].innerHTML+"</style>")}d.writeln("</head><body>");d.writeln(b.innerHTML);d.writeln("</body></html>");d.close();printWindow.print();printWindow.close()}function alternateRowColors(){var a="default";var b="#efefef";var c,d;var e=document.getElementsByTagName("table");var f=0;for(var g=0;g<e.length;g++){if(e.item(g).className==a){atable=e.item(g);c=atable.getElementsByTagName("tr");for(var h=0;h<c.length;h++){d=c.item(h);if(d.nodeName=="TR"){if(f%2){d.style.backgroundColor=b}else{}f++}}f=0}}}function doQuotes(){var a=new Array;var b=new Array;a[0]="I just wanted to say how great this site is. Thanks to whoever put it together! And that its free! <br><br>The Macro-Nutrient and Daily Calorie Needs calculators I use all the time.";b[0]="Anon";a[1]="your web site is awesome... You should be congratulated, and justifiably proud of a job well done. <br><br> :)";b[1]="Terry C.";a[2]="I would like to thank you for making this web site easy to understand. I have had great success and the plan works. Other calorie counting sites are so complicated and confusing";b[2]="Nicole K.";a[3]="I just wanted to say thanks for the site. I have lost 75 lbs in the last 9 months.";b[3]="Garry Evans";a[4]="By using this calculator, and increasing my daily activity, I have safely lost 40 lbs, and still going strong!";b[4]="Sue H";a[5]="I weighed 374. I now weigh 317. I want to say thank you for insight, good tips and being here...";b[5]="Cheri";a[6]="I just love your website, it is so informative and extremely helpful. I especially love the calculators and meal plans.";b[6]="Yasmin";var c=Math.floor(a.length*Math.random());document.getElementById("quotetext").innerHTML='"'+a[c]+'"'+' <br><br><a href="/help/awards.htm">FEEDBACK...</a>';document.getElementById("quoteauthor").innerHTML=b[c]}function b(){status="";return true}function a(a){status=a;return true}function debug(a){if(window.top.debugWindow&&!window.top.debugWindow.closed){window.top.debugWindow.document.write(a+"\n")}}function showDebug(){window.top.debugWindow=window.open("","Debug","left=0,top=0,width=300,height=700,scrollbars=yes,"+"status=yes,resizable=yes");window.top.debugWindow.opener=self;window.top.debugWindow.document.open();window.top.debugWindow.document.write("<HTML><HEAD><TITLE>Debug Window</TITLE></HEAD><BODY><PRE>\n")}function TableObject(a,b,c,d,e,f){function n(){this.className=b}function m(){this.className=e}function l(){this.className=f}function k(){this.className=c}function j(){this.className=d}function i(a){a.onmouseover=a.onmouseout=null}function h(a,c){if(c){if(a.className==f){a.onmouseout=l}else{a.onmouseout=k}a.onmouseover=j}else{a.className=b;a.onmouseover=m;a.onmouseout=n}}var g=Get(a);if(g){loopTable(g,h)}this.unload=function(){loopTable(g,i)}}function loopTable(a,b,c){var d,e;if(!a||!b)return;for(d=0;d<a.rows.length;++d){if(false==b(a.rows[d],true,d,e,c)){return}}}function isNumeric(a,b,c){var d=/(^\d+$)|(^\d+\.\d+$)/;if(d.test(a))return true;else{if(b){alert(b+" Please enter numbers only.");Get(c).focus();Get(c).select()}return false}}function Get(a,b,c){if(!c){if(b){c=b.document}else{c=window.document}}if(c[a]){return c[a]}if(c.all&&c.all[a]){return c.all[a]}if(c.getElementById&&c.getElementById(a)){return c.getElementById(a)}for(var d=0;d<c.forms.length;d++){if(c.forms[d][a]){return c.forms[d][a]}}for(var d=0;d<c.anchors.length;d++){if(c.anchors[d].name==a){return c.anchors[d]}}for(var d=0;document.layers&&d<c.layers.length;d++){var e=Get(a,null,c.layers[d].document);if(e){return e}}if(!b&&window[a]){return window[a]}if(b&&b[a]){return b[a]}for(var d=0;b&&b.frames&&d<b.frames.length;d++){var e=Get(a,b.frames[d],b.frames[d].document);if(e){return e}}return null}addLoadEvent(alternateRowColors);addLoadEvent(doQuotes)
