Sentencing Guidelines Calculator

<style>
#childSupportCalculator input{
	max-width: 100px;
}
#childSupportCalculator{
	max-width: 800px;
}
#childSupportCalculator .calc-col1{
	max-width: 250px;
}
#childSupportCalculator .calc-col2, #childSupportCalculator .calc-col3{
	min-width: 120px;
}
#childSupportCalculator, #childSupportCalculator tr, #childSupportCalculator td, #childSupportCalculator th{
	border: 1px solid black;
	border-collapse: collapse;
	padding: 3px;
}
#childSupportCalculator input{
	margin-left: 3px;
}
#childSupportCalculator input[readonly]{
	background-color: #DDDDDD;
}
#childSupportCalculator #calc-errorMessage{
	color: #FF0000;
}
</style>
<table id="childSupportCalculator">
	<tbody>
		<tr>
			<th colspan="3">
				Number of Minor Children:
				<select id="calc-minorChildren">
					<option value="-1">Select</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
				</select>
			</th>
		</tr>
		<tr>
			<td class="calc-col1"></td>
			<th class="calc-col2">Custodial Parent</th>
			<th class="calc-col3">Non-Custodial Parent</th>
		</tr>
		<tr id="calc-monthlyGrossIncome">
			<th class="calc-col1">Monthly gross income</th>
			<th class="calc-col2">$<input class="calc-num-input calc-custodial" value="0"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0"></th>
		</tr>
		<tr id="calc-deductionForAlimony">
			<th class="calc-col1">Deduction for alimony</th>
			<th class="calc-col2">$<input class="calc-num-input calc-custodial" value="0"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0"></th>
		</tr>
		<tr id="calc-deductionForOther">
			<th class="calc-col1">Deduction for other child support for prior born child(ren)</th>
			<th class="calc-col2">$<input class="calc-num-input calc-custodial" value="0"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0"></th>
		</tr>
		<tr id="calc-monthlyChildCare">
			<th class="calc-col1">Additional monthly child care costs</th>
			<th class="calc-col2">$<input class="calc-num-input calc-custodial" value="0"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0"></th>
		</tr>
		<tr id="calc-monthlyHealthInsurance">
			<th class="calc-col1">Child(ren)'s monthly health insurance premium cost</th>
			<th class="calc-col2">$<input class="calc-num-input calc-custodial" value="0"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0"></th>
		</tr>
		<tr id="calc-presumedMonthlyObligation">
			<th class="calc-col1">Presumed monthly child support obligation</th>
			<th class="calc-col2"></th>
			<th class="calc-col3">$<input class="calc-num-input calc-non-custodial" value="0" readonly=""></th>
		</tr>
		<tr>
			<th colspan="3">
				<text id="calc-errorMessage"></text>
				<button id="calc-calculate">Calculate</button>
			</th>
		</tr>
	</tbody>
</table>
<script>
(function(){
	var childSupportChart = [[50,50,50,50,50,50],[60,61,61,62,63,63],[91,93,94,95,96,97],[123,124,126,127,129,130],[155,156,158,160,162,163],[189,191,193,195,198,200],[224,227,229,232,234,237],[253,262,265,268,271,274],[262,298,301,304,307,311],[272,333,337,340,344,348],[281,368,372,376,381,385],[290,404,408,413,417,422],[299,435,444,449,454,459],[308,447,478,483,488,494],[316,459,512,517,523,528],[325,471,545,551,557,563],[333,483,570,585,592,598],[342,495,584,619,626,633],[350,507,598,653,660,667],[359,519,611,683,694,702],[367,532,626,699,729,736],[376,545,641,716,763,771],[385,558,656,733,797,806],[394,571,672,750,825,840],[403,584,687,767,844,875],[412,597,702,784,863,909],[421,609,717,801,882,944],[430,622,733,818,900,979],[439,635,748,835,919,999],[448,648,763,852,938,1019],[457,661,778,869,956,1040],[465,674,794,886,975,1060],[474,687,808,903,993,1079],[483,699,823,919,1011,1099],[491,712,837,935,1029,1119],[500,724,852,952,1047,1138],[509,737,867,968,1065,1158],[518,749,882,985,1083,1177],[526,762,896,1001,1101,1197],[535,774,911,1018,1119,1217],[544,787,926,1034,1137,1236],[552,799,940,1050,1155,1256],[561,812,955,1067,1173,1275],[570,824,970,1083,1191,1295],[579,837,984,1100,1210,1315],[587,849,999,1116,1228,1334],[596,862,1014,1132,1246,1354],[605,875,1028,1149,1264,1374],[613,887,1043,1165,1282,1393],[618,894,1052,1175,1292,1405],[623,902,1060,1184,1302,1416],[628,909,1068,1193,1313,1427],[633,915,1076,1202,1322,1437],[637,921,1083,1210,1331,1447],[642,928,1090,1218,1340,1456],[646,934,1098,1226,1349,1466],[650,940,1105,1234,1358,1476],[655,946,1112,1242,1367,1485],[659,953,1119,1250,1375,1495],[663,959,1127,1259,1384,1505],[668,965,1134,1267,1393,1514],[672,971,1141,1275,1402,1524],[677,977,1148,1283,1411,1534],[681,984,1156,1291,1420,1544],[685,990,1163,1299,1429,1553],[690,996,1170,1307,1438,1563],[694,1002,1178,1315,1447,1573],[698,1009,1185,1323,1456,1582],[703,1015,1192,1331,1464,1592],[707,1021,1199,1339,1473,1601],[712,1027,1206,1347,1482,1611],[716,1033,1213,1355,1490,1620],[720,1040,1220,1363,1499,1629],[725,1046,1227,1371,1508,1639],[729,1052,1234,1378,1516,1648],[734,1058,1241,1386,1525,1658],[738,1064,1248,1394,1534,1667],[743,1071,1255,1402,1542,1676],[747,1077,1262,1410,1551,1686],[752,1083,1269,1418,1559,1695],[756,1089,1276,1426,1568,1705],[759,1094,1281,1431,1574,1711],[762,1098,1285,1436,1579,1717],[765,1101,1289,1440,1584,1722],[769,1105,1293,1445,1589,1727],[772,1109,1297,1449,1594,1733],[775,1113,1301,1454,1599,1738],[778,1117,1305,1458,1604,1744],[781,1121,1309,1463,1609,1749],[784,1125,1314,1467,1614,1754],[787,1129,1318,1472,1619,1760],[790,1133,1322,1476,1624,1765],[793,1136,1326,1481,1629,1771],[796,1140,1330,1485,1634,1776],[798,1144,1333,1489,1638,1780],[800,1146,1336,1492,1642,1785],[802,1149,1339,1496,1645,1789],[804,1152,1342,1499,1649,1793],[806,1154,1345,1503,1653,1797],[808,1157,1348,1506,1656,1801],[810,1160,1351,1509,1660,1805],[812,1163,1354,1513,1664,1809],[814,1165,1357,1516,1668,1813],[816,1168,1360,1519,1671,1817],[818,1171,1363,1523,1675,1821],[820,1173,1366,1526,1679,1825],[822,1176,1369,1529,1682,1829],[824,1179,1372,1533,1686,1833],[826,1182,1375,1536,1690,1837],[828,1184,1378,1540,1693,1841],[830,1187,1381,1543,1697,1845],[832,1190,1384,1546,1701,1849],[834,1192,1387,1550,1705,1853],[836,1195,1390,1553,1708,1857],[839,1200,1396,1559,1715,1864],[843,1205,1401,1565,1722,1872],[847,1210,1407,1571,1729,1879],[850,1215,1412,1578,1736,1886],[854,1220,1418,1584,1742,1894],[857,1225,1424,1590,1749,1901],[861,1230,1429,1596,1756,1909],[864,1235,1435,1603,1763,1916],[868,1240,1440,1609,1770,1924],[872,1245,1446,1615,1777,1931],[875,1250,1452,1621,1784,1939],[879,1254,1457,1627,1790,1946],[882,1259,1462,1633,1797,1953],[886,1264,1468,1639,1803,1960],[889,1269,1473,1645,1810,1967],[892,1273,1478,1651,1816,1974],[896,1278,1484,1657,1823,1981],[899,1283,1489,1663,1829,1989],[903,1288,1494,1669,1836,1996],[906,1292,1500,1675,1843,2003],[910,1297,1505,1681,1849,2010],[913,1302,1510,1687,1856,2017],[916,1307,1516,1693,1862,2024],[920,1311,1521,1699,1869,2031],[923,1316,1526,1705,1875,2039],[927,1321,1532,1711,1882,2046],[930,1326,1537,1717,1889,2053],[934,1330,1542,1723,1895,2060],[937,1335,1548,1729,1902,2067],[940,1340,1553,1735,1908,2074],[944,1345,1558,1741,1915,2081],[947,1349,1564,1747,1921,2088],[951,1354,1569,1753,1928,2096],[954,1359,1575,1759,1935,2103],[957,1364,1580,1765,1941,2110],[961,1368,1585,1771,1948,2118],[964,1373,1591,1777,1955,2125],[967,1378,1596,1783,1961,2132],[971,1382,1602,1789,1968,2139],[974,1387,1607,1795,1975,2147],[977,1392,1613,1801,1981,2154],[980,1396,1618,1807,1988,2161],[984,1401,1623,1813,1995,2168],[987,1406,1629,1819,2001,2176],[990,1410,1634,1826,2008,2183],[993,1415,1640,1832,2015,2190],[997,1420,1645,1838,2021,2197],[1000,1424,1651,1844,2028,2205],[1003,1429,1656,1850,2035,2212],[1006,1434,1661,1856,2041,2219],[1010,1438,1667,1862,2048,2226],[1013,1443,1672,1868,2055,2234],[1016,1448,1678,1874,2062,2241],[1020,1452,1683,1880,2068,2248],[1023,1457,1689,1886,2075,2255],[1026,1462,1694,1892,2082,2263],[1029,1466,1700,1898,2088,2270],[1033,1471,1705,1904,2095,2277],[1036,1476,1710,1910,2102,2284],[1039,1480,1716,1917,2108,2292],[1042,1485,1721,1923,2115,2299],[1046,1490,1727,1929,2122,2306],[1049,1494,1732,1935,2128,2313],[1052,1499,1738,1941,2135,2321],[1055,1504,1743,1947,2142,2328],[1059,1508,1748,1953,2148,2335],[1062,1513,1754,1959,2155,2342],[1065,1518,1759,1965,2162,2350],[1069,1522,1765,1971,2168,2357],[1072,1527,1770,1977,2175,2364],[1075,1532,1776,1983,2182,2371],[1078,1536,1781,1989,2188,2379],[1082,1541,1786,1995,2195,2386],[1085,1546,1792,2002,2202,2393],[1088,1550,1797,2008,2208,2400],[1091,1555,1803,2014,2215,2408],[1095,1560,1808,2020,2222,2415],[1098,1564,1814,2026,2228,2422],[1101,1569,1819,2032,2235,2429],[1104,1574,1824,2038,2242,2437],[1108,1578,1830,2044,2248,2444],[1111,1583,1835,2050,2255,2451],[1114,1588,1841,2056,2262,2458],[1117,1592,1846,2062,2268,2465],[1120,1596,1850,2067,2273,2471],[1123,1600,1854,2071,2279,2477],[1126,1603,1859,2076,2284,2483],[1128,1607,1863,2081,2289,2488],[1131,1611,1868,2086,2295,2494],[1134,1615,1872,2091,2300,2500],[1137,1619,1876,2096,2305,2506],[1140,1623,1881,2101,2311,2512],[1142,1627,1885,2106,2316,2518],[1145,1630,1889,2110,2321,2523],[1148,1634,1894,2115,2327,2529],[1151,1638,1898,2120,2332,2535],[1153,1642,1902,2125,2337,2541],[1156,1646,1907,2130,2343,2547],[1159,1650,1911,2135,2348,2552],[1162,1653,1915,2140,2354,2558],[1164,1657,1920,2144,2359,2564],[1167,1661,1924,2149,2364,2570],[1170,1665,1929,2154,2370,2576],[1173,1669,1933,2159,2375,2582],[1176,1673,1937,2164,2380,2587],[1178,1677,1942,2169,2386,2593],[1181,1680,1946,2174,2391,2599],[1184,1684,1950,2178,2396,2605],[1187,1688,1955,2183,2402,2611],[1189,1692,1959,2188,2407,2616],[1192,1696,1963,2193,2412,2622],[1195,1700,1968,2198,2418,2628],[1198,1704,1972,2203,2423,2634],[1200,1707,1976,2208,2428,2640],[1203,1711,1981,2213,2434,2646],[1206,1715,1985,2217,2439,2651],[1209,1719,1990,2222,2445,2657],[1212,1723,1994,2227,2450,2663],[1214,1727,1998,2232,2455,2669],[1217,1730,2003,2237,2461,2675],[1220,1734,2007,2242,2466,2680],[1223,1738,2011,2247,2471,2686],[1225,1742,2016,2251,2477,2692],[1228,1746,2020,2256,2482,2698],[1231,1750,2024,2261,2487,2704],[1234,1754,2029,2266,2493,2710],[1236,1757,2033,2271,2498,2715],[1239,1761,2037,2276,2503,2721],[1242,1765,2042,2281,2509,2727],[1245,1769,2046,2286,2514,2733],[1248,1773,2050,2290,2519,2739],[1250,1777,2055,2295,2525,2744],[1253,1781,2059,2300,2530,2750],[1256,1784,2064,2305,2536,2756],[1259,1788,2068,2310,2541,2762],[1261,1792,2072,2315,2546,2768],[1264,1796,2077,2320,2552,2774],[1267,1800,2081,2324,2557,2779],[1270,1804,2085,2329,2562,2785],[1272,1807,2090,2334,2568,2791],[1275,1811,2094,2339,2573,2797],[1278,1815,2098,2344,2578,2803],[1281,1819,2103,2349,2584,2808],[1284,1823,2107,2354,2589,2814],[1286,1827,2111,2359,2594,2820],[1289,1830,2115,2363,2599,2825],[1290,1831,2116,2364,2600,2827],[1291,1833,2118,2365,2602,2828],[1292,1834,2119,2367,2603,2830],[1293,1835,2120,2368,2605,2831],[1294,1836,2121,2369,2606,2833],[1295,1838,2122,2370,2607,2834],[1296,1839,2123,2371,2609,2835],[1297,1840,2124,2373,2610,2837],[1298,1841,2125,2374,2611,2838],[1299,1842,2126,2375,2612,2840],[1300,1843,2127,2376,2614,2841],[1301,1845,2128,2377,2615,2842],[1302,1846,2129,2378,2616,2844],[1303,1847,2130,2379,2617,2845],[1304,1848,2131,2381,2619,2846],[1305,1849,2132,2382,2620,2848],[1306,1850,2133,2383,2621,2849],[1307,1851,2134,2384,2622,2850],[1308,1853,2135,2385,2624,2852],[1309,1854,2136,2386,2625,2853],[1310,1855,2137,2387,2626,2855],[1311,1856,2138,2388,2627,2856],[1312,1857,2139,2390,2629,2857],[1313,1858,2140,2391,2630,2859],[1314,1859,2141,2392,2631,2860],[1315,1861,2142,2393,2632,2861],[1316,1862,2143,2394,2634,2863],[1317,1863,2144,2395,2635,2864],[1318,1864,2145,2396,2636,2865],[1319,1865,2146,2398,2637,2867],[1320,1866,2147,2399,2639,2868],[1321,1867,2148,2400,2640,2869],[1322,1869,2149,2401,2641,2871],[1323,1870,2150,2402,2642,2872],[1324,1871,2151,2403,2644,2873],[1325,1872,2152,2404,2645,2875],[1326,1873,2153,2405,2646,2876],[1327,1874,2155,2407,2647,2878],[1328,1875,2156,2408,2648,2879],[1329,1877,2157,2409,2650,2880],[1330,1878,2158,2410,2651,2882],[1331,1879,2159,2411,2652,2883],[1332,1880,2160,2412,2653,2884],[1333,1881,2161,2413,2655,2886],[1334,1882,2162,2415,2656,2887],[1335,1883,2163,2416,2657,2888],[1336,1885,2164,2417,2658,2890],[1337,1886,2165,2418,2660,2891],[1338,1887,2166,2419,2661,2892],[1339,1888,2167,2420,2662,2894],[1340,1889,2168,2421,2663,2895],[1341,1890,2169,2422,2665,2897],[1342,1891,2170,2424,2666,2898],[1343,1893,2171,2425,2667,2899],[1344,1894,2172,2426,2668,2901],[1345,1895,2173,2427,2670,2902],[1346,1896,2174,2428,2671,2903],[1347,1897,2175,2429,2672,2905],[1348,1898,2176,2430,2673,2906],[1349,1899,2177,2432,2675,2907],[1350,1901,2178,2433,2676,2909],[1351,1902,2179,2434,2677,2910],[1352,1903,2180,2435,2678,2911],[1353,1904,2181,2436,2680,2913],[1354,1905,2182,2437,2681,2914],[1355,1906,2183,2438,2682,2916],[1357,1910,2187,2442,2687,2920],[1360,1914,2191,2448,2692,2927],[1363,1918,2196,2453,2698,2933],[1366,1921,2200,2458,2704,2939],[1368,1925,2205,2463,2709,2945],[1371,1929,2210,2468,2715,2951],[1374,1933,2214,2473,2721,2957],[1377,1937,2219,2479,2726,2964],[1380,1941,2224,2484,2732,2970],[1382,1945,2228,2489,2738,2976],[1385,1949,2233,2494,2743,2982],[1388,1953,2237,2499,2749,2988],[1391,1957,2242,2504,2755,2994],[1394,1961,2247,2509,2760,3000],[1396,1965,2251,2515,2766,3007],[1399,1969,2256,2520,2772,3013],[1402,1973,2260,2525,2777,3019],[1405,1977,2265,2530,2783,3025],[1408,1981,2270,2535,2789,3031],[1410,1985,2274,2540,2794,3037],[1413,1989,2279,2545,2800,3044],[1416,1993,2283,2551,2806,3050],[1419,1997,2288,2556,2811,3056],[1422,2001,2293,2561,2817,3062],[1424,2005,2297,2566,2823,3068],[1427,2009,2302,2571,2828,3074],[1430,2013,2306,2576,2834,3080],[1433,2017,2311,2581,2840,3087],[1436,2021,2316,2587,2845,3093],[1438,2025,2320,2592,2851,3099],[1441,2029,2325,2597,2857,3105],[1444,2033,2329,2602,2862,3111],[1447,2037,2334,2607,2868,3117],[1450,2041,2339,2612,2874,3124],[1453,2045,2343,2617,2879,3130],[1455,2049,2348,2623,2885,3136],[1458,2053,2352,2628,2891,3142],[1461,2057,2357,2633,2896,3148],[1464,2061,2362,2638,2902,3154],[1467,2065,2366,2643,2907,3160],[1469,2069,2371,2648,2913,3167],[1472,2073,2376,2653,2919,3173],[1475,2077,2380,2659,2924,3179],[1478,2081,2385,2664,2930,3185],[1481,2085,2389,2669,2936,3191],[1483,2089,2394,2674,2941,3197],[1486,2093,2399,2679,2947,3203],[1489,2097,2403,2684,2953,3210],[1492,2101,2408,2689,2958,3216],[1495,2105,2412,2695,2964,3222],[1497,2108,2417,2700,2970,3228],[1500,2112,2422,2705,2975,3234],[1503,2116,2426,2710,2981,3240],[1506,2120,2431,2715,2987,3247],[1509,2124,2435,2720,2992,3253],[1511,2128,2440,2725,2998,3259],[1514,2132,2445,2731,3004,3265],[1517,2136,2449,2736,3009,3271],[1520,2140,2454,2741,3015,3277]];
	function lookupChildSupportTable(income, children){
		income = Math.round((income-800)/50);
		income = Math.max(0, income);
		income = Math.min(384, income);
		children -= 1;
		children = Math.max(0, children);
		children = Math.min(5, children);
		return childSupportChart[income][children];
	}

	var inputs = document.getElementsByClassName("calc-num-input");
	for (var i = 0; i < inputs.length; i++){
		inputs[i].onkeypress = function(e){
			resetObligation();
			if (/[0-9]/.test(e.key)){
				return true;
			}
			if (/\./.test(e.key) && this.value.indexOf(".") == -1){
				return true;
			}
			return false;
		};
		inputs[i].onfocus = function(e){
			if (this.value == "0"){
				this.select();
			}
		};
		inputs[i].onblur = function(){
			this.value = this.value.replace(/[^0-9\.]/g, "");
			this.value = this.value.replace(/\./, ",");
			this.value = this.value.replace(/\./g, "");
			this.value = this.value.replace(",", ".");
			if (this.value.length == 0 || this.value == "."){
				this.value = "0";
			}
		};
	}

	document.getElementById("calc-minorChildren").addEventListener("change", function(e){
		resetObligation();
		if (this.selectedIndex > 0){
			document.getElementById("calc-errorMessage").innerText = "";
		}
	});

	function resetObligation(){
		document.getElementById("calc-presumedMonthlyObligation").getElementsByClassName("calc-non-custodial")[0].value = "0";
	}

	document.getElementById("calc-calculate").addEventListener("click", function(){
		var variables = {
			monthlyGrossIncome: document.getElementById("calc-monthlyGrossIncome"),
			deductionForAlimony: document.getElementById("calc-deductionForAlimony"),
			deductionForOther: document.getElementById("calc-deductionForOther"),
			monthlyChildCare: document.getElementById("calc-monthlyChildCare"),
			monthlyHealthInsurance: document.getElementById("calc-monthlyHealthInsurance"),
		};
		var parents = {
			custodial: {},
			nonCustodial: {},
			children: document.getElementById("calc-minorChildren").selectedIndex,
		};
		if (parents.children == 0){
			document.getElementById("calc-errorMessage").innerText = "Please select the number of minor children at the top.\n";
			return;
		}
		var variableKeys = Object.keys(variables);
		for (var i = 0; i < variableKeys.length; i++){
			parents.custodial[variableKeys[i]] = parseFloat(variables[variableKeys[i]].getElementsByClassName("calc-custodial")[0].value);
			parents.nonCustodial[variableKeys[i]] = parseFloat(variables[variableKeys[i]].getElementsByClassName("calc-non-custodial")[0].value);
		}
		calculateObligations(parents.custodial, parents.nonCustodial, parents.children);
		document.getElementById("calc-presumedMonthlyObligation").getElementsByClassName("calc-non-custodial")[0].value = parents.nonCustodial.presumedObligation;
	});

	function calculateObligations(pA, pB, children){
		pA.adjustedMonthlyIncome = pA.monthlyGrossIncome-pA.deductionForAlimony-pA.deductionForOther;
		pB.adjustedMonthlyIncome = pB.monthlyGrossIncome-pB.deductionForAlimony-pB.deductionForOther;
		var combinedIncome = pA.adjustedMonthlyIncome+pB.adjustedMonthlyIncome;
		combinedIncome = Math.max(1, combinedIncome);
		pA.percentageIncome = pA.adjustedMonthlyIncome/combinedIncome;
		pB.percentageIncome = pB.adjustedMonthlyIncome/combinedIncome;
		var totalObligation = lookupChildSupportTable(combinedIncome, children);
		totalObligation += pA.monthlyChildCare+pB.monthlyChildCare;
		totalObligation += pA.monthlyHealthInsurance+pB.monthlyHealthInsurance;
		pA.obligation = pA.percentageIncome*totalObligation;
		pB.obligation = pB.percentageIncome*totalObligation;
		pA.presumedObligation = moneyRound(pA.obligation-pA.monthlyChildCare-pA.monthlyHealthInsurance);
		pB.presumedObligation = moneyRound(pB.obligation-pB.monthlyChildCare-pB.monthlyHealthInsurance);
	}

	function moneyRound(num){
		return Math.round(num*100)/100;
	}
})();
</script>