var months=new Array("none","January","February","March","April","May","June","July","August","September","October","November","December");function dispOvPeriod(a,b){month1=a.getMonth()+1;month1=(month1<10)?""+month1:month1;day1=a.getDate();day1=(day1<10)?""+day1:day1;year1=a.getYear();month2=b.getMonth()+1;month2=(month2<10)?""+month2:month2;day2=b.getDate();day2=(day2<10)?""+day2:day2;year2=b.getYear();if(year1<2000){year1+=1900}if(year2<2000){year2+=1900}return("<nobr>"+months[parseInt(month1)]+"  "+(day1)+", "+year1+"</nobr> &ndash; <nobr>"+months[parseInt(month2)]+"  "+(day2)+", "+year2+"</nobr>")}function dispOvDate(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 isValidDate(a){month=document.ovcalc_form.month.options[document.ovcalc_form.month.selectedIndex].value;day=document.ovcalc_form.day.options[document.ovcalc_form.day.selectedIndex].value;year=document.ovcalc_form.year.options[document.ovcalc_form.year.selectedIndex].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 ovulationCalc(a){menstrual=new Date();ovulation=new Date();ovulation2=new Date();duedate=new Date();today=new Date();cycle=0,luteal=0;month=document.ovcalc_form.month.options[document.ovcalc_form.month.selectedIndex].value;day=document.ovcalc_form.day.options[document.ovcalc_form.day.selectedIndex].value;year=document.ovcalc_form.year.options[document.ovcalc_form.year.selectedIndex].value;cycledays=document.ovcalc_form.cycle.options[document.ovcalc_form.cycle.selectedIndex].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<20||cycledays>46)){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/eggs_hatched.jpg";luteal=14;for(var b=1;b<7;b++){ovulation.setTime(menstrual.getTime()+(b*cycle*86400000)-(luteal*86400000)-(3*86400000));ovulation2.setTime(menstrual.getTime()+(b*cycle*86400000)-(luteal*86400000)+(2*86400000));if(b==1){document.getElementById("breakdown"+b+"_1").innerHTML=""+dispOvPeriod(ovulation,ovulation2);document.getElementById("calculator_result_sum").innerHTML=""+dispOvPeriod(ovulation,ovulation2).replace("&ndash;","to")}else{document.getElementById("breakdown"+b+"_1").innerHTML=""+dispOvPeriod(ovulation,ovulation2)}duedate.setTime(ovulation.getTime()+266*86400000+(3*86400000));if(b==1){document.getElementById("calculator_result_sum2").innerHTML=""+dispOvDate(duedate)}document.getElementById("breakdown"+b+"_2").innerHTML=""+dispOvDate(duedate)}return true};