var months=new Array("none","January","February","March","April","May","June","July","August","September","October","November","December");function isValidDate(a){month=document.duecalc_form.dd_month.value;day=document.duecalc_form.dd_day.value;year=document.duecalc_form.dd_year.value;if(month<1||month>12){alert("Please select a Month.");return false}if(day<1||day>31){alert("Day must be between 1 and 31.");return false}if(year==1){alert("Please select a Year.");return false}if((month==4||month==6||month==9||month==11)&&day==31){alert("Month "+month+" doesn't have 31 days!");return false}if(month==2){var b=(year%4==0&&(year%100!=0||year%400==0));if(day>29||(day==29&&!b)){alert("February "+year+" doesn't have "+day+" days!");return false}}return true}function dispDate(a){month=a.getMonth()+1;month=(month<10)?""+month:month;day=a.getDate();day=(day<10)?""+day:day;year=a.getYear();if(year<2000){year+=1900}return(months[parseInt(month)]+" "+(day)+", "+year)}function pregnancyCalc(a){menstrual=new Date();ovulation=new Date();duedate=new Date();today=new Date();cycle=0,luteal=0;month=document.duecalc_form.dd_month.value;day=document.duecalc_form.dd_day.value;year=document.duecalc_form.dd_year.value;cycledays=document.duecalc_form.cyc_days.value;menst_date=month+"/"+day+"/"+year;lutdays=14;if(isValidDate(menst_date)){menstrualinput=new Date(menst_date);menstrual.setTime(menstrualinput.getTime())}else{return false}cycle=(cycledays==""?28:cycledays);if(cycledays!=""&&(cycledays<22||cycledays>45)){alert("Your cycle length is either too short or too long for \ncalculations to be very accurate!  We will still try to \ncomplete the calculation with the figure you entered. ")}document.getElementById("calculator_header").style.display="none";document.getElementById("calculator_self").style.display="none";document.getElementById("calculator_result").style.display="block";document.getElementById("calculator_img_self").src="/images/calculators/calculator_hello.jpg";luteal=(lutdays==""?14:lutdays);ovulation.setTime(menstrual.getTime()+(cycle*86400000)-(luteal*86400000));duedate.setTime(ovulation.getTime()+266*86400000);document.getElementById("out_duedate").innerHTML=""+dispDate(duedate);document.getElementById("out_duedate2").innerHTML=""+dispDate(duedate);document.getElementById("out_duedate3").innerHTML=""+dispDate(duedate);var b=14+266-((duedate-today)/86400000);weeks=parseInt(b/7);days=Math.floor(b%7);if(weeks>44){document.getElementById("pregnant_now").style.display="none";document.getElementById("pregnant_past").style.display="block";document.getElementById("pregnant_future").style.display="none"}else{if(weeks<0||days<0){document.getElementById("pregnant_now").style.display="none";document.getElementById("pregnant_past").style.display="none";document.getElementById("pregnant_future").style.display="block"}else{document.getElementById("pregnant_now").style.display="block";document.getElementById("pregnant_past").style.display="none";document.getElementById("pregnant_future").style.display="none"}}b=weeks+" week"+(weeks==1?"":"s")+", "+days+" day"+(days==1?"":"s");document.getElementById("out_fetalage").innerHTML=""+b;document.getElementById("calc_weekurl_span").innerHTML="Learn more about your baby's development at week "+weeks+" of pregnancy";document.getElementById("calc_weekurl").href="/calendar/"+weeks+"-week"+(weeks!=1?"s":"")+"-pregnant.html";document.getElementById("calc_block").style.display="block";return false};