/* ---------------------------
' (C) Copyright 2008
' Niro Solutions Pty Limited
' ABN 89 106 967 140
' ---------------------------
' Revision: 2.0.0
' Author: Zhongbo Sun
' Modtime: 05/11/09/08

' --------------------------- */


function startInt(){
  calcInt = setInterval(calculateIt, 50);
}

function parseUndefinedInt(val){
  return (val=="" || parseInt(val)==false) ? 0 : parseInt(val);
}

function calculateIt(){
  f = document.forms.calcForm;
  
  // long term debts
  lineA = parseUndefinedInt(f.mortgage.value)+parseUndefinedInt(f.otherloans.value);
  f.lineATot.value=(Math.round(lineA*100))/100;
  
  // monthly living
  lineB = parseUndefinedInt(f.rent.value);
  lineB += parseUndefinedInt(f.transport.value);
  lineB += parseUndefinedInt(f.home.value);
  lineB += parseUndefinedInt(f.entertainment.value);
  lineB += parseUndefinedInt(f.food.value);
  lineB += parseUndefinedInt(f.school.value);
  lineB += parseUndefinedInt(f.clothes.value);
  lineB=(Math.round(lineB*100))/100;
  
  if(f.yearstocover.value!="" && parseUndefinedInt(f.yearstocover.value)==0) f.yearstocover.value=1;
  
  f.monthtotal.value=(Math.round(lineB*100))/100;
  f.by12.value=lineB*12;
  
  lineB=f.lineBTot.value=f.by12.value*f.yearstocover.value;
  
  lineC=f.lineC.value=lineA+lineB;
  
  f.lineF.value = lineC-parseUndefinedInt(f.lineD.value)-parseUndefinedInt(f.lineE.value);
  
}
function intOnly(field) 
{ 
    if (field != undefined )
    {
        var m_strOut = new String(field.value); 
        m_strOut = m_strOut.replace(/[^0-9]/g, ''); 
        
        if (field.value != m_strOut)
            {field.value = m_strOut} 

    }
}
