
function computeForm(ddlAY,ddlGen,optSC,txtNTI,txtTI,txtSC,txtEDU,txtT) 
    {
        var percent;
        var nti = txtNTI.value;
        var it;
        var surcharge;
        var ecess;
        var totaltax;
        var gender=ddlGen;
        var senior=optSC.checked;
        var AYear =ddlAY.value;

        var Limit1;
        var Limit2;
        var Limit3;
        var SurLimit =1000000;
        var EcessPer=3;

                
    //**************** Set Limitations *********************//
    //******************************************************//
        
        //******* For Financial Year 2007-2008 *************//       
        if (AYear == "2007-2008")
            {
                EcessPer=2;
                if (senior == false)
                    {
                    if (gender == "Male")
                        {   
                        Limit1=100000;
                        Limit2=150000;
                        Limit3=250000;
                        }
                    else if (gender == "Female")
                        {
                        Limit1=135000;
                        Limit2=150000;
                        Limit3=250000;                        
                        }
                    }
                else
                    {
                        Limit1=0;
                        Limit2=185000;
                        Limit3=250000;                    
                    }                    
            }
        //******* For Financial Year 2008-2009 *************//
        else if (AYear == "2008-2009")
            {

                if (senior == false)
                    {
                    if (gender == "Male")
                        {   
                        Limit1=110000;
                        Limit2=150000;
                        Limit3=250000;
                        }
                    else if (gender == "Female")
                        {
                        Limit1=145000;
                        Limit2=150000;
                        Limit3=250000;                        
                        }
                    }
                else
                    {
                        Limit1=0;
                        Limit2=195000;
                        Limit3=250000;                    
                    }  
                                
            }
        //******* For Financial Year 2009-2010 *************//
        else if (AYear == "2009-2010")
            {
                if (senior == false)
                    {
                    if (gender == "Male")
                        {   
                        Limit1=150000;
                        Limit2=300000;
                        Limit3=500000;
                        }
                    else if (gender == "Female")
                        {
                        Limit1=180000;
                        Limit2=300000;
                        Limit3=500000;                        
                        }
                    }
                else
                    {
                        Limit1=225000;
                        Limit2=300000;
                        Limit3=500000;                    
                    }              
            }
     else if (AYear == "2010-2011")
            {
             SurLimit=0;
                if (senior == false)
                    {
                    if (gender == "Male")
                        {   
                        Limit1=160000;
                        Limit2=300000;
                        Limit3=500000;
                        }
                    else if (gender == "Female")
                        {
                        Limit1=190000;
                        Limit2=300000;
                        Limit3=500000;                        
                        }
                    }
                else
                    {
                        Limit1=240000;
                        Limit2=300000;
                        Limit3=500000;                    
                    }              
            }
             else if (AYear == "2011-2012")
            {
             SurLimit=0;
                if (senior == false)
                    {
                    if (gender == "Male")
                        {   
                        Limit1=160000;
                        Limit2=500000;
                        Limit3=800000;
                        }
                    else if (gender == "Female")
                        {
                        Limit1=190000;
                        Limit2=500000;
                        Limit3=800000;                        
                        }
                    }
                else
                    {
                        Limit1=240000;
                        Limit2=500000;
                        Limit3=800000;                    
                    }              
            }
     //***************** IT Calculation ********************//
     //******************************************************//
        
        //***************** This for AY 2007-08,2008-09 *******************//
        //****** These years are not having the first limitation(10%) ******//        
        if (Limit1 == 0 )
            {
        	    if (nti <= Limit2)
	                {
	                it=0;
	                surcharge=0;
	                ecess=0;
	                totaltax=it+surcharge+ecess;
	                }
                else 
                    {
                   
                    if (nti > -1) 
		                {
		                it=0;
		                surcharge=0;
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it+surcharge+ecess;
		                }
    	            if (nti > Limit2 && nti <= Limit3) 
		                {
		                percent = 0.2;		                
		                it=it+(nti - Limit2) * percent; 
		                surcharge=0;
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }        		
		            if (nti > Limit3) 
		                {
		                percent = 0.3;
		                it =((Limit3 - Limit2) * 0.2);		                               
		                it = it+(nti - Limit3) * percent;
		                surcharge=0;
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }
		            if(SurLimit != 0)
		            {
		                if (nti > SurLimit) 
		                {
		                //call marginal relif function
		                percent = 0.3;		                
		                //surcharge=(0.1 * it);
		                surcharge= MarginalRelif(nti,SurLimit,it);
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }
		            }
                    }
                                          
            }   
        else    
            {
        	    if (nti <= Limit1)
	                {
	                it=0;
	                surcharge=0;
	                ecess=0;
	                totaltax=it+surcharge+ecess;
	                }
                else 
                    {
                    if (nti > -1) 
		                {
		                it=0;
		                surcharge=0;
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it+surcharge+ecess;
		                }        
		            if (nti > Limit1 && nti <= Limit2) 
    		            {
		                percent = 0.1;
		                it=(nti - Limit1) * percent;
		                surcharge=0;
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }
		            if (nti > Limit2 && nti <= Limit3) 
		                {
		                percent = 0.2;		                
		                it=(Limit2 - Limit1) * 0.1;
		                it=it + (nti - Limit2) * percent;
		                surcharge =0;
		                ecess=(EcessPer * (it + surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                } 		                		                
		                
		            if (nti > Limit3) 
		                {
		                percent = 0.3;
		                it = ((Limit2 - Limit1) * 0.1) + ((Limit3 - Limit2) * 0.2);
		                it = it + (nti - Limit3) * percent;
		                surcharge=0;
		                ecess =(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }
		                
		            if(SurLimit != 0)
		            {    
		                if (nti > SurLimit) 
		                {
		                 //call marginal relif function
		                percent = 0.3;
		                //surcharge=(0.1 * it);
		                surcharge= MarginalRelif(nti,SurLimit,it);
		                ecess=(EcessPer * (it+surcharge))/100;
		                totaltax=it + surcharge + ecess;
		                }	
		             }
		             	                		                
                    }        
            }             
                    
                    
    txtNTI.value=nti;
    txtTI.value=roundNumber(it,0);
    txtSC.value=roundNumber(surcharge,0);
    txtEDU.value=roundNumber(ecess,0);
    txtT.value=roundNumber(totaltax,0);                                             
    
    }    

function roundNumber(rnum, rlength) 
    {
    var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
    return newnumber;
    }
function MarginalRelif(nti,SurLimit,it)
{
    if(nti>SurLimit)
    {
        var marrelifnti=((nti-SurLimit)*70)/100;
        var marrelifit=(it*10)/100;
        if(marrelifnti<marrelifit)
        {
        return marrelifnti;
        }
        else
        {
        return marrelifit;
        }
    }
}

