function displayEXIT(){
 alert("You are now leaving the U.S. House of Representatives Web site. \n Neither the House office whose site contains the above link \n nor the U.S. House of Representatives is responsible for the\n content of the non-House site you are about to access.")
}

function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}

<!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


	function calc() {
		if (!birthYearInRange()) return setNull();
		var income = getFormValue('01i_income');
		if (income < 1) return setNull();

		var var_01r_current_benefit = calculateBenefit();
		setFormValue('01r_current_benefit', var_01r_current_benefit);
		var var_02r_priv_ss = calculateBushTraditionalBenefit();
		setFormValue('02r_priv_ss', var_02r_priv_ss);
		var var_03r_priv_pa = calculateBushIndividualAccount();
		setFormValue('03r_priv_pa', var_03r_priv_pa);
		var var_04r_priv_total = var_02r_priv_ss + var_03r_priv_pa;
		setFormValue('04r_priv_total', var_04r_priv_total);

		var var_05r_current_benefit = var_01r_current_benefit;
		setFormValue('05r_current_benefit', var_05r_current_benefit);
		var var_06r_priv_total = var_04r_priv_total;
		setFormValue('06r_priv_total', var_06r_priv_total);
		var var_07r_total = var_01r_current_benefit - var_04r_priv_total;
		setFormValue('07r_total', var_07r_total);
		var var_08r_percent = var_07r_total / var_05r_current_benefit;
		setFormValuePercent('08r_percent', var_08r_percent);
		var var_09r_current_benefit = calculateBenefit();
		setFormValue('09r_current_benefit', var_09r_current_benefit);

	}
	
	function clearForm() {
		setFormValue('01i_income', '');
		setFormValue('02i_year_born', '');
		setNull();
	}

	function setNull() {
		setFormValue('01r_current_benefit', '');
		setFormValue('02r_priv_ss', '');
		setFormValue('03r_priv_pa', '');
		setFormValue('04r_priv_total', '');
		setFormValue('05r_current_benefit', '');
		setFormValue('06r_priv_total', '');
		setFormValue('07r_total', '');
		setFormValue('08r_percent', '');
		setFormValue('09r_current_benefit', '');
	}
	
	function calculateBenefit() {
		if (!birthYearInRange()) return 0;
		
		var year_born = getFormValue('02i_year_born');
		var pia = calculatePIA();
		var nra_adjust = calculateNRAAdjust();
//		alert('pia is '+pia+' nra_adjust='+nra_adjust+'');
		
		return Math.round(Math.pow(1.0123,(year_born+62-2005)) * pia * nra_adjust);
	}
	
	function calculatePIA() {
		var income90 = getIncome90();
		var a = 0.9 * Math.max(Math.min(income90,7488),0);
		var b = 0.32 * Math.max(Math.min(income90-7488,37632),0);
		var c = 0.15 * Math.max(Math.min(income90-45120,44880),0);
		return (a + b + c);
	}
	
	function calculateNRAAdjust() {
		var year_born = getFormValue('02i_year_born');
		return (((93+(1/3))-Math.min(Math.max((year_born-1954),0),6)*(10/9))/100);
	}
	
	function getIncome90() {
		var income = getFormValue('01i_income');
		if (income < 0) income = 0;
		return Math.min(income, 90000);
	}
	
	function birthYearInRange() {
		var year = getFormValue('02i_year_born');
		return (year >= 1950 && year <= 2005);
	}

	function calculateBushTraditionalBenefit() {
		if (!birthYearInRange()) return 0;
		
		var scheduled_benefit = calculateBenefit();
		var prog_cut = calculateProgCut();
		var account_offset = calculateAccountOffset();
		
		return Math.round(scheduled_benefit*Math.max(0,1+prog_cut+account_offset),0)
	}
	
	function calculatePriceCut() {
		var year_born = getFormValue('02i_year_born');
		return (1/(Math.pow(1.0123,(year_born-1949))))-1;
	}
	
	function calculateAccountOffset() {
		var income90 = getIncome90();
		var year_born = getFormValue('02i_year_born');
		
		var lookup_row = fetchLookupRow(year_born - 1950);
		var acc_off_low_0 = lookup_row[0];
		var acc_off_low_1 = acc_off_low_0;
		var acc_off_med_0 = lookup_row[1];
		var acc_off_med_1 = (((36000-income90)/20000)*acc_off_low_0) + (((income90-16000)/20000)*acc_off_med_0);
		var acc_off_hi_0 = lookup_row[2];
		var acc_off_hi_1 = (((58000-income90)/22000)*acc_off_med_0) + (((income90-36000)/22000)*acc_off_hi_0);
		var acc_off_max_0 = lookup_row[3];
		var acc_off_max_1 = (((90000-income90)/32000)*acc_off_hi_0) + (((income90-58000)/32000)*acc_off_max_0);
		
		if (income90<16000) {
			return acc_off_low_0;
		} else if (income90<36000) {
			return acc_off_med_1;
		} else if (income90<58000) {
			return acc_off_hi_1;
		} else {
			return acc_off_max_1;
		}
		
	}

	function calculateBushIndividualAccount() {
		if (!birthYearInRange()) return 0;

		var scheduled_benefit = calculateBenefit();
		var account_offset = calculateAccountOffset();

		return Math.round(-scheduled_benefit * account_offset);
	}

	
	function fetchLookupRow(offset) {
		return lookup_data[offset];
	}

	lookup_data = new Array(
[-0.029233431,-0.034841181,-0.028286705,-0.023371234,1],
[-0.035210586,-0.041555354,-0.034461176,-0.028406998,1],
[-0.041585086,-0.048484216,-0.041120262,-0.033837853,1],
[-0.048302163,-0.056008603,-0.048295077,-0.0396915,1],
[-0.055473101,-0.063803405,-0.055939334,-0.046062177,1],
[-0.063847036,-0.073063941,-0.064689618,-0.053521336,1],
[-0.07240408,-0.082533172,-0.073646122,-0.061380234,1],
[-0.081680717,-0.092910784,-0.083484775,-0.070026961,1],
[-0.091319396,-0.10378808,-0.093540326,-0.079180287,1],
[-0.10133469,-0.115071656,-0.104261122,-0.0889462,1],
[-0.111500306,-0.126815562,-0.115179957,-0.099138794,1],
[-0.120842287,-0.13778726,-0.125591334,-0.108874827,1],
[-0.130197286,-0.148871727,-0.136135129,-0.118936016,1],
[-0.139485677,-0.160256658,-0.146963374,-0.129325683,1],
[-0.148779795,-0.171951384,-0.158148711,-0.140192921,1],
[-0.158528425,-0.184145287,-0.169928521,-0.151676556,1],
[-0.158422441,-0.189617026,-0.176873201,-0.159361062,1],
[-0.168136207,-0.202391573,-0.189387532,-0.171854828,1],
[-0.177944181,-0.215510609,-0.202271893,-0.184783184,1],
[-0.187364283,-0.228438168,-0.2151642,-0.197872133,1],
[-0.197153452,-0.241916608,-0.22873978,-0.211718018,1],
[-0.206695429,-0.2552475,-0.242522354,-0.225808283,1],
[-0.216559107,-0.269173544,-0.257011938,-0.240790148,1],
[-0.226304033,-0.282993723,-0.271743224,-0.256240279,1],
[-0.235747403,-0.296639488,-0.286454207,-0.27178611,1],
[-0.245402382,-0.310681001,-0.301971106,-0.287978897,1],
[-0.254719817,-0.324393654,-0.317338951,-0.303949915,1],
[-0.264038014,-0.338282473,-0.33329918,-0.320340428,1],
[-0.273779857,-0.35268861,-0.350132948,-0.337454338,1],
[-0.273158794,-0.357282549,-0.359814227,-0.348576113,1],
[-0.282711867,-0.371600675,-0.377143186,-0.366006126,1],
[-0.291442395,-0.384900066,-0.393987216,-0.383084724,1],
[-0.300391883,-0.398681594,-0.411649958,-0.400985827,1],
[-0.308873662,-0.411950853,-0.429261853,-0.418678909,1],
[-0.316530003,-0.424430081,-0.446608309,-0.436053946,1],
[-0.32439936,-0.437130801,-0.465076607,-0.454520334,1],
[-0.331188395,-0.446677232,-0.483041526,-0.472676053,1],
[-0.337545532,-0.455276574,-0.501422234,-0.491403548,1],
[-0.342834817,-0.462487987,-0.51981524,-0.510308748,0.776484284],
[-0.346739254,-0.467679942,-0.536886519,-0.528827374,0.773333333],
[-0.350710421,-0.473076568,-0.553062285,-0.541486103,0.771676301],
[-0.34956819,-0.471537874,-0.55936095,-0.552481863,0.77034045],
[-0.348917363,-0.470642118,-0.564441525,-0.563777757,0.76945245],
[-0.348340591,-0.46981843,-0.566871109,-0.574692395,0.766055046],
[-0.347744927,-0.469038442,-0.566028791,-0.585104533,0.757936508],
[-0.34731773,-0.468507873,-0.565399091,-0.595396975,0.759659091],
[-0.346324802,-0.467113532,-0.563745001,-0.604047067,0.754227734],
[-0.345791102,-0.466433818,-0.562889517,-0.613109835,0.752670039],
[-0.345001294,-0.465323135,-0.561538566,-0.621064564,0.745272525],
[-0.344352455,-0.464448276,-0.560478154,-0.628838099,0.749720045],
[-0.343649698,-0.463545767,-0.559431559,-0.636047202,0.744444444],
[-0.342658297,-0.462160507,-0.557721603,-0.642035708,0.744858255],
[-0.342014585,-0.46131469,-0.556728923,-0.648322518,0.745828699],
[-0.341984805,-0.461272475,-0.556660852,-0.655156999,0.742114001],
[-0.341400634,-0.460469741,-0.555696997,-0.660492531,0.740618102],
[-0.341122638,-0.460134385,-0.555281051,-0.665946551,0.738986784],
[-0.340898893,-0.459829336,-0.554906851,-0.670890432,0.733879781],
[-0.34065544,-0.459490562,-0.554528659,-0.675318048,0.733478973],
[-0.340444517,-0.459224607,-0.554158446,-0.679280213,0.735084839],
[-0.339861473,-0.458392547,-0.553188839,-0.681899793,0.730038023],
[-0.33914492,-0.457493458,-0.552091172,-0.683813786,0.731627654],
[-0.338696879,-0.456843423,-0.551334473,-0.685542278,0.726879394],
[-0.338246846,-0.456246422,-0.550580727,-0.686745327,0.727666486],
[-0.337936085,-0.45583606,-0.550092282,-0.68770252,0.72311828],
[-0.337305812,-0.454940278,-0.549041761,-0.68741877,0.724286484],
[-0.336845932,-0.454364832,-0.548323736,-0.686930871,0.725849973]
);


function calculateProgCut() {
	var price_cut = calculatePriceCut();
	var rounded_salary = getRoundedSalary();
	var prog_factor = lookupProgFactor(rounded_salary);
	
	return price_cut * prog_factor;
}

function getRoundedSalary() {
	var income90 = getIncome90();
	return roundToThousands(income90);
}

function roundToThousands(num) {
	return (Math.round(num / 1000)) * 1000;
}

function lookupProgFactor(rounded_salary) {
	var offset = Math.floor(rounded_salary / 1000);
	return prog_factor_data[offset][1];
}


var prog_factor_data = new Array(
[0,0],[1000,0],[2000,0],[3000,0],[4000,0],[5000,0],[6000,0],[7000,0],[8000,0],[9000,0],
[10000,0],[11000,0],[12000,0],[13000,0],[14000,0],[15000,0],[16000,0],[17000,0],[18000,0],
[19000,0],[20000,0],[21000,0.034221863],[22000,0.079651322],[23000,0.122706533],
[24000,0.163568882],[25000,0.202401736],[26000,0.239352629],[27000,0.274555133],
[28000,0.308130471],[29000,0.340188914],[30000,0.370830989],[31000,0.40014853],
[32000,0.428225604],[33000,0.455139306],[34000,0.480960477],[35000,0.505754318],
[36000,0.529580944],[37000,0.552495868],[38000,0.574550437],[39000,0.595792211],
[40000,0.61626531],[41000,0.636010715],[42000,0.655066548],[43000,0.673468311],
[44000,0.691249111],[45000,0.708439858],[46000,0.725069444],[47000,0.741164905],
[48000,0.756751568],[49000,0.771853182],[50000,0.786492043],[51000,0.798992329],
[52000,0.805524512],[53000,0.81196541],[54000,0.818316921],[55000,0.824580894],
[56000,0.830759127],[57000,0.836853368],[58000,0.842865317],[59000,0.848796631],
[60000,0.854648921],[61000,0.860423757],[62000,0.866122664],[63000,0.871747132],
[64000,0.877298609],[65000,0.882778507],[66000,0.888188201],[67000,0.893529032],
[68000,0.898802306],[69000,0.904009298],[70000,0.909151249],[71000,0.91422937],
[72000,0.919244842],[73000,0.924198818],[74000,0.929092422],[75000,0.93392675],
[76000,0.938702874],[77000,0.943421838],[78000,0.948084662],[79000,0.952692341],
[80000,0.95724585],[81000,0.961746136],[82000,0.966194128],[83000,0.970590733],
[84000,0.974936835],[85000,0.979233299],[86000,0.983480972],[87000,0.98768068],
[88000,0.99183323],[89000,0.995939413],[90000,1]
);


	////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////

	function setFormValue(dest_field, new_value) {
		var form = document.forms['ssform'];
		var field_obj = form[dest_field];
		if (typeof field_obj != 'undefined') {
			field_obj.value = addCommas(new_value);
		}
	}
	function setFormValuePercent(dest_field, new_value) {
		var form = document.forms['ssform'];
		var field_obj = form[dest_field];
		if (typeof field_obj != 'undefined') {
			field_obj.value = (Math.round(new_value * 100));
		}
	}
	
	function addCommas(number) {
		number = '' + number;
		if (number.length > 3) {
			var mod = number.length % 3;
			var output = (mod > 0 ? (number.substring(0,mod)) : '');
			for (i=0 ; i < Math.floor(number.length / 3); i++) {
				if ((mod == 0) && (i == 0)) {
					output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
				} else {
					output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
				}
			}
			return (output);
		}

		return number;
	}
	
	function getFormValue(field_name) {
		var value;
		var form = document.forms['ssform'];
		
		var raw_value = '';
		if (typeof form[field_name] != 'undefined') {
			raw_value = form[field_name].value;
		} else {
			raw_value = 0;
		}

		value = raw_value.replace(/([^0-9.]+)/g,"");
		if (/[0-9.]+/.test(value)) {
			return parseFloat(value);
		}
		return 0;
	}