// JavaScript Document
var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12

var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12

function displayage(bd){
today=new Date()

var birthdate=bd.split("/")
var mon = birthdate[0]
var yr = birthdate[2]
var day = birthdate[1]

var pastdate=new Date(yr, mon-1, day)

var countunit="years"
var decimals=0
var rounding="rounddown"

finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
document.write(yearspast+tail+" ")
}

function returnage(bd){
today=new Date()

var birthdate=bd.split("/")
var mon = birthdate[0]
var yr = birthdate[2]
var day = birthdate[1]

var pastdate=new Date(yr, mon-1, day)

var countunit="years"
var decimals=0
var rounding="rounddown"

finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
return(yearspast)
}

function displayagegap(his, her){
var hisage = returnage(his)
var herage = returnage(her)
var agediff
if (hisage>herage)
   {
   agediff = hisage-herage
   document.write("He's <b>"+agediff+"</b> years older")
   }
if (hisage<herage)
   {
   agediff = herage-hisage
   document.write("She's <b>"+agediff+"</b> years older")
   }
if (hisage==herage)
   {
   document.write("Same Age")
   }
}
