function verifyincome(checkstring) {
//alert(checkstring);
	if (isnotint(checkstring)) {
		alert("Invalid number.");
		document.formX.income.value="$75,000";
	}
	//document.formX.income.value=formatnumber(unformat(document.formX.income.value),1);
	recalculate();
}
function setIncome(e){
	var amount;
	
	switch(e.id){
		case "incomeYear":
		amount = (e.value);
		break;
		case "incomeMonth":
		amount = (e.value * 12);
		break;
		case "incomeWeek":
		amount = (e.value * 52);
		break;
		case "incomeHour":
		amount = (e.value * 37.5) *52;
		break;
	
	}
	if(e.id != "incomeYear")
	$("incomeYear").value = amount;
	if(e.id != "incomeMonth")
	$("incomeMonth").value = amount / 12;
	if(e.id != "incomeWeek")
	$("incomeWeek").value = amount / 52;
	if(e.id != "incomeHour")
	$("incomeHour").value = (amount / 52) / 37.5;
	
	//document.formX.income.value = amount;
	//verifyincome(amount);
	recalculate(amount);
	$("results").style.display= "";
}
function recalculate(pretax) {
	//var pretax = unformat(document.formX.income.value);
	var bc_tax = taxfromcharts('current', 0,pretax);

//	var bc_taxpay = formatnumber(bc_tax,1);
	var bc_aftertax = pretax-bc_tax;
	
	var aftertax = {year: bc_aftertax, month: (bc_aftertax / 12), week: (bc_aftertax / 52), day : (bc_aftertax / 365)};
	aftertax.hour = (aftertax.week / 37.5);
//	$("txResult").innerHTML = "Y: "+aftertax.year+"\n M: "+aftertax.month+"\n W:"+aftertax.week+"\n h:"+aftertax.hour;
	
	$("resultYear").innerHTML = formatnumber(aftertax.year);
	$("resultMonth").innerHTML = formatnumber(aftertax.month);
	$("resultWeek").innerHTML = formatnumber(aftertax.week);
	$("resultHour").innerHTML = formatnumber(aftertax.hour);
	
}

function dopopup(windowText) {
	var imgWindow;
	var DispString;
	imgWindow = open("","","width=420,height=250,scrollbars=yes");
	imgWindow.document.open();
	imgWindow.document.write("<html>");
	imgWindow.document.write("<head>");
	imgWindow.document.write("<link rel=STYLESHEET href='cica.css' type='text/css'>");
	imgWindow.document.write("</head>");
	imgWindow.document.write("<body bgcolor='white'>");
	imgWindow.document.write(windowText + "<p>");
	imgWindow.document.write("<form>");
	imgWindow.document.write("<center>");
	imgWindow.document.write("<input type='button' value='Close' onClick='self.close()'>");
	imgWindow.document.write("</center>");
	imgWindow.document.write("</form>");
	imgWindow.document.write("</body>");
	imgWindow.document.write("</html>");
	imgWindow.focus();
}
