<!--
version = ""
if (navigator.appName == "Netscape" && ((parseInt(navigator.appVersion) == 3) || (parseInt(navigator.appVersion) == 4))) {version = "n3"}

function loadPopUp(html,title) {
        var popup = window.open(html,title,"scrollbars,resizable,width=650,height=480")
        popup = window.open(html,title,"scrollbars,resizable,width=650,height=480")
        if (version == "n3") {
                popup.focus()
        }
        return false
}

function isDollarAmt(inputstr)
{
   if (!inputstr) return false;
   var iChars = "0123456789,.\$";
   var notFloats = "$,";
   ts = '';
   for (var i = 0; i < inputstr.length; i++) 
   {
      s = inputstr.charAt(i);
      if (iChars.indexOf(s) == -1)
         return false;
      if (notFloats.indexOf(s) == -1)
         ts += s;
   }
   fbal = parseFloat(ts);
   if (fbal < 1)
      return false;
   return true;
}
function isNumberGE0(inputstr)
{
   if (!inputstr) return false;
   var iChars = "0123456789";
   var notFloats = "";
   ts = '';
   for (var i = 0; i < inputstr.length; i++) 
   {
      s = inputstr.charAt(i);
      if (iChars.indexOf(s) == -1)
         return false;
      if (notFloats.indexOf(s) == -1)
         ts += s;
   }
   fbal = parseFloat(ts);
   if (fbal < 0)
      return false;
   return true;
}
function isNumberGE1(inputstr)
{
   if (!inputstr) return false;
   var iChars = "0123456789";
   var notFloats = "";
   ts = '';
   for (var i = 0; i < inputstr.length; i++) 
   {
      s = inputstr.charAt(i);
      if (iChars.indexOf(s) == -1)
         return false;
      if (notFloats.indexOf(s) == -1)
         ts += s;
   }
   fbal = parseFloat(ts);
   if (fbal < 1)
      return false;
   return true;
}                      
// Get checked value from radio button.
function getRadioButtonValue (radio)
{
    for (var i = 0; i < radio.length; i++)
    {
       if (radio[i].checked) { break }
    }
    return radio[i].value
}
function isValidContPercent(theForm)
{
    instring = theForm.contribution.value;
    systype = getRadioButtonValue(theForm.system);
    if (systype == "FERS")
    {
       if (isNumberGE0(instring) == false)
       {
           alert("You entered \""+instring+"\" for the percent of your annual pay you will contribute to the plan,     Enter a valid contribution percent using whole numbers of 1 through 99 for FERS. ");
           theForm.contribution.focus();
           return false;
       }
    }
    if (systype == "CSRS")
    {
       if (isNumberGE1(instring) == false)
       {
           alert("You entered \""+instring+"\" for the percent of your annual pay you will contribute to the plan,     Enter a valid contribution percent using whole numbers of 1 through 99 for CSRS. ");
           theForm.contribution.focus();
           return false;
       }
    }
    if (systype == "Uniformed Services")
    {
       if (isNumberGE1(instring) == false)
       {
           alert("You entered \""+instring+"\" for the percent of your annual pay you will contribute to the plan,     Enter a valid contribution percent using whole numbers of 1 through 99 for Uniformed Services. ");
           theForm.contribution.focus();
           return false;
       }
    }
    return true;
}
function isValidPay(theField)
{
    var iChars = "0123456789,.$";
    var notFloats = "$,";
    instring = theField.value
    if (isDollarAmt(instring) == false)
    {
        alert("You entered \""+instring+"\" for your annual pay,     Enter a valid salary amount (1 or more). ");
        theField.focus();
        return false;
    }
    ts = '';
    for (var i = 0; i < instring.length; i++) 
    {
       s = instring.charAt(i);
       if (iChars.indexOf(s) == -1)
          return false;
       if (notFloats.indexOf(s) == -1)
          ts += s;
    }
    fbal = parseFloat(ts);
    theField.value = fbal;
    return true;
}
function isValidContYear(theField)
{
    instring = theField.value
    if (isNumberGE1(instring) == false)
    {
        alert("You entered \""+instring+"\" for the number of years you plan to contribute to the plan,    Enter a valid number of years (1 or more). ");
        theField.focus();
        return false;
    }
    return true;
}
function isValidContRate(theField)
{
    instring = theField.value
    if (isNumberGE1(instring) == false)
    {
        alert("You entered \""+instring+"\" for the annual rate you expect your investment to earn,    Enter a valid return rate (1 or more). ");
        theField.focus();
        return false;
    }
    return true;
}
function isValidSavingsAmt(theField)
{
    var iChars = "0123456789,.$";
    var notFloats = "$,";
    instring = theField.value
    if (isDollarAmt(instring) == false)
    {
        alert("You entered \""+instring+"\" for the amount you have in your TSP Account,     Enter a valid savings amount (1 or more). ");
        theField.focus();
        return false;
    }
    ts = '';
    for (var i = 0; i < instring.length; i++) 
    {
       s = instring.charAt(i);
       if (iChars.indexOf(s) == -1)
          return false;
       if (notFloats.indexOf(s) == -1)
          ts += s;
    }
    fbal = parseFloat(ts);
    theField.value = fbal;
    return true;
}
function isValidCatchUpAmt(theField)
{
    var iChars = "0123456789,.$";
    var notFloats = "$,";
    instring = theField.value
    if (isDollarAmt(instring) == false)
    {
        alert("You entered \""+instring+"\" for the amount you plan to contribute each year in catch-up contributions,     Enter a valid amount (1 or more). ");
        theField.focus();
        return false;
    }
    ts = '';
    for (var i = 0; i < instring.length; i++)
    {
       s = instring.charAt(i);
       if (iChars.indexOf(s) == -1)
          return false;
       if (notFloats.indexOf(s) == -1)
          ts += s;
    }
    fbal = parseFloat(ts);
    theField.value = fbal;
    return true;
}
function isValidSaveYear(theField)
{
    instring = theField.value
    if (isNumberGE1(instring) == false)
    {
        alert("You entered \""+instring+"\" for the number of years you expect to leave your current savings in the TSP,     Enter a valid number of years (1 or more). ");
        theField.focus();
        return false;
    }
    return true;
}
function isValidSaveRate(theField)
{
    instring = theField.value
    if (isNumberGE1(instring) == false)
    {
        alert("You entered \""+instring+"\" for the annual rate you expect your savings to earn,    Enter a valid return rate (1 or more). ");
        theField.focus();
        return false;
    }
    return true;
}
function isValidTable1(theForm)
{
    if (isValidContPercent(theForm) == false)
    {
       theForm.contribution.focus();
       return false;
    }
    if (isValidPay(theForm.income) == false)
    {
       theForm.income.focus();
       return false;
    }
    if (isValidContYear(theForm.period) == false)
    {
       theForm.period.focus();
       return false;
    }
    if (isValidContRate(theForm.rate) == false)
    {
       theForm.rate.focus();
       return false;
    }
    return true;
}
function isValidTable2(theForm)
{
    if (isValidSavingsAmt(theForm.savings) == false)
    {
       theForm.savings.focus();
       return false;
    }
    if (isValidSaveYear(theForm.period2) == false)
    {
       theForm.period2.focus();
       return false;
    }
    if (isValidSaveRate(theForm.rate2) == false)
    {
       theForm.rate2.focus();
       return false;
    }
    return true;
}
function isValidForm(theForm)
{
    if (((theForm.contribution.value != null) && (theForm.contribution.value != "")) ||
        ((theForm.income.value != null) && (theForm.income.value != "")) ||
        ((theForm.period.value != null) && (theForm.period.value != "")) ||
        ((theForm.rate.value != null) && (theForm.rate.value != "")))
    {
       if (isValidTable1(theForm) == false)
           return false;
    }
    if (((theForm.savings.value != null) && (theForm.savings.value != "")) ||
        ((theForm.period2.value != null) && (theForm.period2.value != "")) ||
        ((theForm.rate2.value != null) && (theForm.rate2.value != "")))
    {
       if (isValidTable2(theForm) == false)
           return false;
    }
    if (((theForm.contribution.value == null) || (theForm.contribution.value == "")) &&
        ((theForm.savings.value == null) || (theForm.savings.value == "")))
    {
       alert("You must enter the requested information to calculate the growth of your TSP account");
       theForm.contribution.focus();
       return false;
    }
    return true;
}
//-->
