<!-- Begin JS

function checkSalary(form){
if ((form.salary.value == "") || isNaN(form.salary.value))
	alert('Please enter an adjusted gross income.');
else
	return true;
return false;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function calculatePhaseout(form) {
pageTracker._trackPageview("/goal/click/calc/rothIRAPhaseoutCalc");

form.salary.value = form.salary.value.replace("$","");
form.salary.value = form.salary.value.replace(",","");

if (checkSalary(form)){
	form.limit.value = "calculating...";
	poSingleTop = 120000;
	poSingleBtm = 105000;
	poMJtop = 177000;
	poMJbtm = 167000;
	poMStop = 10000;
	poMSbtm = 0;
	salary = form.salary.value * 1;
	limit = 5000;

	poTop = poSingleTop;
	poBtm = poSingleBtm;
	
	if (form.agedfifty.checked)
		limit += 1000;

	stat = getCheckedValue(form.status);
	//alert(salary);

	if (salary < limit){ //if salary is under limit, use salary
	        calclimit = salary;
	} else {
		// change the top and bottom values based on filing type
	        if (stat  == "MFJ") {
			poTop = poMJtop;
			poBtm = poMJbtm;
		}else if (stat == "MFS") {
	                poTop = poMStop;
	                poBtm = poMSbtm;
		}
		poRng = poTop - poBtm; // stores range of phaseout
	
		if (salary < poBtm){ // under phaseout range limits
		        calclimit = limit;
		}else if (salary > poTop){ // over phaseout range limits
			calclimit = 0;
		}else{
			salary = salary - poBtm;
			perc = 1-(salary / poRng);
			calclimit = limit * perc;
	
			if (limit < 200){
				calclimit = 200;
			}else {
				round = Math.floor((calclimit / 10))*10;
				if ((calclimit - round) > 0){
					calclimit = (Math.floor((calclimit / 10))+1)*10;
				}
			}
		}
	}
	form.limit.value = calclimit;

}
}
// End JS-->

