function CalQualAmt()
{
    var IncOne
    var IncTwo
    var OthInc
    var RentInc
    var TotInc

    var HomeLoan
    var OthLoan
    var CardLim
    
    var Marritial
    var Parent
    var NumbDep
    
    //var AmtDep
    //var OthExp 
    var ExpFromTable
    var TotExp
    

    var IntRate
    var MonthTerm
    var RepayAmt
    var QualAmt

    if (checkIncOne(document.qualify.IncOne) &&
	checkNumb(document.qualify.OthInc,"Other Income") &&
	checkNumb(document.qualify.RentInc,"Rental Income") &&
	checkNumb(document.qualify.HomeLoan,"Home Loan") &&
	checkNumb(document.qualify.OthLoan,"Other Loan") &&
	checkNumb(document.qualify.CardLim,"Card Limit") &&				
	checkIntRate(document.qualify.IntRate) &&
        checkTermY(document.qualify.TermYear) &&
        checkTermM(document.qualify.TermYear,document.qualify.TermMonth))
        {

        IncOne  = parseInt(parseNumb(document.qualify.IncOne))
        OthInc = parseInt(parseNumb(document.qualify.OthInc))
        RentInc = parseNumb(document.qualify.RentInc)
        HomeLoan = parseNumb(document.qualify.HomeLoan)
        OthLoan = parseNumb(document.qualify.OthLoan)
        CardLim = parseNumb(document.qualify.CardLim)
                              
	Marritial = parseInt((document.qualify.MaritialAndLiving[document.qualify.MaritialAndLiving.selectedIndex].value).substring(0,1))
    	Parent    = parseInt((document.qualify.MaritialAndLiving[document.qualify.MaritialAndLiving.selectedIndex].value).substring(1))        
        NumbDep = parseInt(document.qualify.dependent[document.qualify.dependent.selectedIndex].value)
        
	Marritial = parseInt((document.qualify.MaritialAndLiving[document.qualify.MaritialAndLiving.selectedIndex].value).substring(0,1))
    	Parent    = parseInt((document.qualify.MaritialAndLiving[document.qualify.MaritialAndLiving.selectedIndex].value).substring(1))
                
        IntRate = parseNumb(document.qualify.IntRate)/1200
        MonthTerm = parseMonth(document.qualify.TermYear,document.qualify.TermMonth)
 
        TotInc = IncOne + OthInc
	
	ExpFromTable = getExpFromTable(Marritial,NumbDep,Parent)
	
	TotExp = ExpFromTable*1 + HomeLoan*1 + OthLoan*1 + (CardLim * 0.05) 

	RepayAmt = 0.85*(TotInc + (RentInc * 0.75)) - TotExp

        LoanAmt = (RepayAmt) * (1 - Math.pow((1 + IntRate*1),-MonthTerm))/IntRate
        if (LoanAmt > 0)
            {
            document.qualify.LoanAmt.value = ParseDollar(Math.round(LoanAmt))
            }
        else
            {
            document.qualify.LoanAmt.value = "$ 0"
            } 
        }
    else
        {
        document.qualify.LoanAmt.value = " "
        }

}

function getExpFromTable(Marritial,NumbDep,Parent){
	
	var Single = 0;
	var Married = 1;
	var Widowed = 2;
	var DivorcedAndSep = 3;
	var Defacto = 4;
	var NotLivWithParent = 0;
	var LivWithParent = 1;
	
	
//	table[Maritial Status][# of dependants][Living with parents] = Living Expenses
	
	
	var single = new Array(12);
			
	single[0]  = 855  //[Single][0][NotLivWithParent]	
	single[1]  = 430  //[Single][0][LivWithParent]
	single[2]  = 1175 //[Single][1][NotLivWithParent]
	single[3]  = 750  //[Single][1][LivWithParent]
	single[4]  = 1477 //[Single][2][NotLivWithParent]
	single[5]  = 1052 //[Single][2][LivWithParent]
	single[6]  = 1779 //[Single][3][NotLivWithParent]
	single[7]  = 1354 //[Single][3][LivWithParent]
	single[8]  = 2081 //[Single][4][NotLivWithParent]
	single[9]  = 1657 //[Single][4][LivWithParent]
	single[10] = 2383 //[Single][5][NotLivWithParent]
	single[11] = 1959 //[Single][5][LivWithParent]


	var married = new Array(12);
	
	married[0] = 1243  //[Married][0][NotLivWithParent]
	married[1] = 0     //[Married][0][LivWithParent]  NA	
	married[2] = 1546  //[Married][1][NotLivWithParent]
	married[3] = 0     //[Married][1][LivWithParent]  NA		
	married[4] = 1848  //[Married][2][NotLivWithParent]	
	married[5] = 0     //[Married][2][LivWithParent]  NA	
	married[6] = 2150  //[Married][3][NotLivWithParent]	
	married[7] = 0     //[Married][3][LivWithParent]  NA	
	married[8] = 2449  //[Married][4][NotLivWithParent]	
	married[9] = 0     //[Married][4][LivWithParent]  NA	
	married[10] = 2748 //[Married][5][NotLivWithParent]
	married[11] = 0    //[Married][5][LivWithParent]  NA
	

	var widowed = new Array(12);

	widowed[0]  = 855  //[Widowed][0][NotLivWithParent] 
	widowed[1]  = 430  //[Widowed][0][LivWithParent]    
	widowed[2]  = 1175 //[Widowed][1][NotLivWithParent] 
	widowed[3]  = 750  //[Widowed][1][LivWithParent]    
	widowed[4]  = 1477 //[Widowed][2][NotLivWithParent] 
	widowed[5]  = 1052 //[Widowed][2][LivWithParent]    
	widowed[6]  = 1779 //[Widowed][3][NotLivWithParent] 
	widowed[7]  = 1354 //[Widowed][3][LivWithParent]    
	widowed[8]  = 2081 //[Widowed][4][NotLivWithParent] 
	widowed[9]  = 1657 //[Widowed][4][LivWithParent]    
	widowed[10] = 2383 //[Widowed][5][NotLivWithParent] 
	widowed[11] = 1959 //[Widowed][5][LivWithParent]    

	
	var divoiced = new Array(12);

	divoiced[0]  = 855   //[DivorcedAndSep][0][NotLivWithParent] 
	divoiced[1]  = 430   //[DivorcedAndSep][0][LivWithParent]    
	divoiced[2]  = 1175  //[DivorcedAndSep][1][NotLivWithParent] 
	divoiced[3]  = 750   //[DivorcedAndSep][1][LivWithParent]    
	divoiced[4]  = 1477  //[DivorcedAndSep][2][NotLivWithParent] 
	divoiced[5]  = 1052  //[DivorcedAndSep][2][LivWithParent]    
	divoiced[6]  = 1779  //[DivorcedAndSep][3][NotLivWithParent] 
	divoiced[7]  = 1354  //[DivorcedAndSep][3][LivWithParent]    
	divoiced[8]  = 2081  //[DivorcedAndSep][4][NotLivWithParent] 
	divoiced[9]  = 1657  //[DivorcedAndSep][4][LivWithParent]    
	divoiced[10]  = 2383  //[DivorcedAndSep][5][NotLivWithParent] 
	divoiced[11]  = 1959  //[DivorcedAndSep][5][LivWithParent]    


        var defacto = new Array(12);
        
	defacto[0]  = 1243 //[Defacto][0][NotLivWithParent] 
	defacto[1]  = 0    //[Defacto][0][LivWithParent]    NA
	defacto[2]  = 1546 //[Defacto][1][NotLivWithParent] 
	defacto[3]  = 0    //[Defacto][1][LivWithParent]    NA
	defacto[4]  = 1848 //[Defacto][2][NotLivWithParent] 
	defacto[5]  = 0    //[Defacto][2][LivWithParent]    NA
	defacto[6]  = 2150 //[Defacto][3][NotLivWithParent] 
	defacto[7]  =0     //[Defacto][3][LivWithParent]    NA
	defacto[8]  = 2449 //[Defacto][4][NotLivWithParent] 
	defacto[9]  =0     //[Defacto][4][LivWithParent]    NA
	defacto[10] = 2748 //[Defacto][5][NotLivWithParent] 
	defacto[11] =0     //[Defacto][5][LivWithParent]    NA

	
	if (Marritial == Single){
	  return single[2*NumbDep + Parent];
	}
	else if (Marritial == Married){
	  return married[2*NumbDep + Parent];
	}
	else if (Marritial == Widowed){
	  return widowed[2*NumbDep + Parent];
	}
	else if (Marritial == DivorcedAndSep){
	  return widowed[2*NumbDep + Parent];
	}
	else if (Marritial == Defacto){
	  return defacto[2*NumbDep + Parent];
	}	
}