
function calc()
{
for (i=0;i<document.it.category.length;i++){
		if (document.it.category[i].checked==true){
			var category=document.it.category[i].value;
			}
	}

var sal=document.it.sal.value;
var hp=document.it.hp.value;
var os=document.it.os.value;
var cg=document.it.cg.value;
var inv80c=document.it.inv80c.value;
var inv80d=document.it.inv80d.value;
var inv80d1=document.it.inv80d1.value;
var other=document.it.other.value;
var itax=document.it.itax.value;
var sur=document.it.sur.value;
var ecess=document.it.ecess.value;
var liab=document.it.liab.value;
var incsr=document.it.incsr.value;
var taxsr=document.it.taxsr.value;
var gitax=document.it.gitax.value;
var inc=document.it.inc.value;

var einv80c;
var einv80d;
var einv80d1;

if (inv80c >= 100000)
{einv80c = 100000;}
else
{einv80c = inv80c;}

if (category == "seniorcitizen");
{
if (inv80d >= 20000)
{einv80d = 20000;}
else if (inv80d >0<20000)
{einv80d = inv80d;}}

if (category != "seniorcitizen")
{
if (inv80d >= 15000)
{einv80d = 15000;}
else if (inv80d > 0 && inv80d < 15000)
{einv80d = inv80d;}}

if (inv80d1 >= 20000)
{einv80d1 = 20000;}
else
{einv80d1 = inv80d1;}

document.it.inc.value = document.it.sal.value*1 + document.it.hp.value*1 + document.it.cg.value*1 + document.it.os.value*1 - einv80c - einv80d  - einv80d1 - document.it.other.value*1;
var ginc=inc*1 + incsr*1;

document.it.ninc.value = ginc*1 - liab*1 ;

if (category == "indmale" && inc > 500000)
{
document.it.itax.value = Math.round(55000*1+((inc-500000)*.3));
if (ginc > 1000000 && (ginc*1 - gitax*1.1)> 795000)
document.it.sur.value = Math.round(gitax*.1);
else if ( ginc > 1000000 && (ginc*1 - gitax*1.1)<= 795000 )
document.it.sur.value = (ginc*1 - 795000*1 - gitax*1);
else 
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1 ;
}
else if ( category == "indmale" && inc <= 500000 && inc > 300000)
{ document.it.itax.value = Math.round(15000*1+((inc-300000)*.2));
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1 )*1 ;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1 )*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "indmale" &&  inc <= 300000 && inc > 150000)
{ document.it.itax.value = Math.round((inc-150000)*.1);
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "indmale" &&  inc <= 150000)
{document.it.itax.value = 0;
document.it.sur.value = 0;
document.it.gitax.value = 0;
document.it.ecess.value = 0;
document.it.liab.value = 0;
}

else if (category == "indfemale" && inc > 500000)
{
document.it.itax.value = Math.round(52000*1+(inc-500000)*.3); 
if (ginc > 1000000 && (ginc*1 - gitax*1.1)> 798000)
document.it.sur.value = Math.round(gitax*.1);
else if ( ginc > 1000000 && (ginc*1 - gitax*1.1)<= 798000 )
document.it.sur.value = (ginc*1 - 798000*1 - gitax*1);
else 
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "indfemale" && inc <= 500000 && inc > 300000)
{document.it.itax.value = 12000*1+((inc-300000)*.2);
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "indfemale" &&  inc <= 300000 && inc > 180000)
{ document.it.itax.value = Math.round((inc-180000)*.1);
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "indfemale" &&  inc <= 180000)
{document.it.itax.value = 0;
document.it.sur.value = 0;
document.it.gitax.value = 0;
document.it.ecess.value = 0;
document.it.liab.value = 0;
}
else if (category == "seniorcitizen" && inc > 500000)
{
document.it.itax.value =Math.round(47500*1+(inc-500000)*.3); 
if (ginc > 1000000 && (ginc*1 - gitax*1.1)> 802500)
document.it.sur.value = Math.round(gitax*.1);
else if ( ginc > 1000000 && (ginc*1 - gitax*1.1)<= 802500 )
document.it.sur.value = (ginc*1 - 802500*1 - gitax*1);
else 
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "seniorcitizen" && inc <= 500000 && inc >= 300000)
{ document.it.itax.value = Math.round(7500*1 + (inc-300000)*.2);
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "seniorcitizen" &&  inc <= 300000 && inc >225000)
{document.it.itax.value = Math.round((inc-225000)*.1);
document.it.sur.value = 0;
document.it.gitax.value = (document.it.itax.value*1 + taxsr*1)*1;
document.it.ecess.value = Math.round((document.it.itax.value*1 + document.it.sur.value*1 + taxsr*1)*.03);
document.it.liab.value = document.it.gitax.value*1 + document.it.sur.value*1 + document.it.ecess.value*1;
}
else if (category == "seniorcitizen" &&  inc <= 225000)
{document.it.itax.value = 0;
document.it.sur.value = 0;
document.it.gitax.value = 0;
document.it.ecess.value = 0;
document.it.liab.value = 0;
}
}


function checkNumeric(whichObj,msg){
	// first trim the field
	var income=whichObj.value.replace(/(^\s*)|(\s*$)/g, "" );
	income=income.replace(/,/,"");
	// check if the input is at all numeric
	if(isNaN(income)==true){
		document.getElementById(""+msg+"").style.backgroundColor = "#fff2e8";
		document.getElementById("showmsg").innerHTML = "Enter Valid Number.";
			return false;
		}
		else
		{
				document.getElementById(""+msg+"").style.backgroundColor = "white";
				document.getElementById("showmsg").innerHTML = "";
				return true; 	
		}
	// check if the numeric is non-negative
	if((income) <= 0 ){ 
	document.getElementById(""+msg+"").style.backgroundColor = "#fff2e8";
	document.getElementById("showmsg").innerHTML = "Enter Valid Number.";
		return false;
	}
	else{
		document.getElementById(""+msg+"").style.backgroundColor = "white";
		document.getElementById("showmsg").innerHTML = "";
		return true; 	
	}
	// if only integers are expected, round the value
	
}