$(document).ready(function() { function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/; domain=kaboose.com"; } function Get_Cookie( check_name ) { // first well split this cookie up into name/value pairs // note: document.cookie only returns name=value, not the other components var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; // set boolean t/f default f for ( i = 0; i < a_all_cookies.length; i++ ) { // now well split apart each name=value pair a_temp_cookie = a_all_cookies[i].split( '=' ); // and trim left/right whitespace while were at it cookie_name = a_temp_cookie[0].replace(/^ +| +$/g, ''); // if the extracted name matches passed check_name if ( cookie_name == check_name ) { b_cookie_found = true; // we need to handle case where cookie has no value but exists (no = sign, that is): if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^ +| +$/g, '') ); } // note that in cases where cookie is initialized but no value, null is returned return cookie_value; break; } a_temp_cookie = null; cookie_name = ''; } if ( !b_cookie_found ) { return null; } } function eraseCookie(name) { createCookie(name,"",-1); } function infoset() { var cdes = new Array ();// childDescription holds the three describing variable var codes = new Array (); var cups = new Array(); var m = 0 cdes ['gender'] = new Array ('girl','boy');// child gender variable 1 is girl 2 is boy cdes ['activity'] = new Array (1,2,3);// child activity is sedentary=1 moderately active=2 active =3 cdes ['age'] = new Array (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);// child age field is expected age -2 for (i=0;i<=1;i++) { for (j=0;j<=2;j++) { for (k=0;k<=16;k++) { codestring=(cdes['gender'][i]+cdes['activity'][j]+cdes['age'][k]+" "); codes[m]= codestring; m=m+1; } } } cups [0] = new Array (codes[0],codes[1],codes[2],codes[3],codes[34],codes[51],codes[52],codes[53],codes[54],codes[68],codes[85]); cups [1] = new Array (codes[4],codes[5],codes[6],codes[7],codes[8],codes[9],codes[10],codes[11],codes[12],codes[13],codes[14],codes[15],codes[16],codes[17],codes[18],codes[19],codes[20],codes[21],codes[22],codes[23],codes[24],codes[25],codes[26],codes[27],codes[28],codes[35],codes[36],codes[37],codes[38],codes[39],codes[41],codes[55],codes[56],codes[57],codes[58],codes[59],codes[60],codes[61],codes[69],codes[70],codes[71],codes[72],codes[73],codes[74],codes[75],codes[76],codes[86],codes[87],codes[88],codes[89],codes[90]); cups [2] = new Array (codes[29],codes[30],codes[31],codes[32],codes[33],codes[33],codes[40],codes[42],codes[43],codes[44],codes[45],codes[46],codes[47],codes[48],codes[49],codes[50],codes[62],codes[63],codes[64],codes[65],codes[66],codes[67],codes[77],codes[78],codes[79],codes[80],codes[81],codes[91],codes[92],codes[93],codes[94],codes[95],codes[96]); cups [3] = new Array (codes[82],codes[83],codes[84],codes[97],codes[98],codes[99],codes[100],codes[101]); return cups; } function validate () { var valid = new Boolean(true); if (document.childData.gender.options.selectedIndex == 0) { valid = false; } if (document.childData.activity.options.selectedIndex == 0) { valid = false; } if (document.childData.age.options.selectedIndex == 0) { valid = false; } if (document.childData.fintake.options.selectedIndex == 0) { valid = false; } return valid; } function retrieveData() { var childgen = document.childData.gender.options.selectedIndex; var childact = document.childData.activity.options.selectedIndex; var childage = document.childData.age.options.selectedIndex; var childintake = document.childData.fintake.options.selectedIndex; //check childs gender if (childgen==1) { codeseg1='girl'; } else if (childgen==2) { codeseg1='boy'; } //checks child activity codeseg2 = childact; if (childact==1) { childact= "sedentary"; } else if (childact==2) { childact = "moderately active"; } else { childact = "active" } //checks child age codeseg3 = childage+1; //checks child intake if (childintake==1) { childintake = "less than 1 cup"; } else if (childintake==6) { childintake = "3 or more cups"; } else { childintake = childintake/2; } finalcode = new Array (codeseg1+codeseg2+codeseg3+" ",codeseg1,childact,codeseg3,childintake); return (finalcode); } function searchData (nfoset,code) { for(i=0;i cup(s) of fruit per day.

Right now, your kid isn't getting that and may be missing out on the vitamins, minerals, and other nutrients he or she needs to grow, develop, and function properly. If you're not sure how to incorporate fruit into your family's diet, here are some Kaboose recipes to get you started.

'; var resultToomuch = '

Your child is actually eating too much fruit! She or he should be eating ' + dailycups + ' cup(s) of fruit each day.

While it's wonderful that your child loves to munch on fruit, she or he may actually be filling up on fruit and not eating enough vegetables, grains, or other foods he or she needs to grow, develop, and function properly. Here are some Kaboose recipes that include a variety of fare you can serve your child at family meals.

'; var resultJustright = '

Great job! Your child is getting ' + dailycups + ' cup(s) of fruit each day.

That's exactly the right amount of fruit he or she needs daily to grow, develop, and function properly. To maintain your family's good track record of eating well, here are some Kaboose recipes that will help you serve a greater variety of fruit.

'; if (intake < dailycups || intake == "less than 1 cup") { $('#resultarea').append(resultToolittle); return resultToolittle; } else if (intake > dailycups || intake == "3 or more cups") { $('#resultarea').append(resultToomuch); return resultToomuch; } else if (intake=dailycups) { $('#resultarea').append(resultJustright); return resultJustright; } else { $('#resultarea').append('whoops an error occured please refresh!'); } } // jQuery stuff to make the page fun!! var x = Get_Cookie('mfc'); if (x) { $('#fruitcalcontainer').css('display', 'none'); $('#fruitcalcontainer2').css('display', 'block'); $('#resultarea').append(unescape(x)); } $('#submit').click(function(){ if (validate() == true) { $('#fruitcalcontainer').fadeOut('fast'); $('#fruitcalcontainer2').fadeIn('slow'); var cookiejar = displayResults (retrieveData()[1],retrieveData()[2],retrieveData()[3],retrieveData()[4],searchData(infoset(),retrieveData()[0])); createCookie('mfc',escape(cookiejar),0); } else { $('#error').fadeIn('slow'); } }); $('#helpopen1').click(function(){ $('#helpbox1').fadeIn('fast'); $('#rightmod').css('visibility', 'hidden'); }); $('#helpbox1').click(function(){ $('#helpbox1').fadeOut('slow'); $('#rightmod').css('visibility', 'visible'); }); $('#helpopen2').click(function(){ $('#helpbox2').fadeIn('fast'); $('#rightmod').css('visibility', 'hidden'); }); $('#helpbox2').click(function(){ $('#helpbox2').fadeOut('slow'); $('#rightmod').css('visibility', 'visible'); }); $('#tryagain').click(function(){ eraseCookie('mfc'); document.location.reload(true); }); $('#printy').click(function(){ window.print(); }); $('#error').click(function(){ $('#error').fadeOut('slow'); }); });