	var healthcare =	{"inp":{"empexists":true,"req":false,"fte":0,"t_emp":0,"pte":0,"ft_wage":0,"pt_wage":0,"pt_hrs":0,"prem_s":0,"indins":0,"prem_f":0,"fam_ins":0,"prem_per":0,"state":"-"},"res":{}};


	var state_cap = {"AK":{"L":"Alaska","S":6204,"F":13723},"AL":{"L":"Alabama","S":4441,"F":11275},"AR":{"L":"Arkansas","S":4329,"F":9677},"AZ":{"L":"Arizona","S":4495,"F":10239},"CA":{"L":"California","S":4628,"F":10957},"CO":{"L":"Colorado","S":4972,"F":11437},"CT":{"L":"Connecticut","S":5419,"F":13484},"DC":{"L":"District of Columbia","S":5355,"F":12823},"DE":{"L":"Delaware","S":5602,"F":12513},"FL":{"L":"Florida","S":5161,"F":12453},"GA":{"L":"Georgia","S":4612,"F":10598},"HI":{"L":"Hawaii","S":4228,"F":10508},"IA":{"L":"Iowa","S":4652,"F":10503},"ID":{"L":"Idaho","S":4215,"F":9365},"IL":{"L":"Illinois","S":5198,"F":12309},"IN":{"L":"Indiana","S":4775,"F":11222},"KS":{"L":"Kansas","S":4603,"F":11462},"KY":{"L":"Kentucky","S":4287,"F":10434},"LA":{"L":"Louisiana","S":4829,"F":11074},"MA":{"L":"Massachusetts","S":5700,"F":14138},"MD":{"L":"Maryland","S":4837,"F":11939},"ME":{"L":"Maine","S":5215,"F":11887},"MI":{"L":"Michigan","S":5098,"F":12364},"MN":{"L":"Minnesota","S":4704,"F":11938},"MO":{"L":"Missouri","S":4663,"F":10681},"MS":{"L":"Mississippi","S":4533,"F":10501},"MT":{"L":"Montana","S":4772,"F":10212},"NC":{"L":"North Carolina","S":4920,"F":11583},"ND":{"L":"North Dakota","S":4469,"F":10506},"NE":{"L":"Nebraska","S":4715,"F":11169},"NH":{"L":"New Hampshire","S":5519,"F":13624},"NJ":{"L":"New Jersey","S":5607,"F":13521},"NM":{"L":"New Mexico","S":4754,"F":11404},"NV":{"L":"Nevada","S":4553,"F":10297},"NY":{"L":"New York","S":5442,"F":12867},"OH":{"L":"Ohio","S":4667,"F":11293},"OK":{"L":"Oklahoma","S":4838,"F":11002},"OR":{"L":"Oregon","S":4681,"F":10890},"PA":{"L":"Pennsylvania","S":5039,"F":12471},"RI":{"L":"Rhode Island","S":5887,"F":13786},"SC":{"L":"South Carolina","S":4899,"F":11780},"SD":{"L":"South Dakota","S":4497,"F":11483},"TN":{"L":"Tennessee","S":4611,"F":10369},"TX":{"L":"Texas","S":5140,"F":11972},"UT":{"L":"Utah","S":4238,"F":10935},"VA":{"L":"Virginia","S":4890,"F":11338},"VT":{"L":"Vermont","S":5244,"F":11748},"WA":{"L":"Washington","S":4543,"F":10725},"WI":{"L":"Wisconsin","S":5222,"F":12819},"WV":{"L":"West Virginia","S":4986,"F":11611},"WY":{"L":"Wyoming","S":5266,"F":12163}};

	var res_success="";
	var res_failure ="<b>Since you don't have employees, the new employer-provided health care provisions don't apply to you.</b><br/><br/><br/>If you hire employees later, this tool will help you calculate how the new provisions affect your business." ;
	var inputs_res ="";
	

	function process_calcfunctions(){

		//alert('inside process calcfunction')
		if(!healthcare.inp.empexists){
			document.getElementById('resultDivOne').innerHTML=res_failure;
			return;
		}

		var _x = Math.round(healthcare.inp.pt_hrs/2080)
		var _fte_equi = parseInt(healthcare.inp.fte) + _x
		healthcare.res.req= (_fte_equi > 49)?true:false;

		
		var tcost =0;//
		//check if state is defined / selected

		if (typeof (healthcare.inp.state) !='undefined' && (healthcare.inp.state !='-')){
				tcost= (healthcare.inp.indins * Math.min(healthcare.inp.prem_s,state_cap[''+healthcare.inp.state].S) ) + (healthcare.inp.fam_ins * Math.min (healthcare.inp.prem_f,state_cap[''+healthcare.inp.state].F) );

				if ( (healthcare.inp.prem_f>state_cap[''+healthcare.inp.state].F )||(healthcare.inp.prem_s>state_cap[''+healthcare.inp.state].S)){
									healthcare.res.is_state_cap="Yes";

				}else{
					healthcare.res.is_state_cap="No";

				}
			//alert('applying state cap ::\n individual ins:'+healthcare.inp.indins + '\nhealthcare.inp.prem_s:'+healthcare.inp.prem_s+'\nState cap:'+state_cap[''+healthcare.inp.state].S+'\nhealthcare.inp.fam_ins:'+healthcare.inp.fam_ins+'\nhealthcare.inp.prem_f:'+healthcare.inp.prem_f+'\nState cap:'+state_cap[''+healthcare.inp.state].F+'\ntcost:'+tcost);
		}
		else{
				healthcare.res.is_state_cap="No";

				tcost= (healthcare.inp.indins * healthcare.inp.prem_s ) + (healthcare.inp.fam_ins * healthcare.inp.prem_f );

		}

		var av_wg =(healthcare.inp.ft_wage + healthcare.inp.pt_wage)/_fte_equi;
		var s_cd = 10200;
		var f_cd =27500;
		var cd_ex_s = 0;
		var cd_ex_f = 0;
		var pen1 =0
		var pen2 =0
		var pen3 =0

		if (healthcare.inp.prem_s > s_cd){
		cd_ex_s= ((healthcare.inp.prem_s  - s_cd) * (healthcare.inp.indins)) * 0.4;
		}

		if (healthcare.inp.prem_f > f_cd){
		cd_ex_f= ((healthcare.inp.prem_f  - f_cd) * (healthcare.inp.fam_ins)) * 0.4;
		}

		var cd_pen =cd_ex_s+cd_ex_f;

		if ( _fte_equi >49){
			pen1 =healthcare.inp.fte *3000;
			pen2 = (healthcare.inp.fte -30)*2000
		}

//AND PremPer >= .5
		var qual =false;
		if (_fte_equi< 26 && av_wg < 50001 && (healthcare.inp.prem_per/100.0) >=0.5 ){
			qual=true;
		}


		//changed 4/5/2010
		var employer_cont=0;//<r3> If ((<Req> = "Yes" and <PremPer> >= .6), (<tcost> x <PremPer>), (<tCost> x .6)) 
		if (healthcare.res.req ){

			if((healthcare.inp.prem_per/100.0) >=0.6){
				employer_cont=tcost * healthcare.inp.prem_per/100.0;
				}
			else{
				employer_cont=tcost * 0.6;
			}
		}
		else{
			employer_cont=tcost * healthcare.inp.prem_per/100.0;
		}

		var employer_conti=tcost * healthcare.inp.prem_per/100.0; //<r3i>

		var tq_ins_prem=0; //<r4> If (<Qual> = "Yes", <tCost>, null)
		
		if (qual){
			tq_ins_prem=tcost;
		}



		var eCost = tq_ins_prem * healthcare.inp.prem_per/100.0;	
		var pCredi = eCost*0.35;
		var pCred = eCost*0.5;

		var phase1 =0;
		//If (FTEequiv > 10, (pCred x ((FTEequiv - 10)/15)), $0)	
		if (_fte_equi > 10){
			phase1 =pCred * ((_fte_equi - 10)/15);
		}

		var phase2 = 0;
		//If (AveWage > $25,000, (pCred x ((AveWage - $25,000)/$25,000)), $0) 
		if (av_wg > 25000){
			phase2 =pCred * ((av_wg - 25000)/25000);
		}
		var phase = phase1 + phase2

		var phase1i =0;
		//If (FTEequiv > 10, (pCred x ((FTEequiv - 10)/15)), $0)	
		if (_fte_equi > 10){
			phase1i =pCredi * ((_fte_equi - 10)/15);
		}

		var phase2i = 0;
		//If (AveWage > $25,000, (pCred x ((AveWage - $25,000)/$25,000)), $0) 
		if (av_wg > 25000){
			phase2i =pCredi * ((av_wg - 25000)/25000);
		}
		var phasei = phase1i + phase2i
		var tent_crd=0;//<r5> = if ((<Qual> = "Yes"), <pCred>, null)
		if (qual){
		tent_crd=pCred;
		}

		var tent_crdi=0;//<r5i> = if ((<Qual> = "Yes"), <pCredi>, null)
		if (qual){
		tent_crdi=pCredi;
		}


		var phase_crd=0;//<r6> = If (phase <= pCred, phase, <r5>)	
		if (phase<=pCred){
			phase_crd=phase;
		}
		else{
			phase_crd=tent_crd;
		}
		
		var phase_crdi=0;//<r6i> = If (phase <= pCred, phase, <r5i>)	
		if (phasei<=pCredi){
			phase_crdi=phasei;
		}
		else{
			phase_crdi=tent_crdi;
		}


			/*var _rs = 'tcost::'+tcost+'\n';
			_rs +='_fte_equi::'+_fte_equi+'\n';
			_rs +='av_wg::'+av_wg+'\n';
			_rs +='qual::'+qual+'\n';


			_rs +='tq_ins_prem::'+tq_ins_prem+'\n';
			_rs +='employer_cont::'+employer_cont+'\n';
			_rs +='eCost::'+eCost+'\n';
			_rs +='pCredi::'+pCredi+'\n';
			_rs +='phase_crdi::'+phase_crdi+'\n';
			_rs +='tent_crdi::'+tent_crdi+'\n';

			alert(_rs)*/

		var sm_bus_crd=0;//<r7> = if ((<Qual> = "Yes"),(<r5> - <r6>), $0))	
		if (qual){
			sm_bus_crd=tent_crd-phase_crd;
		}

		var sm_bus_crdi=0;//<r7i> = if ((<Qual> = "Yes"),(<r5i> - <r6i>), $0))	
		if (qual){
			sm_bus_crdi=tent_crdi-phase_crdi;
		}

		var cad_excise="No";//<r8> = If ((<CadPen> > 0), "Yes", "No")	
		if (cd_pen>0){
		cad_excise="Yes"
		}

		var net_cost=(employer_cont-sm_bus_crd)+cd_pen;//<r9> = (<r3> - <r7> + <CadPen>)					
		if (pen1 < pen2){
		pen3 =pen1;
		}
		else{
		pen3 =pen2;
		}

		var net_costi=(employer_conti-sm_bus_crdi);//<r9i> = (<r3i> - <r7i>)					
		
		

		healthcare.res.qual=(qual)?"Yes":"No";
		healthcare.res.cd_ex_s=Math.round(cd_ex_s);
		healthcare.res.cd_ex_f=Math.round(cd_ex_f);
		healthcare.res.cd_pen=Math.round(cd_pen);
		healthcare.res.pen1=Math.round(pen1);
		healthcare.res.pen2=Math.round(pen2);
		healthcare.res.pen3=Math.round(pen3);
		healthcare.res.employer_cont=Math.round(employer_cont);
		healthcare.res.tq_ins_prem=Math.round(tq_ins_prem);
		healthcare.res.tent_crd=Math.round(tent_crd);
		healthcare.res.phase_crd=Math.round(phase_crd);
		healthcare.res.sm_bus_crd=Math.round(sm_bus_crd);
		healthcare.res.cad_excise=cad_excise;
		healthcare.res.net_cost=Math.round(net_cost);
		healthcare.res.indins=healthcare.inp.indins
		healthcare.res.fam_ins=healthcare.inp.fam_ins

		healthcare.res.s_cd=s_cd
		healthcare.res.f_cd=f_cd
		healthcare.res.prem_per=healthcare.inp.prem_per

		healthcare.res.net_cost_i=Math.round(net_costi);
		healthcare.res.phase_crd_i=Math.round(phase_crdi);
		healthcare.res.tent_crd_i=Math.round(tent_crdi);
		healthcare.res.employer_cont_i=Math.round(employer_conti);
		healthcare.res.sm_bus_crd_i=Math.round(sm_bus_crdi);
		healthcare.res.ecost_i=Math.round(eCost);
		healthcare.res.ecost=Math.round(eCost);


		


		var res_inter="<table border=0 width=850 style='border: 1px solid #CCCCCC'>";
		res_inter+="<TR>";
		res_inter+="		<TD colspan=5 bgcolor='#DDDDDD' height=18><b>Your inputs<b></TD>";
		res_inter+="	</TR>";
		res_inter+="	<TR>";
		res_inter+="		<TD colspan=2 align=center><b>Employee Information</b></TD>";
		res_inter+="		<TD colspan=2 align=center><B>Insurance Information</B></TD>";
		res_inter+="	</TR>";
		res_inter+="	<TR>";
		res_inter+="		<TD width=180>Total FT employees </TD>";
		res_inter+="		<TD>"+healthcare.inp.fte+"</TD>";
		res_inter+="		<TD width=170>&nbsp; </TD>";

		res_inter+="		<TD>Employee-only insurance premium </TD>";
		res_inter+="		<TD>"+convertformat(healthcare.inp.prem_s)+"</TD>";
		res_inter+="	</TR>";
		res_inter+="	<TR>";
		res_inter+="		<TD>Total FT regular wages </TD>";
		res_inter+="		<TD>"+ convertformat(healthcare.inp.ft_wage)+"</TD>";
			res_inter+="		<TD >&nbsp; </TD>";

		res_inter+="		<TD> FT employees with employee-only coverage</TD>";
		res_inter+="		<TD>"+healthcare.inp.indins+"</TD>";
		res_inter+="	</TR>";
		res_inter+="	<TR>";
		res_inter+="		<TD>Total PT employees  </TD>";
		res_inter+="		<TD>"+healthcare.inp.t_emp+"</TD>";
		res_inter+="		<TD >&nbsp; </TD>";

		res_inter+="		<TD>Family insurance premium  </TD>";
		res_inter+="		<TD>"+convertformat(healthcare.inp.prem_f)+"</TD>";
		res_inter+="	</TR>";
		res_inter+="	<TR>";
		res_inter+="		<TD>Total PT regular wages</TD>";
		res_inter+="		<TD>"+convertformat(healthcare.inp.pt_wage)+"</TD>";
		res_inter+="		<TD width=10>&nbsp; </TD>";

		res_inter+="		<TD>FT employees with family coverage</TD>";
		res_inter+="		<TD>"+healthcare.inp.fam_ins+"</TD>";
		res_inter+="	</TR>";
		res_inter+="		<TR>";
		res_inter+="		<TD>Total PT regular hours</TD>";
		res_inter+="		<TD>"+addNumberFormat(healthcare.inp.pt_hrs)+"</TD>";
		res_inter+="		<TD width=10>&nbsp; </TD>";

		res_inter+="		<TD>Percent of premiums you'll pay</TD>";
		res_inter+="		<TD>"+(healthcare.inp.prem_per)+"</TD>";
		res_inter+="	</TR>";
		res_inter+="	</TABLE>";

		inputs_res=res_inter;

					
					
	var summary= "";
	if (healthcare.res.req)	{
	summary+="<b>It appears that you will be required to provide health insurance to your full-time employees. To avoid the employer compliance penalty, you will need to provide health insurance to your full-time employees and pay at least 60% of the premiums.  Should you choose not to comply with the health insurance requirement, you will be subject to a maximum penalty of "+convertformat(Math.round(net_cost))+".</b>"
	}
	else{
	 summary+="<b>Based on the information provided, you will not be penalized if you do not provide health insurance to your employees. If you do provide health insurance to your employees, your business should qualify for a credit of "+convertformat(Math.round(sm_bus_crd))+". Taking this credit into consideration, your net cost for providing insurance is "+convertformat(Math.round(net_cost))+".</b>";
	}

	var heading="<b>The information below assumes that all of the provisions in the health care legislation (regardless of effective date) signed into law in March 2010, are in full effect.</b>";


	var res_short="<table border=0 width=530 style='border: 1px solid #CCCCCC;' cellpadding=2>";
		res_short+="	<TR>";
		res_short+="		<TD colspan=2 bgcolor='#DDDDDD' height=20><b><b></TD>";
		res_short+="		<TD  bgcolor='#DDDDDD' align='center' height=20><b>2010-2013<b><span id='sp_hlp_cal_year'></span></TD>";
		res_short+="		<TD  bgcolor='#DDDDDD' align='center' height=20><b>2014-2017<b><span id='sp_hlp_cal_year'></span></TD>";
		res_short+="		<TD  bgcolor='#DDDDDD' align='center' height=20><b>2018 and <br>later <b><span id='sp_hlp_cal_year'></span></TD>";

		res_short+="	</TR>";
		res_short+="	<TR >";
		res_short+="		<TD width=200 colspan=2>Cost to provide health insurance</TD>";
		res_short+="		<TD align='right'>"+convertformat(healthcare.res.employer_cont_i)+"</TD>";
		res_short+="		<TD align='right'>"+convertformat(healthcare.res.employer_cont)+"</TD>";
		res_short+="		<TD align='right'>"+convertformat(healthcare.res.employer_cont)+"</TD>";

		res_short+="	</TR>";
		res_short+="	<TR>";
		res_short+="		<TD colspan=2>Credit for providing health insurance<span id='sp_hlp_credit_ins'>  </span><sup>1,2,3</sup></TD>";
		res_short+="		<TD align='right'>("+convertformat(healthcare.res.sm_bus_crd_i)+")</TD>";
		res_short+="		<TD align='right'>("+convertformat(healthcare.res.sm_bus_crd)+")</TD>";
		res_short+="		<TD align='right'>("+convertformat(healthcare.res.sm_bus_crd)+")</TD>";

		res_short+="	</TR>";
		res_short+="	<TR>";
		res_short+="		<TD colspan=2>Cadillac <span id='sp_hlp_cadillac'>  </span>&nbsp;excise tax (if applicable)<sup>4</sup></TD>";
		res_short+="		<TD>&nbsp;</TD>";
		res_short+="		<TD>&nbsp;</TD>";
		res_short+="		<TD align='right'>"+convertformat(cd_pen)+"</TD>";

		res_short+="	</TR>";	
		res_short+="	<TR>";
		res_short+="		<TD width=20>&nbsp;</TD>";
		res_short+="		<TD>Your net cost to provide insurance</TD>";
		res_short+="		<TD align='right' style='border-top: 1px solid #888;'>"+convertformat(healthcare.res.net_cost_i)+"</TD>";
		res_short+="		<TD align='right' style='border-top: 1px solid #888;'>"+convertformat(healthcare.res.net_cost)+"</TD>";
		res_short+="		<TD align='right' style='border-top: 1px solid #888;'>"+convertformat(healthcare.res.net_cost)+"</TD>";

		res_short+="	</TR>";	
		res_short+="	<TR>";
		res_short+="		<TD colspan=2>Penalty if you choose not to provide <br/>health insurance<sup>5</sup> </TD>";
		res_short+="		<TD>&nbsp;</TD>";
		res_short+="		<TD align='right' style='border-top: 3px double #888;'>"+convertformat(pen3)+"</TD>";
		res_short+="		<TD align='right' style='border-top: 3px double #888;'>"+convertformat(pen3)+"</TD>";

		res_short+="	</TR>";	
		res_short+="</Table>";	

		var disc="<div class='disclaimer' style='margin-top:0px;'><i>Estimator results based on legislation signed into law as of 7/01/2010.<br>Results apply to for-profit organizations only. Tax-exempt and other not-for-profit organizations should contact their tax professionals for assistance with health care reform calculations. H&R Block not responsible for inaccurate or incomplete information entered by business.<br><sup>1</sup>The credit may be capped by the average premium amount for the small business market in the state where your business is located. Business owners should contact their tax professionals for information on how the state caps affect the credit.<br><sup>2</sup>The tax benefit may be lower if you also deduct health insurance costs. A credit and deduction cannot both be claimed for the same health insurance expense dollar.<br><sup>3</sup>Starting in 2014, the credit is available only for a consecutive two-year period for premiums paid to a state insurance exchange.<br><sup>4</sup>Cadillac health plan tax does not apply until 2018.<br><sup>5</sup>Noncompliance tax does not apply until 2014.</div>";
		

		var restxt ="<b>Based on the provisions in the health care legislation signed into law in March 2010, you "	+
		((healthcare.res.req)?" may ":" may not ")+ " be required to provide health insurance to your employees.</b>"; 

		document.getElementById('resultDivOne').innerHTML="<div style='padding-bottom:5px;'>"+summary+"</div><div style='padding-bottom:5px;'>"+res_short+"</div><div style='padding-bottom:2px;'><a href='#' onclick='showHideDetailedRes();return false;'> <img src='http://www.thetaxinstitute.com/images/btn_detailed_results.gif' border=0></a></div>"+disc;


		var hlpspanobj = getElementsByAttribute("id","sp_hlp_cadillac");
		for (var j=0;j< hlpspanobj.length;j++ ){
			var obj = new tooltip('hlp_cadillac',9,19,hlpspanobj[j]);
		}

		hlpspanobj = getElementsByAttribute("id","sp_hlp_cal_year");
		for (var j=0;j< hlpspanobj.length;j++ ){
			var obj = new tooltip('hlp_cal_year',9,19,hlpspanobj[j]);
		}

		
		var tmp_crd_div =document.getElementById('hlp_credit_ins');
		if (typeof tmp_crd_div !='undefined' && tmp_crd_div!=null ){
		
			hlpspanobj = getElementsByAttribute("id","sp_hlp_credit_ins");
			for (var j=0;j< hlpspanobj.length;j++ ){
				var obj = new tooltip('hlp_credit_ins',9,19,hlpspanobj[j]);
			}
		}



	}	

	function animateSlide(nxt){
			
			if(!healthcare.inp.empexists){
				slider.process(document.getElementById('four-header'));


			}
			else{
				slider.process(document.getElementById(nxt))
			}

	}

	function showhideaccordions(show){

	healthcare.inp.empexists=show;
		if(show){
		document.getElementById('three-header').style.display='block';
		document.getElementById('three-content').style.visibility='visible';
		document.getElementById('two-header').style.display='block';
		document.getElementById('two-content').style.visibility='visible';

		}
		else{
		document.getElementById('three-header').style.display='none';
		document.getElementById('three-content').style.visibility='hidden';
		document.getElementById('two-header').style.display='none';
		document.getElementById('two-content').style.visibility='hidden';

		}
	}

