function computeForm(form){if(form.property.value==null||form.property.value.length==0)form.property.value=0;if(form.amount.value==null||form.amount.value.length==0)form.amount.value=0;form.nswStampDuty.value=0;form.vicStampDuty.value=0;form.qldStampDuty.value=0;form.saStampDuty.value=0;form.waStampDuty.value=0;form.ntStampDuty.value=0;form.actStampDuty.value=0;form.tasStampDuty.value=0;form.nswStampDuty2.value=0;form.vicStampDuty2.value=0;form.qldStampDuty2.value=0;form.saStampDuty2.value=0;form.waStampDuty2.value=0;form.ntStampDuty2.value=0;form.actStampDuty2.value=0;form.tasStampDuty2.value=0;if(form.amount.value>16000){form.nswStampDuty.value=Math.ceil((form.amount.value-16000)/1000)*4+5}else if(form.amount.value>0){form.nswStampDuty.value=5}if(form.property.value<=14000){form.nswStampDuty2.value=Math.ceil(form.property.value/100)*1.25}else if(form.property.value<=30000){form.nswStampDuty2.value=175+Math.ceil((form.property.value-14000)/100)*1.5}else if(form.property.value<=80000){form.nswStampDuty2.value=415+Math.ceil((form.property.value-30000)/100)*1.75}else if(form.property.value<=300000){form.nswStampDuty2.value=1290+Math.ceil((form.property.value-80000)/100)*3.5}else if(form.property.value<=1000000){form.nswStampDuty2.value=8990+Math.ceil((form.property.value-300000)/100)*4.5}else{form.nswStampDuty2.value=40490+Math.ceil((form.property.value-1000000)/100)*5.5}if(form.amount.value>10000){form.vicStampDuty.value=Math.ceil((form.amount.value-10000)/200)*0.8+4}else if(form.amount.value>0){form.vicStampDuty.value=4}if(form.property.value<=20000){form.vicStampDuty2.value=form.property.value*0.014}else if(form.property.value<=115000){form.vicStampDuty2.value=280+(form.property.value-20000)*0.024}else if(form.property.value<=870000){form.vicStampDuty2.value=2560+(form.property.value-115000)*0.06}else{form.vicStampDuty2.value=form.property.value*5.5}form.qldStampDuty.value=Math.ceil(form.amount.value/100)*0.4;if(form.property.value<=250000){form.qldStampDuty2.value=Math.ceil(form.property.value/100)}else if(form.property.value<=500000){form.qldStampDuty2.value=2500+Math.ceil((form.property.value-250000)/100)*3.5}else{form.qldStampDuty2.value=11250+Math.ceil((form.property.value-500000)/100)*3.75}if(form.amount.value<=400){form.saStampDuty.value=0}else if(form.amount.value<=4000){form.saStampDuty.value=10}else if(form.amount.value<=10000){form.saStampDuty.value=10+Math.ceil((form.amount.value-4000)/100)*0.25}else{form.saStampDuty.value=25+Math.ceil((form.amount.value-10000)/100)*0.35}if(form.property.value<=12000){form.saStampDuty2.value=Math.ceil(form.property.value/100)}else if(form.property.value<=30000){form.saStampDuty2.value=120+Math.ceil((form.property.value-12000)/100)*2}else if(form.property.value<=50000){form.saStampDuty2.value=480+Math.ceil((form.property.value-30000)/100)*3}else if(form.property.value<=100000){form.saStampDuty2.value=1080+Math.ceil((form.property.value-50000)/100)*3.5}else if(form.property.value<=500000){form.saStampDuty2.value=2830+Math.ceil((form.property.value-100000)/100)*4}else if(form.property.value<=1000000){form.saStampDuty2.value=18830+Math.ceil((form.property.value-500000)/100)*4.5}else{form.saStampDuty2.value=41330+Math.ceil((form.property.value-1000000)/100)*5}var tempProperty=form.property.value;form.waStampDuty.value=form.amount.value*0.0025;if(form.property.value>0&&form.property.value<=80000){tempProperty=(tempProperty/100);for(var i=0,k=1;tempProperty>i&&tempProperty>k;i++,k++);form.waStampDuty2.value=eval(form.waStampDuty2.value)+(k*1.95)}if(form.property.value>80000&&form.property.value<=100000){tempProperty=(tempProperty-80000)/100;for(var i=0,k=1;tempProperty>i&&tempProperty>k;i++,k++);form.waStampDuty2.value=eval(form.waStampDuty2.value)+(k*2.85)+1560}if(form.property.value>100000&&form.property.value<=250000){tempProperty=(tempProperty-100000)/100;for(var i=0,k=1;tempProperty>i&&tempProperty>k;i++,k++);form.waStampDuty2.value=eval(form.waStampDuty2.value)+(k*3.7)+2130}if(form.property.value>250000&&form.property.value<=500000){tempProperty=(tempProperty-250000)/100;for(var i=0,k=1;tempProperty>i&&tempProperty>k;i++,k++);form.waStampDuty2.value=eval(form.waStampDuty2.value)+(k*4.55)+7680}if(form.property.value>500000){tempProperty=(tempProperty-500000)/100;for(var i=0,k=1;tempProperty>i&&tempProperty>k;i++,k++);form.waStampDuty2.value=eval(form.waStampDuty2.value)+(k*4.85)+19055}form.ntStampDuty.value=0;tempProperty=form.property.value;tempProperty/=1000;var tempP=tempProperty;tempProperty*=tempProperty;if(form.property.value<=500000){form.ntStampDuty2.value=(tempProperty*0.065)+(21*tempP)}else{form.ntStampDuty2.value=(form.property.value*0.054)}form.actStampDuty.value=0;if(form.property.value==0){form.actStampDuty2.value=0}else if(form.property.value<=1600){form.actStampDuty2.value=20}else if(form.property.value<=14000){form.actStampDuty2.value=Math.ceil(form.property.value/100)*1.25}else if(form.property.value<=30000){form.actStampDuty2.value=175+Math.ceil((form.property.value-14000)/100)*1.5}else if(form.property.value<=60000){form.actStampDuty2.value=415+Math.ceil((form.property.value-30000)/100)*2}else if(form.property.value<=100000){form.actStampDuty2.value=1015+Math.ceil((form.property.value-60000)/100)*2.5}else if(form.property.value<=300000){form.actStampDuty2.value=2015+Math.ceil((form.property.value-100000)/100)*3.5}else if(form.property.value<=1000000){form.actStampDuty2.value=9015+Math.ceil((form.property.value-300000)/100)*4.5}else{form.actStampDuty2.value=40515+Math.ceil((form.property.value-1000000)/100)*5.5}if(form.amount.value==0){form.tasStampDuty.value=0}else if(form.amount.value<=8000){form.tasStampDuty.value=20}else if(form.amount.value<=10000){form.tasStampDuty.value=form.amount.value*0.0025}else{form.tasStampDuty.value=form.amount.value*0.0035-10}if(form.property.value==0){form.tasStampDuty2.value=0}else if(form.property.value<=1300){form.tasStampDuty2.value=20}else if(form.property.value<=10000){form.tasStampDuty2.value=Math.ceil(form.property.value/100)*1.5}else if(form.property.value<=30000){form.tasStampDuty2.value=Math.ceil(form.property.value/100)*2-50}else if(form.property.value<=75000){form.tasStampDuty2.value=Math.ceil(form.property.value/100)*2.5-200}else if(form.property.value<=150000){form.tasStampDuty2.value=Math.ceil(form.property.value/100)*3-575}else if(form.property.value<=225000){form.tasStampDuty2.value=Math.ceil(form.property.value/100)*3.5-1325}else{form.tasStampDuty2.value=Math.ceil(form.property.value/100)*4-2450}form.nswTotalDuty.value=eval(form.nswStampDuty.value)+eval(form.nswStampDuty2.value);form.vicTotalDuty.value=eval(form.vicStampDuty.value)+eval(form.vicStampDuty2.value);form.qldTotalDuty.value=eval(form.qldStampDuty.value)+eval(form.qldStampDuty2.value);form.saTotalDuty.value=eval(form.saStampDuty.value)+eval(form.saStampDuty2.value);form.waTotalDuty.value=eval(form.waStampDuty.value)+eval(form.waStampDuty2.value);form.ntTotalDuty.value=eval(form.ntStampDuty.value)+eval(form.ntStampDuty2.value);form.actTotalDuty.value=eval(form.actStampDuty.value)+eval(form.actStampDuty2.value);form.tasTotalDuty.value=eval(form.tasStampDuty.value)+eval(form.tasStampDuty2.value);form.nswStampDuty.value=format(round(form.nswStampDuty.value));form.vicStampDuty.value=format(round(form.vicStampDuty.value));form.qldStampDuty.value=format(round(form.qldStampDuty.value));form.saStampDuty.value=format(round(form.saStampDuty.value));form.waStampDuty.value=format(round(form.waStampDuty.value));form.ntStampDuty.value=format(round(form.ntStampDuty.value));form.actStampDuty.value=format(round(form.actStampDuty.value));form.tasStampDuty.value=format(round(form.tasStampDuty.value));form.nswStampDuty2.value=format(round(form.nswStampDuty2.value));form.vicStampDuty2.value=format(round(form.vicStampDuty2.value));form.qldStampDuty2.value=format(round(form.qldStampDuty2.value));form.saStampDuty2.value=format(round(form.saStampDuty2.value));form.waStampDuty2.value=format(round(form.waStampDuty2.value));form.ntStampDuty2.value=format(round(form.ntStampDuty2.value));form.actStampDuty2.value=format(round(form.actStampDuty2.value));form.tasStampDuty2.value=format(round(form.tasStampDuty2.value));form.nswTotalDuty.value=format(round(form.nswTotalDuty.value));form.vicTotalDuty.value=format(round(form.vicTotalDuty.value));form.qldTotalDuty.value=format(round(form.qldTotalDuty.value));form.saTotalDuty.value=format(round(form.saTotalDuty.value));form.waTotalDuty.value=format(round(form.waTotalDuty.value));form.ntTotalDuty.value=format(round(form.ntTotalDuty.value));form.actTotalDuty.value=format(round(form.actTotalDuty.value));form.tasTotalDuty.value=format(round(form.tasTotalDuty.value))}function format(number){if(number.length>9&&number.length<=12){number=(number.substring(0,number.length-9)+","+number.substring(number.length-9,number.length-6)+","+number.substring(number.length-6,number.length));return number}if(number.length>6&&number.length<=9){number=(number.substring(0,number.length-6)+","+number.substring(number.length-6,number.length));return number}return number}function round(number){var dollars=Math.floor(number);for(var decimalAt=0;decimalAt<number.length;decimalAt++){if(number.charAt(decimalAt)==".")break}var cents=""+Math.round(number*100);cents=cents.substring(cents.length-2,cents.length);dollars+=((number.charAt(decimalAt+2)=="9")&&(cents=="00"))?1:0;return(dollars+"."+cents)}function CheckLoan(loanform){var LAmount=parseInt(loanform.LAmount.value);var Interest=parseFloat(loanform.Interest.value);var Years=parseInt(loanform.Years.value);var Deposit=parseInt(loanform.Deposit.value);if(isNaN(LAmount)||LAmount<=0){alert('You need to enter a numeric loan amount');return false}else if(isNaN(Interest)||Interest<=0){alert('You need to enter a numeric interest rate');return false}else if(isNaN(Years)||Years<=0){alert('You need to enter a numeric loan term, in years');return false}else if(Years>40){alert('You need to enter a realistic loan term');loanform.Years.value='';loanform.Years.focus();return false}if(isNaN(Deposit)||Deposit<0){loanform.Deposit.value=0}return true}function doClear(results){results.Payment.value='';results.Interest.value='';results.LoanSD.value='';results.PropSD.value='';results.Total.value=''}function CalculateLoan(loanform,results){var Deposit=parseInt(loanform.Deposit.value);var LAmount=parseInt(loanform.LAmount.value);var Rate=parseFloat(loanform.Interest.value);var Term=parseInt(loanform.Years.value);var Frequency=loanform.Frequency.options[loanform.Frequency.selectedIndex].value;var State=loanform.State.options[loanform.State.selectedIndex].value;var Payment,NumPays,Total;if(Frequency=='Monthly'){Rate=Rate/1200.0;NumPays=Term*12}else if(Frequency=='Weekly'){Rate=Rate/5200.0;NumPays=Term*52}Payment=LAmount*Rate/(1-Math.pow((1+Rate),-NumPays));Total=Payment*NumPays;results.Payment.value=format(RoundCents(Payment));document.SDForm.property.value=Deposit+LAmount;document.SDForm.amount.value=LAmount;computeForm(document.SDForm);results.LoanSD.value=eval('document.SDForm.'+State+'StampDuty.value');results.PropSD.value=eval('document.SDForm.'+State+'StampDuty2.value');results.Interest.value=format(RoundCents(Total-LAmount));results.Total.value=format(RoundCents(Total+parseFloat(results.LoanSD.value)+parseFloat(results.PropSD.value)))}function RoundCents(n){var val=new String(Math.round(n*100));var Dollars=val.substring(0,val.length-2);var Cents=val.substring(val.length-2);return(Dollars+'.'+Cents)}