function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == ‘none’)
e.style.display = ‘block’;
else
e.style.display = ‘none’;
}
function formatCurrency(strValue) {
strValue = strValue.toString().replace(/$|,/g,”);
dblValue = parseFloat(strValue);
blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
dblValue = Math.floor(dblValue*100+0.50000000001);
intCents = dblValue%100;
strCents = intCents.toString();
dblValue = Math.floor(dblValue/100).toString();
if(intCents<10)
strCents = “0” + strCents;
for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+’,’+
dblValue.substring(dblValue.length-(4*i+3));
return (((blnSign)?”:’-‘) + ‘$’ + dblValue + ‘.’ + strCents);
}
// TITLE CALCULATOR
function startTitleCalc(form) {
var tempTitleAmount = form.TitleAmount.value;
var titleAmount = new Number;
titleAmount = parseInt(tempTitleAmount);
var titleState = form.TitleState.value;
var titleType = form.TitleType.value;
// VARIABLES
var insuranceAmount = new Number;
var base1 = new Number;
var base2 = new Number;
var base3 = new Number;
var base4 = new Number;
var base5 = new Number;
var base6 = new Number;
var base7 = new Number;
var base8 = new Number;
var interimAmount = new Number;
var estimatedTotal = new Number;
var insuranceAndFees = new Number;
var tempSaleAmount = form.TitleAmount.value;
if (titleState == “New Jersey” && titleType == “Purchase”) {
if (titleAmount <= 100000) {
if (titleAmount <= 40000) { insuranceAmount = 200; } else { insuranceAmount = (titleAmount / 1000) * 5.25; } } else if (titleAmount > 100000 && titleAmount <= 500000) { base1 = (100000 / 1000) * 5.25; interimAmount = ((titleAmount – 100000) / 1000) * 4.25; insuranceAmount = base1 + interimAmount; } else if (titleAmount > 500000 && titleAmount <= 2000000) { base1 = (100000 / 1000) * 5.25; base2 = (400000 / 1000) * 4.25; interimAmount = ((titleAmount – 500000) / 1000) * 2.75; insuranceAmount = base1 + base2 + interimAmount; } else if (titleAmount > 2000000) {
base1 = (100000 / 1000) * 5.25;
base2 = (400000 / 1000) * 4.25;
base3 = (1500000 / 1000) * 2.75;
interimAmount = ((titleAmount – 2000000) / 1000) * 2.00;
insuranceAmount = base1 + base2 + base3 + interimAmount;
} else {
alert(“Title Calculator Error – New Jersey / Purchase”);
return false;
}
insuranceAndFees = insuranceAmount + 440;
} else if (titleState == “New Jersey” && titleType == “Refinance”) {
if (titleAmount <= 100000) {
if (titleAmount <= 80000) { insuranceAmount = 200; } else { insuranceAmount = (titleAmount / 1000) * 2.75; } } else if (titleAmount > 100000 && titleAmount <= 500000) { base1 = (100000 / 1000) * 2.75; interimAmount = ((titleAmount – 100000) / 1000) * 2.5; insuranceAmount = base1 + interimAmount; } else if (titleAmount > 500000 && titleAmount <= 2000000) { base1 = (100000 / 1000) * 2.75; base2 = (400000 / 1000) * 2.5; interimAmount = ((titleAmount – 500000) / 1000) * 2.25; insuranceAmount = base1 + base2 + interimAmount; } else if (titleAmount > 2000000) {
base1 = (100000 / 1000) * 2.75;
base2 = (400000 / 1000) * 2.5;
base3 = (1500000 / 1000) * 2.25;
interimAmount = ((titleAmount – 2000000) / 1000) * 1.75;
insuranceAmount = base1 + base2 + base3 + interimAmount;
} else {
alert(“Title Calculator Error – New Jersey / Refinance”);
return false;
}
insuranceAndFees = insuranceAmount + 445;
} else if (titleState == “Pennsylvania” && titleType == “Purchase”) {
if (titleAmount <= 30000) { insuranceAmount = 500.00; } else if (titleAmount > 30000 && titleAmount <= 45000) { base1 = 500.00; interimAmount = ((titleAmount – 30000) / 1000) * 6.50; insuranceAmount = base1 + interimAmount; } else if (titleAmount > 45000 && titleAmount <= 100000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; interimAmount = ((titleAmount – 45000) / 1000) * 5.50; insuranceAmount = base1 + base2 + interimAmount; } else if (titleAmount > 100000 && titleAmount <= 500000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; base3 = (55000 / 1000) * 5.50; interimAmount = ((titleAmount – 100000) / 1000) * 5.00; insuranceAmount = base1 + base2 + base3 + interimAmount; } else if (titleAmount > 500000 && titleAmount <= 1000000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; base3 = (55000 / 1000) * 5.50; base4 = (400000 / 1000) * 5.00; interimAmount = ((titleAmount – 500000) / 1000) * 4.00; insuranceAmount = base1 + base2 + base3 + base4 + interimAmount; } else if (titleAmount > 1000000 && titleAmount <= 2000000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; base3 = (55000 / 1000) * 5.50; base4 = (400000 / 1000) * 5.00; base5 = (500000 / 1000) * 4.00; interimAmount = ((titleAmount – 1000000) / 1000) * 3.00; insuranceAmount = base1 + base2 + base3 + base4 + base5 + interimAmount; } else if (titleAmount > 2000000 && titleAmount <= 7000000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; base3 = (55000 / 1000) * 5.50; base4 = (400000 / 1000) * 5.00; base5 = (500000 / 1000) * 4.00; base6 = (1000000 / 1000) * 3.00; interimAmount = ((titleAmount – 2000000) / 1000) * 2.00; insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + interimAmount; } else if (titleAmount > 7000000 && titleAmount < 30000000) { base1 = 500.00; base2 = (15000 / 1000) * 6.50; base3 = (55000 / 1000) * 5.50; base4 = (400000 / 1000) * 5.00; base5 = (500000 / 1000) * 4.00; base6 = (1000000 / 1000) * 3.00; base7 = (5000000 / 1000) * 2.00; interimAmount = ((titleAmount – 7000000) / 1000) * 1.50; insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + base7 + interimAmount; } else if (titleAmount > 30000000) {
base1 = 500.00; // 30000
base2 = (15000 / 1000) * 6.50;
base3 = (55000 / 1000) * 5.50;
base4 = (400000 / 1000) * 5.00;
base5 = (500000 / 1000) * 4.00;
base6 = (1000000 / 1000) * 3.00;
base7 = (5000000 / 1000) * 2.00;
base8 = (23000000 / 1000) * 1.50;
interimAmount = ((titleAmount – 30000000) / 1000) * 1.25;
insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + base7 + base8 + interimAmount;
} else {
alert(“Title Calculator Error – Pennsylvania / Purchase”);
return false;
}
insuranceAndFees = insuranceAmount + 455;
} else if (titleState == “Pennsylvania” && titleType == “Refinance”) {
if (titleAmount <= 30000) { insuranceAmount = 450.00; } else if (titleAmount > 30000 && titleAmount <= 45000) { base1 = 450.00; interimAmount = ((titleAmount – 30000) / 1000) * 6.50; insuranceAmount = base1 + interimAmount; } else if (titleAmount > 45000 && titleAmount <= 100000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; interimAmount = ((titleAmount – 45000) / 1000) * 4.75; insuranceAmount = base1 + base2 + interimAmount; } else if (titleAmount > 100000 && titleAmount <= 500000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; base3 = (55000 / 1000) * 4.75; interimAmount = ((titleAmount – 100000) / 1000) * 4.25; insuranceAmount = base1 + base2 + base3 + interimAmount; } else if (titleAmount > 500000 && titleAmount <= 1000000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; base3 = (55000 / 1000) * 4.75; base4 = (400000 / 1000) * 4.25; interimAmount = ((titleAmount – 500000) / 1000) * 3.75; insuranceAmount = base1 + base2 + base3 + base4 + interimAmount; } else if (titleAmount > 1000000 && titleAmount <= 2000000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; base3 = (55000 / 1000) * 4.75; base4 = (400000 / 1000) * 4.25; base5 = (500000 / 1000) * 3.75; interimAmount = ((titleAmount – 1000000) / 1000) * 2.75; insuranceAmount = base1 + base2 + base3 + base4 + base5 + interimAmount; } else if (titleAmount > 2000000 && titleAmount <= 7000000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; base3 = (55000 / 1000) * 4.75; base4 = (400000 / 1000) * 4.25; base5 = (500000 / 1000) * 3.75; base6 = (1000000 / 1000) * 2.75; interimAmount = ((titleAmount – 2000000) / 1000) * 1.75; insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + interimAmount; } else if (titleAmount > 7000000 && titleAmount < 30000000) { base1 = 450.00; base2 = (15000 / 1000) * 5.25; base3 = (55000 / 1000) * 4.75; base4 = (400000 / 1000) * 4.25; base5 = (500000 / 1000) * 3.75; base6 = (1000000 / 1000) * 2.75; base7 = (5000000 / 1000) * 1.75; interimAmount = ((titleAmount – 7000000) / 1000) * 1.50; insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + base7 + interimAmount; } else if (titleAmount > 30000000) {
base1 = 450.00;
base2 = (15000 / 1000) * 5.25;
base3 = (55000 / 1000) * 4.75;
base4 = (400000 / 1000) * 4.25;
base5 = (500000 / 1000) * 3.75;
base6 = (1000000 / 1000) * 2.75;
base7 = (5000000 / 1000) * 1.75;
base8 = (23000000 / 1000) * 1.50;
interimAmount = ((titleAmount – 30000000) / 1000) * 1.25;
insuranceAmount = base1 + base2 + base3 + base4 + base5 + base6 + base7 + base8 + interimAmount;
} else {
alert(“Title Calculator Error – Pennsylvania / Refinance”);
return false;
}
insuranceAndFees = insuranceAmount + 455;
}
if (tempSaleAmount == null || tempSaleAmount ==””) {
alert(“Please enter an amount.”);
return false;
} else {
toggle_visibility(‘TitleCalc’);
if (titleState == “New Jersey” && titleType == “Purchase”) {
var propertyAmountCurrency = formatCurrency(titleAmount);
document.getElementById(‘purchaseAmountNJ’).innerHTML = propertyAmountCurrency;
var insuranceamountcurrency = formatCurrency(insuranceAmount);
document.getElementById(‘ContentPlaceHolder1_lbl_insuranceAmountNJ’).innerHTML = insuranceamountcurrency;
var insuranceAndFeesCurrency = formatCurrency(insuranceAndFees);
document.getElementById(‘ContentPlaceHolder1_lbl_totalNJ’).innerHTML = insuranceAndFeesCurrency;
toggle_visibility(‘NJPurchase’);
} else if (titleState == “New Jersey” && titleType == “Refinance”) {
var propertyAmountCurrency = formatCurrency(titleAmount);
document.getElementById(‘refiAmountNJ’).innerHTML = propertyAmountCurrency;
var insuranceamountcurrency = formatCurrency(insuranceAmount);
document.getElementById(‘ContentPlaceHolder1_lbl_insuranceAmountNJRefi’).innerHTML = insuranceamountcurrency;
var insuranceAndFeesCurrency = formatCurrency(insuranceAndFees);
document.getElementById(‘ContentPlaceHolder1_lbl_totalNJRefi’).innerHTML = insuranceAndFeesCurrency;
toggle_visibility(‘NJRefinance’);
} else if (titleState == “Pennsylvania” && titleType == “Purchase”) {
var propertyAmountCurrency = formatCurrency(titleAmount);
document.getElementById(‘purchaseAmountPA’).innerHTML = propertyAmountCurrency;
var insuranceamountcurrency = formatCurrency(insuranceAmount);
document.getElementById(‘ContentPlaceHolder1_lbl_insuranceAmountPA’).innerHTML = insuranceamountcurrency;
var insuranceAndFeesCurrency = formatCurrency(insuranceAndFees);
document.getElementById(‘ContentPlaceHolder1_lbl_totalPA’).innerHTML = insuranceAndFeesCurrency;
toggle_visibility(‘PAPurchase’);
} else if (titleState == “Pennsylvania” && titleType == “Refinance”) {
var propertyAmountCurrency = formatCurrency(titleAmount);
document.getElementById(‘refiAmountPA’).innerHTML = propertyAmountCurrency;
var insuranceamountcurrency = formatCurrency(insuranceAmount);
document.getElementById(‘ContentPlaceHolder1_lbl_insuranceAmountPARefi’).innerHTML = insuranceamountcurrency;
var insuranceAndFeesCurrency = formatCurrency(insuranceAndFees);
document.getElementById(‘ContentPlaceHolder1_lbl_totalPARefi’).innerHTML = insuranceAndFeesCurrency;
toggle_visibility(‘PARefinance’);
} else {
alert(“An error occurred.”);
return false;
}
}
}