﻿// JScript File


       function formatnumber(a,b)
        { 
        a = unformat(a); 
        var txtIncome = document.getElementById('txt_NetIncome');      
	            if (b == 0)
	            {   a=a;
		            if (a == 0) 
		            { return "0"; }
		            else if (a/Math.abs(a) == 1) 
		            { return addcommas(Math.round(a)); 
		            }
		            else 
		            { return "(" + addcommas(Math.round(-a)) + ")";
		            }
	            } 
	            else 
	            {
		        if (a == 0) 
		        { return "$0";
		         }
		        else if (a/Math.abs(a) == 1)
		        {		        
		         txtIncome.value = "$ " +addcommas(Math.round(a)); 
		         }
		        else 
		        {		       
		        txtIncome.value  = "$ "+addcommas(Math.round(-a));
		        }
                }	
        }

        
        function addcommas(x) 
        {
         var newstring="";
         x=x+"c"
         for (i=0 ; i<x.length-1 ; i++) {
          if ((x.length-i)%3 == 1  &  i != 0) {
           newstring = newstring + "," + x.substring(i,i+1);
          } else {
           newstring = newstring + x.substring(i,i+1);
         } }
         return newstring;
        }





 function unformat(x)
    {
	
	var newvalue = 0;
	for (i=0 ; i<x.length ; i++)
	{
		y = x.substring(i,i+1);
		if (y == '0' | y == '1' | y == '2' | y == '3' | y == '4' | y == '5' | y == '6' | y == '7' | y == '8' | y == '9')
		{
			newvalue = 10*newvalue + Number(x.substring(i,i+1));
		}
		else if (y == '.')
		{
			return (newvalue);
		}
	}
	return (newvalue);
   }
   
   
   function doClick(buttonName,e)
    {
   //the purpose of this function is to allow the enter key to 

//point to the correct button to click.
       
        var key;

         if(window.event)
         {
              key = window.event.keyCode;      //IE
//                 alert(key);
           }
         else
         {
              key = e.which; 
              
              }    //firefox

    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
         
            var btn = buttonName;
            if (btn != null)
            { //If we find the button click it

                btn.click();
                event.keyCode = 0
            }
        }
   }
   

function CalGSTHST()
{

try
{

    var netIncome = document.getElementById('txt_NetIncome').value;
    var chilldren = document.getElementById('ddlChildren').value;
    var statusMU = document.getElementById('ddlStatus').value;
    var result = document.getElementById('txt_Result');

    var tabNotMarried = document.getElementById('tab_NotMarried');
    var tabMarried = document.getElementById('tab_Married');

    netIncome = unformat(netIncome);
    
    
    var rowNo;
    var rows;
    
    
    
    if(statusMU == 0)  //*****************Not Married
    {
            rows=tabNotMarried.rows;
                   
            if(netIncome <=  8047)
            { 
             rowNo=1;       
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  8047 && netIncome <= 10000)
            { 
             rowNo=2;
             GetValues(chilldren,result,rows,rowNo);            
               
            }
            else if(netIncome >  10000 && netIncome <= 15000)
            { 
             rowNo=3;
             GetValues(chilldren,result,rows,rowNo);            
               
            }  
            
            
            else if(netIncome >  15000 && netIncome <= 20000)
            { 
             rowNo=4;
             GetValues(chilldren,result,rows,rowNo);            
               
            }  
            
            
             else if(netIncome >  20000 && netIncome <= 25000)
            { 
             rowNo=5;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
           
            else if(netIncome >  25000 && netIncome <= 30000)
            { 
             rowNo=6;
             GetValues(chilldren,result,rows,rowNo);            
               
            }    
            
            else if(netIncome >  30000 && netIncome <= 32312)
            { 
             rowNo=7;
             GetValues(chilldren,result,rows,rowNo);            
               
            }            
            else if(netIncome >  32312 && netIncome <= 33000)
            { 
             rowNo=8;
             GetValues(chilldren,result,rows,rowNo);            
               
            }            
            
            else if(netIncome >  33000 && netIncome <= 34000)
            { 
             rowNo=9;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  34000 && netIncome <= 35000)
            { 
             rowNo=10;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
              else if(netIncome >  35000 && netIncome <= 36000)
            { 
             rowNo=11;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  36000 && netIncome <= 37000)
            { 
             rowNo=12;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  37000 && netIncome <= 38000)
            { 
             rowNo=13;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  38000 && netIncome <= 39000)
            { 
             rowNo=14;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  39000 && netIncome <= 39875)
            { 
             rowNo=15;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  39875 && netIncome <= 40000)
            { 
             rowNo=16;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  40000 && netIncome <= 41000)
            { 
             rowNo=17;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  41000 && netIncome <= 42000)
            { 
             rowNo=18;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  42000 && netIncome <= 43000)
            { 
             rowNo=19;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  43000 && netIncome <= 44000)
            { 
             rowNo=20;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  44000 && netIncome <= 45000)
            { 
             rowNo=21;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  45000 && netIncome <= 46000)
            { 
             rowNo=22;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  46000 && netIncome <= 47000)
            { 
             rowNo=23;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  47000 && netIncome <= 47435)
            { 
             rowNo=24;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  47435 && netIncome <= 48000)
            { 
             rowNo=25;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  48000 && netIncome <= 49000)
            { 
             rowNo=26;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  49000 && netIncome <= 50000)
            { 
             rowNo=27;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  50000 && netIncome <= 50032)
            { 
             rowNo=28;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  50032 && netIncome <= 51000)
            { 
             rowNo=29;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  51000 && netIncome <= 52000)
            { 
             rowNo=30;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  52000 && netIncome <= 52632)
            { 
             rowNo=31;
             GetValues(chilldren,result,rows,rowNo);            
               
            }            
            
    
    }
    else if(statusMU == 1) //************************Married
    {
            rows=tabMarried.rows;   
        
            if(netIncome <=  8047)
            { 
             rowNo=1;       
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  8047 && netIncome <= 10000)
            { 
             rowNo=2;
             GetValues(chilldren,result,rows,rowNo);            
               
            }
            else if(netIncome >  10000 && netIncome <= 15000)
            { 
             rowNo=3;
             GetValues(chilldren,result,rows,rowNo);            
               
            }  
            
            
            else if(netIncome >  15000 && netIncome <= 20000)
            { 
             rowNo=4;
             GetValues(chilldren,result,rows,rowNo);            
               
            }  
            
            
             else if(netIncome >  20000 && netIncome <= 25000)
            { 
             rowNo=5;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
           
            else if(netIncome >  25000 && netIncome <= 30000)
            { 
             rowNo=6;
             GetValues(chilldren,result,rows,rowNo);            
               
            }    
            
            else if(netIncome >  30000 && netIncome <= 32312)
            { 
             rowNo=7;
             GetValues(chilldren,result,rows,rowNo);            
               
            }            
            else if(netIncome >  32312 && netIncome <= 33000)
            { 
             rowNo=8;
             GetValues(chilldren,result,rows,rowNo);            
               
            }            
            
            else if(netIncome >  33000 && netIncome <= 34000)
            { 
             rowNo=9;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  34000 && netIncome <= 35000)
            { 
             rowNo=10;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
              else if(netIncome >  35000 && netIncome <= 36000)
            { 
             rowNo=11;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  36000 && netIncome <= 37000)
            { 
             rowNo=12;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  37000 && netIncome <= 38000)
            { 
             rowNo=13;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  38000 && netIncome <= 39000)
            { 
             rowNo=14;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  39000 && netIncome <= 40000)
            { 
             rowNo=15;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  40000 && netIncome <= 41000)
            { 
             rowNo=16;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  41000 && netIncome <= 42000)
            { 
             rowNo=17;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  42000 && netIncome <= 42235)
            { 
             rowNo=18;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  42235 && netIncome <= 43000)
            { 
             rowNo=19;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  43000 && netIncome <= 44000)
            { 
             rowNo=20;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  44000 && netIncome <= 44835)
            { 
             rowNo=21;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  44835 && netIncome <= 45000)
            { 
             rowNo=22;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  45000 && netIncome <= 46000)
            { 
             rowNo=23;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  46000 && netIncome <= 47000)
            { 
             rowNo=24;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  47000 && netIncome <= 47437)
            { 
             rowNo=25;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  47437 && netIncome <= 48000)
            { 
             rowNo=26;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  48000 && netIncome <= 49000)
            { 
             rowNo=27;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  49000 && netIncome <= 50000)
            { 
             rowNo=28;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  50000 && netIncome <= 50032)
            { 
             rowNo=29;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  50032 && netIncome <= 51000)
            { 
             rowNo=30;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            
            else if(netIncome >  51000 && netIncome <= 52000)
            { 
             rowNo=31;
             GetValues(chilldren,result,rows,rowNo);            
               
            } 
            else if(netIncome >  52000 && netIncome <= 52635)
            { 
             rowNo=32;
             GetValues(chilldren,result,rows,rowNo);            
               
            }  
     }       



}// end try 


catch (e)
{
}

}// end function





function GetValues(chilldren,result,rows,rowNo)
{

                var cellValue;

                if(chilldren == 1)
                {
                                
                if (window.event)
                { //IE             
                  cellValue = rows[rowNo].cells[1].innerText
                }
                else
                {
                 //Firefox             
                cellValue = rows[rowNo].cells[1].textContent
                
                }               
                              
                result.value = cellValue;
                }
                else if(chilldren == 2)
                {
                                
                if (window.event)
                { //IE             
                  cellValue = rows[rowNo].cells[2].innerText
                }
                else
                {
                 //Firefox             
                cellValue = rows[rowNo].cells[2].textContent
                
                }              
                result.value = cellValue;
                }
                 else if(chilldren == 3)
                {
                if (window.event)
                { //IE             
                  cellValue = rows[rowNo].cells[3].innerText
                }
                else
                {
                 //Firefox             
                cellValue = rows[rowNo].cells[3].textContent
                
                }              
                result.value = cellValue;
                }
                 else if(chilldren == 4)
                {
                
                if (window.event)
                { //IE             
                  cellValue = rows[rowNo].cells[4].innerText
                }
                else
                {
                 //Firefox             
                cellValue = rows[rowNo].cells[4].textContent
                
                } 
                           
                result.value = cellValue;
                }
                
                else if(chilldren == 5)
                {
                
                if (window.event)
                { //IE             
                  cellValue = rows[rowNo].cells[5].innerText
                }
                else
                {
                 //Firefox             
                cellValue = rows[rowNo].cells[5].textContent
                
                }                
                result.value = cellValue;
                }





}







