/*****************************************
(C) http://www.calculator.net all right reserved.  
*****************************************/
function calcp(){showquickmsg("calculating...",true);cpdate=document.calcf.today.value;cageat=document.calcf.ageat.value;cyear=parseFloat(cpdate.substr(6,4));cmonth=parseFloat(cpdate.substr(0,2))-1;cday=parseFloat(cpdate.substr(3,2));cayear=parseFloat(cageat.substr(6,4));camonth=parseFloat(cageat.substr(0,2))-1;caday=parseFloat(cageat.substr(3,2));var A=new Date();A.setFullYear(cyear,cmonth,cday);var D=new Date();D.setFullYear(cayear,camonth,caday);if(A.getTime()>D.getTime()){showquickmsg("date of birth needs to be earlier than the age at date",true);return }totalDays=parseInt((D.getTime()-A.getTime())/86400000);totalWeeks=Math.floor(totalDays/7);weekDays=totalDays-totalWeeks*7;diffyear=cayear-cyear;diffmonth=camonth-cmonth;diffday=caday-cday;var C=new Date();var B=new Date();C.setFullYear(cayear,camonth,1);B.setTime(C.getTime()-86400000);lastMonthDays=B.getDate();C.setFullYear(cayear,(camonth+1),1);B.setTime(C.getTime()-86400000);thisMonthDays=B.getDate();if(diffday<0){diffmonth=diffmonth-1;diffday=diffday+lastMonthDays}if(diffmonth<0){diffyear=diffyear-1;diffmonth=diffmonth+12}outPut="<b>Age:</b><br>";outPut+=diffyear+" years "+diffmonth+" months "+diffday+" days";outPut+="<br>or "+(diffmonth+diffyear*12)+" months "+diffday+" days";outPut+="<br>or "+totalWeeks+" weeks "+weekDays+" days";outPut+="<br>or "+totalDays+" days";outPut+="<br>or "+(totalDays*24)+" hours";outPut+="<br>or "+(totalDays*24*60)+" minutes";outPut+="<br>or "+(totalDays*24*3600)+" seconds";showquickmsg(outPut,false)};