﻿// JavaScript Document
function calculate(){A=document.indScale.annIncome.value
B=document.indScale.houseSize.value
A=A.replace(/[^\w^\s^\p{Sc}^\p{M}^\p{P}]/g, "");alert(A)
B=B.replace(/[^\w^\s^\p{Sc}^\p{M}^\p{P}]/g, "");alert(B)
var deduction=(5.350)
var single=(.001)
var multiplier=(7.8/5)
if (Number(A)&& Number(B)){A=Number(A)
B=Number(B)
if (B==1){if (A * multiplier > 125){C=(125)
}
else if (A * multiplier < 40){C=(40)
}
else{C=Math.round(A * multiplier)
}}
else if (B > 1 && B < 6){if ((A - (B-1)*deduction)* multiplier > 125){C=(125)
}
else if ((A - (B-1)*deduction)* multiplier < 40){C=(40)
}
else{C=Math.round((A - (B-1)*deduction)* multiplier)
}}
else{B=(5)
if ((A - (B-1)*deduction)* multiplier > 125){C=(125)
}
else if ((A - (B-1)*deduction)* multiplier < 40){C=(40)
}
else{C=Math.round((A - (B-1)*deduction)* multiplier)
}}
document.indScale.suggFee.value="$"+C
}
else{alert("Please enter non-zero numbers in both boxes.\r\rAnnual income is etimated in THOUSANDS $US: $50,000=50 — without commas.\r\rPlease include income from all residents.");}}
function gcalculate(){D=document.groupScale.gannIncome.value
E=document.groupScale.ghouseSize.value
var deduction=(5.350)
var single=(.001)
var multiplier=(.6)
if (Number(D)&& Number(E)){D=Number(D)
E=Number(E)
if (E==1){if (D * multiplier > 45){F=(45)
}
else if (D * multiplier < 15){F=(15)
}
else{F=Math.round(D * multiplier)
}}
else if (E > 1 && E < 6){if ((D - (E-1)*deduction)* multiplier > 45){F=(45)
}
else if ((D - (E-1)*deduction)* multiplier < 15){F=(15)
}
else{F=Math.round((D - (E-1)*deduction)* multiplier)
}}
else{E=(5)
if ((D - (E-1)*deduction)* multiplier > 45){F=(45)
}
else if ((D - (E-1)*deduction)* multiplier < 15){F=(15)
}
else{F=Math.round((D - (E-1)*deduction)* multiplier)
}}
document.groupScale.gsuggFee.value="$"+F
}
else{alert("Please enter non-zero numbers in both boxes.\r\rAnnual income is etimated in THOUSANDS $US: $50,000=50 — without commas.\r\rPlease include income from all household residents.");}}
function annmsg(){alert("Estimated in THOUSANDS $US: $50,000=50.\r\rPlease include income from all household residents.\r\rAfter entering value, please tab to next field.");}
function housemsg(){alert("Household Size=Total adults \& dependents in home.\r\rAfter entering value, please tab to next field.");}
function affordmsg(){alert("The fee you can realistically afford may differ from this figure.\r\rWe can discuss your individual needs during your initial consultation.")
}
function addLoadEvent(func){var oldonload=window.onload;if (typeof window.onload !='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
function prepareInputsForHints(){var inputs=document.getElementsByTagName("input");for (var i=0;i<inputs.length;i++){
if (inputs[i].parentNode.getElementsByTagName("span")[0]){
inputs[i].onfocus=function (){this.parentNode.getElementsByTagName("span")[0].style.display="inline";}
inputs[i].onblur=function (){this.parentNode.getElementsByTagName("span")[0].style.display="none";}}}
var selects=document.getElementsByTagName("select");for (var k=0;k<selects.length;k++){if (selects[k].parentNode.getElementsByTagName("span")[0]){selects[k].onfocus=function (){this.parentNode.getElementsByTagName("span")[0].style.display="inline";}
selects[k].onblur=function (){this.parentNode.getElementsByTagName("span")[0].style.display="none";}}}}
addLoadEvent(prepareInputsForHints);function BrowserCheck(){var b=navigator.appName;if (b=="Netscape")this.b="NS";else if (b=="Microsoft Internet Explorer")this.b="IE";else this.b=b;this.v=parseInt(navigator.appVersion);this.NS=(this.b=="NS" && this.v>=4);this.NS4=(this.b=="NS" && this.v==4);this.NS5=(this.b=="NS" && this.v==5);this.IE=(this.b=="IE" && this.v>=4);this.IE4=(navigator.userAgent.indexOf('MSIE 4')>0);this.IE5=(navigator.userAgent.indexOf('MSIE 5')>0);if (this.IE5||this.NS5)this.VER5=true;if (this.IE4||this.NS4)this.VER4=true;this.OLD=(! this.VER5 && ! this.VER4)? true : false;this.min=(this.NS||this.IE);}
is=new BrowserCheck();alertBox=(is.VER5)? document.getElementById("alertLayer").style
: (is.NS)? document.layers["alertLayer"]
: document.all["alertLayer"].style;function hideAlert(){alertBox.visibility="hidden";}
function makeAlert(aTitle,aMessage){document.all.alertLayer.innerHTML="<table border=0 width=100% height=100%>"+
"<tr height=5><td colspan=4 class=alertTitle>"+" "+aTitle+"</td></tr>"+
"<tr height=5><td width=5></td></tr>"+
"<tr><td width=5></td><td width=20 align=left><img src='alert.gif'></td><td align=center class=alertMessage>"+aMessage+"<BR></td><td width=5></td></tr>"+
"<tr height=5><td width=5></td></tr>"+
"<tr><td width=5></td><td colspan=2 align=center><input type=button value='OK' onClick='hideAlert()' class=okButton><BR></td><td width=5></td></tr>"+
"<tr height=5><td width=5></td></tr></table>";thisText=aMessage.length;if (aTitle.length > aMessage.length){thisText=aTitle.length;}
aWidth=(thisText * 5)+80;aHeight=100;if (aWidth < 150){aWidth=200;}
if (aWidth > 350){aWidth=350;}
if (thisText > 60){aHeight=110;}
if (thisText > 120){aHeight=130;}
if (thisText > 180){aHeight=150;}
if (thisText > 240){aHeight=170;}
if (thisText > 300){aHeight=190;}
if (thisText > 360){aHeight=210;}
if (thisText > 420){aHeight=230;}
if (thisText > 490){aHeight=250;}
if (thisText > 550){aHeight=270;}
if (thisText > 610){aHeight=290;}
alertBox.width=aWidth;alertBox.height=aHeight;alertBox.left=(document.body.clientWidth - aWidth)/2;alertBox.top=(document.body.clientHeight - aHeight)/2;alertBox.visibility="visible";}
