var monthName=new Array("January","February","March","April","May","June","July","August","September","October","November","December");function clean_durationResult() {document.durationCalculator.resultField.value="";document.durationCalculator.resultSum.value="";} function setCurrentDateA() {var curDate=new Date();var curDay=curDate.getDate();var curMonth=curDate.getMonth();var curYear=curDate.getUTCFullYear();document.writeln("<select name=day_aField size=1 onchange=clean_durationResult()>");for(var i=1;i<=31;i++) {if(i==curDay) document.writeln("<option selected>"+i);else document.writeln("<option>"+i);document.writeln("</option>");} document.writeln("</select>");document.writeln("<select name=month_aField size=1 onchange=clean_durationResult()>");for(var j=0;j<12;j++) {if(j==curMonth) document.writeln("<option selected>"+monthName[j]);else document.writeln("<option>"+monthName[j]);document.writeln("</option>");} document.writeln("</select>");document.writeln("<input type=text name=year_aField value="+curYear+" size=4 maxlength=4 onkeypress=clean_durationResult()>");} function setCurrentDateB() {var curDate=new Date();var curDay=curDate.getDate();var curMonth=curDate.getMonth();var curYear=curDate.getUTCFullYear();document.writeln("<select name=day_bField size=1 onchange=clean_durationResult()>");for(var i=1;i<=31;i++) {if(i==curDay) document.writeln("<option selected>"+i);else document.writeln("<option>"+i);document.writeln("</option>");} document.writeln("</select>");document.writeln("<select name=month_bField size=1 onchange=clean_durationResult()>");for(var j=0;j<12;j++) {if(j==curMonth) document.writeln("<option selected>"+monthName[j]);else document.writeln("<option>"+monthName[j]);document.writeln("</option>");} document.writeln("</select>");document.writeln("<input type=text name=year_bField value="+curYear+" size=4 maxlength=4 onkeypress=clean_durationResult()>");} function durationCalc(form) {var a_day=form.day_aField.selectedIndex+1;var a_month=form.month_aField.selectedIndex;var a_year=form.year_aField.value;var b_day=form.day_bField.selectedIndex+1;var b_month=form.month_bField.selectedIndex;var b_year=form.year_bField.value;var _price=form.costDay.value;price=parseFloat(_price);clean_durationResult();int_aYear=parseInt(a_year);int_aMonth=parseInt(a_month);int_aDay=parseInt(a_day);int_bYear=parseInt(b_year);int_bMonth=parseInt(b_month);int_bDay=parseInt(b_day);int_aYear=parseInt(a_year);if((a_year=="")||!(int_aYear>=1900)) {alert("Year must be an integer not less than 1900.");document.durationCalculator.year_aField.focus();document.durationCalculator.year_aField.select();return false;} if((b_year=="")||!(int_bYear>=1900)) {alert("Year must be an integer not less than 1900.");document.durationCalculator.year_bField.focus();document.durationCalculator.year_bField.select();return false;} if(((int_aYear%4)==0&&(int_aYear%100)!=0)||(int_aYear%400)==0) {if((int_aMonth==1)&&(int_aDay>29)) {alert("February cannot have more than 29 days in the leap year.");return false;}} else {if((int_aMonth==1)&&(int_aDay>28)) {alert("February cannot have more than 28 days.");return false;}} if(((int_bYear%4)==0&&(int_bYear%100)!=0)||(int_bYear%400)==0) {if((int_bMonth==1)&&(int_bDay>29)) {alert("February cannot have more than 29 days in the leap year.");return false;}} else {if((int_bMonth==1)&&(int_bDay>28)) {alert("February cannot have more than 28 days.");return false;}} if(((int_aMonth==3)||(int_aMonth==5)||(int_aMonth==8)||(int_aMonth==10))&&(int_aDay>30)) {alert("This month cannot have more than 30 days.");return false;} if(((int_bMonth==3)||(int_bMonth==5)||(int_bMonth==8)||(int_bMonth==10))&&(int_bDay>30)) {alert("This month cannot have more than 30 days.");return false;} date_A=new Date(int_aYear,int_aMonth,int_aDay,1,1,1);date_B=new Date(int_bYear,int_bMonth,int_bDay,1,1,1);var day_step=86400000;var days_count=Math.ceil((date_B.getTime()-date_A.getTime())/day_step);document.durationCalculator.resultField.value=days_count+" days";if((days_count==0)||(price==0)) {document.durationCalculator.resultSum.value=0;} else {document.durationCalculator.resultSum.value=days_count*price;}} 
