/*****************************************
(C) http://www.calculator.net all right reserved.  
*****************************************/
function showquickobjmsg(C,A,B){if(A){C="<font color=red>"+C+"</font>"}gObj(B).innerHTML=C}function calcp(){showquickmsg("calculating...",true);cpdate=trimAll(document.calcf.today.value+"");cageat=trimAll(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(gObj("addendday").checked){D.setTime(D.getTime()+86400000);cayear=D.getFullYear();camonth=D.getMonth();caday=D.getDate()}if(A.getTime()>D.getTime()){showquickmsg("start date needs to be earlier than the end 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>date difference:</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";showquickmsg(outPut,false)}function isPositiveInteger(A){if(!isNumber(A)){return false}tempIntV=parseInt(A);tempFloatV=parseInt(A);if(Math.abs(tempFloatV-tempIntV)>1e-7){return false}if(tempIntV<0){return false}return true}function calcp2(){showquickobjmsg("calculating...",true,"coutput2");cpdate=trimAll(document.calcf2.today2.value+"");cyear=parseFloat(cpdate.substr(6,4));cmonth=parseFloat(cpdate.substr(0,2))-1;cday=parseFloat(cpdate.substr(3,2));c2op=document.calcf2.c2op.value;c2year=document.calcf2.c2year.value;c2month=document.calcf2.c2month.value;c2week=document.calcf2.c2week.value;c2day=document.calcf2.c2day.value;if(!isPositiveInteger(c2year)){showquickobjmsg("years need to be a positive integer.",true,"coutput2");return }else{if(!isNumber(c2month)){showquickobjmsg("months need to be a positive integer.",true,"coutput2");return }else{if(!isNumber(c2week)){showquickobjmsg("weeks need to be a positive integer.",true,"coutput2");return }else{if(!isNumber(c2day)){showquickobjmsg("days need to be a positive integer.",true,"coutput2");return }}}}c2year=parseInt(c2year);c2month=parseInt(c2month);c2week=parseInt(c2week);c2day=parseInt(c2day);c2day=c2week*7+c2day;if(c2op=="+"){cyear=cyear+c2year;cmonth=cmonth+c2month}else{cyear=cyear-c2year;cmonth=cmonth-c2month}cyear=cyear+Math.floor(cmonth/12);cmonth=cmonth%12;if(cmonth<0){cmonth=cmonth+12}var A=new Date();A.setFullYear(cyear,cmonth,cday);if(c2op=="+"){A.setTime(A.getTime()+86400000*c2day)}else{A.setTime(A.getTime()-86400000*c2day)}coutyear=A.getFullYear();coutmonth=A.getMonth();coutdays=A.getDate();coutday=A.getDay();if(coutday==0){coutday="Sunday"}else{if(coutday==1){coutday="Monday"}else{if(coutday==2){coutday="Tuesday"}else{if(coutday==3){coutday="Wednesday"}else{if(coutday==4){coutday="Thursday"}else{if(coutday==5){coutday="Friday"}else{if(coutday==6){coutday="Saturday"}}}}}}}if(coutmonth==0){coutmonth="Jan."}else{if(coutmonth==1){coutmonth="Feb."}else{if(coutmonth==2){coutmonth="Mar."}else{if(coutmonth==3){coutmonth="Apr."}else{if(coutmonth==4){coutmonth="May"}else{if(coutmonth==5){coutmonth="Jun."}else{if(coutmonth==6){coutmonth="Jul."}else{if(coutmonth==7){coutmonth="Aug."}else{if(coutmonth==8){coutmonth="Sep."}else{if(coutmonth==9){coutmonth="Oct."}else{if(coutmonth==10){coutmonth="Nov."}else{if(coutmonth==11){coutmonth="Dec."}}}}}}}}}}}}outputVal=coutmonth+" "+coutdays+", "+coutyear+" "+coutday;showquickobjmsg("<font color=green><b>"+outputVal+"</b></font><br><br>",false,"coutput2")};