var jhcs_StateTax_msgConfirm = "Please note that this calculation is an estimate based upon input you provided. Certain assumptions have been made to determine this calculation. This calculation uses 2006 tax tables unless otherwise noted.  I have read and understand the assumptions used to make these calculations in the 'Terms and Conditions'.  Calculate Results Now.";



function jhcs_ValidatorOnSubmit() {
	if ( typeof(getAspForm) != "function" ) { alert( 'no aspform' ); return false; }
	if (!theForm) { getAspForm(); }
	
	if ( !theForm ) { alert( 'no form' ); return false; }
	
	var tab = 0;
	if (theForm.csf_currentTab) { tab = theForm.csf_currentTab.value }
	switch (tab) {
		case "1":   return validateTab1( theForm ); break;
		case "2":   return true; break;
		default:  return false;
	}
}

function validateTab1( frm ) {
	if (frm.csf_income.value == "")
	{
		alert("Please enter your Annual Taxable Income.");
		frm.csf_income.value="";
		frm.csf_income.focus();
		return false;
	}
	else if (isNaN(frm.csf_income.value) || parseInt(frm.csf_income.value) <= 0)
	{
		alert("The value of your Annual Taxable Income must be a positive number. Please do not use commas.");
		frm.csf_income.value="";
		frm.csf_income.focus();
		return false;
	}
	else if (frm.csf_contribution.value == "")
	{
		alert("Please enter your Contribution Amount.");
		frm.csf_contribution.value="";
		frm.csf_contribution.focus();
		return false;
	}
	else if (isNaN(frm.csf_contribution.value) || parseInt(frm.csf_contribution.value) <= 0)
	{
		alert("The value of your Contribution Amount must be a positive number. Please do not use commas.");
		frm.csf_contribution.value="";
		frm.csf_contribution.focus();
		return false;
	}
	else if (parseInt(frm.csf_contribution.value) > parseInt(frm.csf_income.value))
	{
		alert("The Contribution Amount cannot be greater than the Annual Taxable Income.");
		frm.csf_contribution.focus();
		return false;
	} 
	else {
		var st = getCheckedValue( frm.csf_status );
		if ( "0" != st && "1" != st ) {
			alert("Please select a filling status.");
			return false;
		}
	
	   confirm_box = confirm(jhcs_StateTax_msgConfirm);
	   if (confirm_box == true) {
	     return true;
	   } else {
	     return false;
	   }
	   return true;
	}   
}


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 "";
}