
var a =new Array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
var aaa =new Array("Sun","Mon","Tues","Weds","Thurs","Fri","Sat");
var chocolaty;
var hugibug;
var days;
today = new Date();
yyy=today.getFullYear();
xxx=yyy-1;
function tombong(form)
{
//alert(xxx);
lmp = new Date(a[form.s2.selectedIndex] + ((1*form.s1.selectedIndex)+1) + " , " + ((1*form.s3.selectedIndex)+xxx)); 
edd = new Date();

edd.setTime(lmp.getTime() + 280*86400000);
var ccc =aaa[edd.getDay()];

difference=(today -lmp)/86400000;
days = Math.floor(difference);
week = Math.floor(days/7);
leftday= days-(week*7);
if (week<0||week>42||week==0){
chocolaty=" ";}
if(week==1){
chocolaty= "you are "+ week+ " week pregnant";
}
if (week > 1 && week <43)
{
chocolaty= ".Today you are "+ week+ " weeks pregnant";
}
if(week==0||week<0||week>42)hugibug=" ";

if(week>0 && week <43)hugibug =  "and " +leftday+ " days" ;

if (leftday==1 && week >0 && week <43)hugibug="and " +leftday+ " day ";
if (leftday==0 && week >0 && week <43)hugibug=" ";

form.galaxy.value = " "+ aaa[edd.getDay()] + "  "+ edd.getDate()+"  "+ a[edd.getMonth()]+ "  " + edd.getFullYear() + " " + chocolaty +" "+ hugibug + " ";
}
function tom(form)
{ lmp = new Date(a[form.s2.selectedIndex] + ((1*form.s1.selectedIndex)+1) + " , " + ((1*form.s3.selectedIndex)+xxx)) ;  
var xx= a[form.s5.selectedIndex]  + " " + ((1*form.s4.selectedIndex)+1) + " , " + ((1*form.s6.selectedIndex)+xxx);  
fut = new Date(a[form.s5.selectedIndex]  + " " + ((1*form.s4.selectedIndex)+1) + " , " + ((1*form.s6.selectedIndex)+xxx));
difference = ((fut-lmp)/86400000); 
days = Math.floor(difference);
week = Math.floor(days/7);
leftday= days-(week*7);
lert = " on " + xx + " you are "+ week+ " weeks pregnant and " + leftday + " days";
if(leftday==0) 
{lert = " on " + xx + " you are "+ week+ " weeks pregnant ";
}
if ( difference <0 )lert = " You have entered a date earlier than you could be pregnant.Please reenter the data correctly " ;        
if( difference > 301)lert = "You have entered a date greater than 3 weeks after your expected date of delivery.Please reenter the data correctly   " ;        
alert(lert);}

function thomas(form)
{ lmp = new Date(a[form.s2.selectedIndex] + ((1*form.s1.selectedIndex)+1) + " , " + ((1*form.s3.selectedIndex)+xxx)) ;
 lmpplus = new Date();
lmpplus.setTime(lmp.getTime() +(7*(form.s7.selectedIndex)+form.s8.selectedIndex)*86400000);
alert(" "+ lmpplus.getDate() + "  " + a[lmpplus.getMonth()] + "  " + lmpplus.getFullYear() + " ") ;
}
function restore1(form)
{form.s2.selectedIndex=0;
form.s1.selectedIndex=0;
form.s3.selectedIndex=0;
form.galaxy.value=" ";
}
function restore2(form)
{form.s4.selectedIndex=0;
form.s5.selectedIndex=0;
form.s6.selectedIndex=0;
}
function restore3(form)
{form.s7.selectedIndex=0;
form.s8.selectedIndex=0;

}



