<!-- * Create List Price * -->
<!-- * Verify the Search Form Selections * -->
function js_verify_cc(formname)
{
   return true;
}

function js_verify_hlc(formname)
{
  return true;
}

function js_hlc_whattocalc(idx,formname)
{
  document.getElementById("e1").style.color="black"
  document.getElementById("e1").style.fontWeight="normal"
  document.getElementById("e1").style.textAlign="right"
  document.getElementById("e3").style.color="black"
  document.getElementById("e3").style.fontWeight="normal"
  document.getElementById("e3").style.textAlign="right"
  document.getElementById("e4").style.color="black"
  document.getElementById("e4").style.fontWeight="normal"
  document.getElementById("e4").style.textAlign="right"
  formname.loanamount.disabled = false; 
  formname.period.disabled = false; 
  formname.monthlyrep.disabled = false; 

  formname.loanamount.value  = "";
  formname.period.value = "";
  formname.irate.value  = "";
  formname.monthlyrep.value = ""; 
  
  if( idx == 0 ) formname.monthlyrep.disabled = true; 
  if( idx == 1 ) formname.period.disabled = true; 
  if( idx == 2 ) formname.loanamount.disabled = true; 
  
}

function js_hlc_calc(formname)
{
   var amt;
   if( formname.whattocalc.selectedIndex == 0 )
   {
      amt = find_repayment(formname.loanamount.value,formname.irate.value/100/12,formname.period.value);
      formname.monthlyrep.disabled = false; 
      document.getElementById("e4").style.color="red"
      document.getElementById("e4").style.fontWeight="bold"
      document.getElementById("e4").style.textAlign="left"
      formname.monthlyrep.value = amt.toFixed(3);
   }
   if( formname.whattocalc.selectedIndex == 1 )
   {
      amt = find_period(formname.loanamount.value,formname.irate.value/100/12,formname.monthlyrep.value);
      formname.period.disabled = false; 
      document.getElementById("e3").style.color="red"
      document.getElementById("e3").style.fontWeight="bold"
      document.getElementById("e3").style.textAlign="left"
      formname.period.value = amt.toFixed(2);
   }
   if( formname.whattocalc.selectedIndex == 2 )
   {
      amt = find_loanamount(formname.monthlyrep.value,formname.irate.value/100/12,formname.period.value);
      formname.loanamount.disabled = false; 
      document.getElementById("e1").style.color="red"
      document.getElementById("e1").style.fontWeight="bold"
      document.getElementById("e1").style.textAlign="left"
      formname.loanamount.value = amt.toFixed(0);
   }
   formname.period.value = formname.period.value + " ÓäÉ";
   formname.irate.value  = formname.irate.value  + "Ü%Ü" ;
}

function find_repayment(loanamount, irate, period) 
{
  return ( irate*loanamount ) / ( 1 - Math.pow(1+irate,-period*12) )
}

function find_period(loanamount, irate, repayment) 
{
  return (- Math.log(1-irate*loanamount/repayment)/Math.log(1+irate))/12
}

function find_loanamount(repayment, irate, period) 
{
  return (repayment/irate)*(1- Math.pow(1+irate,-period*12))
}
