// JavaScript Document
function select_item(name, value) {
this.name = name;
this.value = value;
}

function get_selection(select_object) {
contents = new select_item();
for(var i=0;i<select_object.options.length;i++) {
if(select_object.options[i].selected == true) {
contents.name = select_object.options[i].text;
contents.value = select_object.options[i].value;
}
}
return contents;
}

function StripChars(strIn) {
var newstr = "";
var Chars = "0123456789.";
    for (var i = 0; i < strIn.length; i++) {
       if (Chars.indexOf(strIn.charAt(i)) == -1) {}
   else {
   newstr = newstr + strIn.charAt(i);
   }
    }
return newstr;
}

function stampduty(formfield) {
var amount = StripChars(formfield.amount.value);
var loanamount = StripChars(formfield.loanamount.value);
var state = get_selection(formfield.state);
var type = "OO"
for (i=0; i< formfield.elements.length; i++) {
if (formfield.elements[i].name == 'Type') {
for (s=0;s < 2; s++) {
if (formfield.Type[s].checked == true) {
type = formfield.Type[s].value;
}
}
}
}
if ((amount == "") && (loanamount == "")) {
window.alert("You have not entered any values!");
return;
}
t_amount = amount;
if ((amount % 100) != 0 ) {
var mod = eval(100-(amount % 100));
amount = -(-amount - mod);
}

if ((loanamount % 100) != 0 ) {
var mod2 = eval(100-(loanamount % 100));
loanamount = -(-loanamount- mod2);
}

//********************** Victoria *************************
if (state.value == "VIC") {

if ((t_amount % 1000) != 0 ) {
var mod = eval(1000-(t_amount % 1000));
t_amount = -(-t_amount - mod);
}
if ((t_amount > 0) && (t_amount <= 500000)) {
var transfer = (t_amount / 1000) * 2.46 + 92;
}
else {
var transfer = 1323;
}
transfer = Math.ceil(transfer) ;
mortgage = 46.20;
var exnotes = "First Home Bonus\n"+
"- First home buyers are eligible for a $3,000 bonus if consideration of the property does not exceed $500,000 and if transaction takes place between 1st Jan 2006 and 30 Jun 2007.\n\n"+
"First Home Buyers with Families\n"+
"- Must have at least 1 dependant child (under 18 and under control of applicant).\n"+
"- Full stamp duty exemption for properties valued up to $150,000.\n"+
"- Stamp duty concessions on a reducing scale for properties between $150,000 to $200,000.\n"+
"- All applicants must have not previously owned a home.\n\n"+

"Home Buyers with Concession Cards\n"+
"- Full stamp duty exemption for properties valued up to $250,000\n"+
"- Stamp duty concessions on a reducing scale for properties between $250,000 to $350,000\n"+
"- Have a Pensioner Concession Card (Department of Social Security or Department of Veterans' Affairs), Veterans' Affairs Gold Card, Health Benefits Card, or Health Care Card.\n"+
"- Mortgage registration fee changed from $45 to $46.20.";

if (amount <= 20000) {
var duty = eval(((amount)/100)*1.4);

}
else if ((amount > 20000) && (amount <= 115000)) {
var duty = eval((((amount - 20000)/100)*2.4) + 280);
}

else if ((amount > 115000) && (amount <= 870000)) {
var duty = eval((((amount - 115000)/100)*6) + 2560);
}

else {
var duty = eval(((amount)/100)*5.5) ;
}
if ((loanamount % 200) != 0 ) {
var mod = eval(200-(loanamount % 200));
loanamount = -(-loanamount- mod);
}
/*
No more loan duty as of 1/7/2004

if (loanamount <= 10000) {
var loanduty = 4;
}
else {
var loanduty = eval((((loanamount - 10000)/200)*0.8) + 4);
}
*/
var loanduty = 0;

}

//********************** New South Wales *************************
else if (state.value == "NSW") {
var mortgage = 77.25;
var transfer = 77.25;
var exnotes = "First Home Plus Scheme\n"+
"- Full stamp and mortgage duty exemption for homes valued up to $500,000 in NSW\n"+
"- Stamp and mortgage duty concessions on a reducing scale for homes between $500,000 and $600,000 in NSW.\n"+
"- First home buyers purchasing vacant block of residential land will pay no stamp duty on land valued up to $300,000.\n"+
"- Discounts are available on stamp duty between $300,000 and $450,000.\n"+
"- Where the dutiable value of residential land exceeds $3 million, the duty payable is $150,490 plus $7 for every $100, or part by which the dutiable value exceeds $3 million";

if (amount <= 14000) {
var duty = eval((amount/100)*1.25);
}

else if ((amount > 14000) && (amount <= 30000)) {
var duty = eval((((amount - 14000)/100)*1.5) + 175);
}

else if ((amount > 30000) && (amount <= 80000)) {
var duty = eval((((amount - 30000)/100)*1.75) + 415);
}

else if ((amount > 80000) && (amount <= 300000)) {
var duty = eval((((amount - 80000)/100)*3.5) + 1290);
}

else if ((amount > 300000) && (amount <= 1000000)) {
var duty = eval((((amount - 300000)/100)*4.5) + 8990);
}

else {
var duty = eval((((amount - 1000000)/100)*5.5) + 40490);
}
if ((loanamount % 1000) != 0 ) {
var mod = eval(1000-(loanamount % 1000));
loanamount = -(-loanamount- mod);
}
if (loanamount <= 16000) {
var loanduty = 5;
}
else {
var loanduty = eval((((loanamount - 16000)/1000)*4) + 5);
}

}

//********************** ACT *************************
else if (state.value == "ACT") {
var mortgage = 84;
var transfer = 164;
var loanduty = 0;
var exnotes = "Home Buyer Concession\n"+
"- Eligibility is determined by income and the number of dependent children.\n"+
"- Minimum duty ($20) payable on properties valued less than $287,100. Concessional duty payable for properties valued between $287,100 and $389,300.\n"+
"-  First home buyer concession available for vacant blocks with property values up to $186,600.";

if (amount <= 100000) {
var duty = Math.max(Math.ceil(eval(amount/100))*2, 20);
}
else if (amount <= 200000) {
var duty = Math.ceil(eval((amount-100000)/100))*3.5 + 2000;
}
else if (amount <= 300000) {
var duty = Math.ceil(eval((amount-200000)/100))*4 + 5500;
}
else if (amount <= 500000) {
var duty = Math.ceil(eval((amount-300000)/100))*5.5 + 9500;
}
else if (amount <= 1000000) {
var duty = Math.ceil(eval((amount-500000)/100))*5.75 + 20500;
}
else {
var duty = Math.ceil(eval((amount-1000000)/100))*6.75 + 49250;
}
}

//********************** Queensland *************************
else if (state.value == "QLD") {
if ((t_amount % 10000) != 0 ) {
var mod = eval(10000-(t_amount % 10000));
t_amount = -(-t_amount - mod);
}
var transfer = 108.30;
if (t_amount > 180000) transfer += Math.ceil(eval((t_amount-180000)/10000))*23.10;

var mortgage = 108.30;

if (type == 'OO') {
var exnotes = "First Home Buyers' Rebate\n- Full stamp and mortgage duty exemption for properties valued up to $250,000.\n- Stamp duty rebate applies on a reducing scale for properties valued between $250,000 and $500,000.";

if(loanamount > 70000) loanduty = Math.ceil(eval((loanamount - 70000)/100)) * 0.40;
else loanduty = 0;
/*
if (amount <= 250000) {
var duty = eval((amount/100)*1);
}
else if ((amount > 250000) && (amount <= 500000)) {
var duty = eval((((amount - 250000)/100)*3.5) + 2500);
}
else {
var duty = eval((((amount - 500000)/100)*3.75) + 11250);
}
*/

/*if (amount <= 80000) var duty = 800;
else if (amount <= 300000) var duty = amount*0.01;
else if (amount <= 500000) var duty = 3000 + Math.ceil(eval((amount - 300000)/100)) * 3.5;
else var duty = 11250 + Math.ceil(eval((amount - 500000)/100)) * 3.75;

*/
if (amount <= 300000) var duty = Math.ceil(eval( amount /100)) * 1.0;
else if (amount <= 500000) var duty = 3000 + Math.ceil(eval((amount - 300000)/100)) * 3.5;
else var duty = 10000 + Math.ceil(eval((amount - 500000)/100)) * 3.75;
}
else {
var exnotes = "";

loanduty = Math.ceil(eval(loanamount/100)) * 0.40

if (amount <= 20000) var duty = Math.ceil(eval(amount/100)) * 1.5;
else if (amount <= 50000) var duty = 300 + Math.ceil(eval((amount - 20000)/100)) * 2.25;
else if (amount <= 100000) var duty = 975 + Math.ceil(eval((amount - 50000)/100)) * 2.75;
else if (amount <= 250000) var duty = 2350 + Math.ceil(eval((amount - 100000)/100)) * 3.25;
else if (amount <= 500000) var duty = 7225 + Math.ceil(eval((amount - 250000)/100)) * 3.5;
else var duty = 15975 + Math.ceil(eval((amount - 500000)/100)) * 3.75;
/*

if (amount <= 20000) {
var duty = Math.ceil(eval(amount/100))*1.5;
}
else if ((amount > 20000) && (amount <= 50000)) {
var duty = Math.ceil(eval((((amount - 20000)/100)*2.25) + 300);
}
else if ((amount > 50000) && (amount <= 100000)) {
var duty = eval((((amount - 50000)/100)*2.75) + 975);
}
else if ((amount > 100000) && (amount <= 250000)) {
var duty = eval((((amount - 100000)/100)*3.25) +2350);
}
else if ((amount > 250000) && (amount <= 500000)) {
var duty = eval((((amount - 250000)/100)*3.5) + 7225);
}
else {
var duty = eval((((amount - 500000)/100)*3.75) + 15975);
}
*/
}

}

//********************** South Australia *************************
else if (state.value == "SAN") {
if (amount <= 5000)
        transfer = 101;
    if (amount > 5000 && amount <= 20000)
        transfer = 112;
    if (amount > 20000 && amount <= 40000)
        transfer = 125;
    if (amount > 40000)
    { 
transfer = Math.ceil(eval((amount - 50000)/10000)*56) + 179;
}
mortgage = 101;

var exnotes = "First Home Owner's Concession\n"+
"Properties valued up to $80,500 will receive a full exemption from stamp duty.  Where the property is valued between $80,501 and $100,000, the concession will reduce from 100% to 50% (2.5% reduction per $1,000 of property value) and will remain at 50% where the property is valued between $100,001 and $150,000.  Thereafter the concession reduces by $24 for every $1,000 increase in property value above $150,000 and phases out completely for first home purchases above $250,000.\n\n"+

"From 1 July 2005, all mortgages taken out for the purposes of securing a loan that has been or is to be applied for home acquisition or improvement will be exempt from stamp duty.";

// Round up to next $100
amount = Math.ceil(amount/100.0)*100;

if (amount <= 12000) {
var duty = eval((amount/100.0)*1);
}

else if ((amount > 12000) && (amount <= 30000)) {
var duty = eval((((amount - 12000)/100)*2) + 120);
}

else if ((amount > 30000) && (amount <= 50000)) {
var duty = eval((((amount - 30000)/100)*3) + 480);
}

else if ((amount > 50000) && (amount <= 100000)) {
var duty = eval((((amount - 50000)/100)*3.5) + 1080);
}

else if ((amount > 100000) && (amount <= 200000)) {
var duty = eval((((amount - 100000)/100)*4) + 2830);
}
else if ((amount > 200000) && (amount <= 250000)) {
var duty = eval((((amount - 200000)/100)*4.25) + 6830);
}
else if ((amount > 250000) && (amount <= 300000)) {
var duty = eval((((amount - 250000)/100)*4.75) + 8955);
}
else if ((amount > 300000) && (amount <= 500000)) {
var duty = eval((((amount - 300000)/100)*5) + 11330);
}
else {
var duty = eval((((amount - 500000)/100)*5.5) + 21330);
}

loanamount = Math.ceil(loanamount/100)*100;

if (loanamount <= 400) {
var loanduty = 0;
}
else if ((loanamount > 400) && (loanamount <= 6000)) {

if (type == "OO") {var loanduty = 0;}
          else {var loanduty = 10;};
}
else {
if (type == "OO") var loanduty = 0; //eval((((loanamount - 6000)/100)*0.35) + 10);
else var loanduty = eval((((loanamount - 6000)/100)*0.45) + 10);
}
}

//********************** Tasmania *************************
else if (state.value == "TAS") {
var mortgage = 85.50;
var transfer = 131;
var exnotes = "First Home Owner's Rebate\n"+
"- Homes purchased after 20th May 2004 will receive up to $4,000 stamp duty relief for homes purchased for less than $350,000.\n"+
"- A concession of $2,400 is available for the purchase of vacant land providing the dutiable value does not exceed $175,000.\n"+
"- Property must be first home and intended as principal residence.";
if (amount <= 1300) {
var duty = 20;
}
else if ((amount > 1300) && (amount <= 10000)) {
var duty = eval((amount/100)*1.5);
}

else if ((amount > 10000) && (amount <= 30000)) {
var duty = eval((((amount - 10000)/100)*2) + 150);
}

else if ((amount > 30000) && (amount <= 75000)) {
var duty = eval((((amount - 30000)/100)*2.5) + 550);
}

else if ((amount > 75000) && (amount <= 150000)) {
var duty = eval((((amount - 75000)/100)*3) + 1675);
}

else if ((amount > 150000) && (amount <= 225000)) {
var duty = eval((((amount - 150000)/100)*3.5) + 3925);
}

else {
var duty = eval((((amount - 225000)/100)*4) + 6550);
}

if (loanamount <= 8000) {
var loanduty = 20;
}
else if ((loanamount > 8000) && (loanamount <= 10000)) {
var loanduty = eval((((loanamount - 8000)/100)*0.25) + 20);
}
else {
var loanduty = eval((((loanamount - 10000)/100)*0.35) + 25);
}
}

//********************** Western Australia *************************
else if (state.value == "WAN") {
if (amount <= 85000) {
var transfer = 80;
}
else if ((amount > 85000) && (amount <= 120000)) {
var transfer = 90;
}
else if ((amount > 120000) && (amount <= 200000)) {
var transfer = 110;
}
else if ((amount > 200000) && (amount <= 300000)) {
var transfer = 130;
}
else if ((amount > 300000) && (amount <= 400000)) {
var transfer = 150;
}
else if ((amount > 400000) && (amount <= 500000)) {
var transfer = 170;
}
else if ((amount > 500000) && (amount <= 600000)) {
var transfer = 190;
}
else if ((amount > 600000) && (amount <= 700000)) {
var transfer = 210;
}
else if ((amount > 700000) && (amount <= 800000)) {
var transfer = 230;
}
else if ((amount > 800000) && (amount <= 900000)) {
var transfer = 250;
}
else if ((amount > 900000) && (amount <= 1000000)) {
var transfer = 270;
}
else if ((amount > 1000000) && (amount <= 1100000)) {
var transfer = 290;
}
else if ((amount > 1100000) && (amount <= 1200000)) {
var transfer = 310;
}
else if ((amount > 1200000) && (amount <= 1300000)) {
var transfer = 330;
}
else if ((amount > 1300000) && (amount <= 1400000)) {
var transfer = 350;
}
else if ((amount > 1400000) && (amount <= 1500000)) {
var transfer = 370;
}
else if ((amount > 1500000) && (amount <= 1600000)) {
var transfer = 390;
}
else if ((amount > 1600000) && (amount <= 1700000)) {
var transfer = 410;
}
else if ((amount > 1700000) && (amount <= 1800000)) {
var transfer = 430;
}
else if ((amount > 1800000) && (amount <= 1900000)) {
var transfer = 450;
}
else if ((amount > 1900000) && (amount <= 2000000)) {
var transfer = 470;
}
else if ((amount > 2000000) && (amount <= 2100000)) {
var transfer = 490;
}
else if ((amount > 2100000) && (amount <= 2200000)) {
var transfer = 510;
}
else if ((amount > 2200000) && (amount <= 2300000)) {
var transfer = 530;
}
else if ((amount > 2300000) && (amount <= 2400000)) {
var transfer = 550;
}
else if ((amount > 2400000) && (amount <= 2500000)) {
var transfer = 570;
}
else if ((amount > 2500000) && (amount <= 2600000)) {
var transfer = 590;
}
else if ((amount > 2600000) && (amount <= 2700000)) {
var transfer = 610;
}
else if ((amount > 2700000) && (amount <= 2800000)) {
var transfer = 630;
}
else if ((amount > 2800000) && (amount <= 2900000)) {
var transfer = 650;
}
else if ((amount > 2900000) && (amount <= 3000000)) {
var transfer = 670;
}

else {
var transfer = Math.ceil(eval((amount - 200000)/100000))*20 + 669;
}

mortgage = 80;
var exnotes = "Concessional Rate\n-Applies to purchase of principal place of residence or business undertaking with a dutiable value not exceeding $200,000.\nThe concessional rate is $1.50 per $100 (or part thereof) up to $100,000 and $4.70 per $100 (or part thereof) for that amount between $100,001 and $200,000.\n\nFirst Home Owner's Rebate\n- Property must be first home and intended as principal residence.\n- First home buyers will get a full exemption from conveyance duty on homes up to $250,000. Then for every $100 or part thereof above $250,000, $13.20 duty is payable, up to $350,000.\n- First home purchasers buying vacant land and building a home will receive full rebate on land values to $150,000 and a partial rebate on land values to $200,000.";

if (type == 'OO' && amount <= 200000) {
if (amount <= 100000) {
var duty = Math.ceil(eval(amount/100))*1.5;
}
else {
var duty = Math.ceil(eval((amount - 100000) / 100)) *4.7 + 1500;
}
}
else {
if (amount <= 80000) {
var duty = Math.ceil(eval(amount/100))*2.0;
}

else if ((amount > 80000) && (amount <= 100000)) {
var duty = Math.ceil(eval((amount - 80000)/100))*3.0 + 1600;
}

else if ((amount > 100000) && (amount <= 250000)) {
var duty = Math.ceil(eval((amount - 100000)/100))*4.0 + 2200;
}

else if ((amount > 250000) && (amount <= 500000)) {
var duty = Math.ceil(eval((amount - 250000)/100))*5.0 + 8200;
}

else {
var duty = Math.ceil(eval((amount - 500000)/100))*5.4 + 20700;
}
}

        var loanduty = 20;

if (type =="OO") {
    if (loanamount > 8000) loanduty += Math.ceil(eval((loanamount-8000)/100)) * 0.25;
}
else {
if (loanamount > 5000) loanduty += Math.ceil(eval((loanamount-5000)/100)) * 0.40;
}
}

//********************** Northern Territory  *************************
else if (state.value == "NT") {
var mortgage = 90;
var transfer = 90;
var loanduty = 0;

var exnotes = "First Home Owner's Concession\n"+
"- If property is your first home anywhere in Australia, then you may be eligible for a concession of up to $8,015.60 on the total stamp duty payable.  This represents the duty on the first $225,000 of the property value.\n"+
"- Property may be an existing home or land to build a new home.\n\n"+

"Principal Place of Residence Rebate\n"+
"- If property is your principal place of residence you may be eligible for a stamp duty rebate of up to $2,500.";

// A rebate of up to $3,640.60 off the total stamp duty payable\n- Property must be first home and intended as principal residence"

if (amount <=500000) {
newamount = eval(amount / 1000);
var duty = eval((0.065 * Math.pow(newamount,2)) + (21 * newamount));
}

else {
var duty = eval(0.054 * amount);
}
if (type =="OO") {
duty = duty - 2500;
if (duty < 0) duty = 0;
}
}
total = eval(duty + loanduty + mortgage + transfer);
total = rounding(total);
duty = rounding(duty);
loanduty = rounding(loanduty);
mortgage = rounding(mortgage);
transfer = rounding(transfer);

formfield.duty.value = duty;
formfield.loanduty.value = loanduty;
formfield.mortgage.value = mortgage;
formfield.transfer.value = transfer;
formfield.total.value = total;
formfield.notes.value = exnotes;
}
function rounding(n) {
pennies = n * 100;
pennies = Math.round(pennies);
strPennies = "" + pennies;
len = strPennies.length;
return strPennies.substring(0, len - 2) + "." + strPennies.substring((len - 2), len);
}
-->