var n;
var p;
var p1;
var tot;
var total;

function editpass(m){
  p1=m;
  p = p1.value;
  document.getElementById('PASSWORDMESSAGE').innerHTML = "";
  if (p.length < 8) {
     document.getElementById('PASSWORDMESSAGE').innerHTML = "Type at least 8 characters";
  };
  if (!(/\d/.test(p))) {
     document.getElementById('PASSWORDMESSAGE').innerHTML = "Use at least 1 digit"; 
  };
}

function editdate(m){
  p1=m;
  p = p1.value;
  p1.value = p.replace(/-/g,"/");
  if ((p.length > 0) && (p.length < 6))
     {p1.value = p + "000000"; p = p1.value; p1.value = p.substr(0,6);}
  p = p1.value;
  if (p.indexOf('/') == -1)
	{p1.value = p.substr(0,2) + "/" + p.substr(2,2) + "/" + p.substr(4,4)}
  p = p1.value;
  if (p.charAt(5) != "/")
	{p1.value = p.substr(0,5) + "/" + p.substr(5,4)}
  p = p1.value;
  if (p.length == 8)
	{p1.value = p.substr(0,6) + "20" + p.substr(6,4)}
}


function editnum(m){
  p1=m;
  p = p1.value;
  if (p.indexOf(',') != -1) { p1.value = p.replace(/\,/g,"");  p = p1.value;};
  if (isNaN(p)) 
	{ alert("Not a number"); p1.value = ".00"; }
  else if (p.indexOf('.') == -1) 
	{ p1.value = p + ".00";}
  else if (p.length - p.indexOf('.') == 1 ) 
	{ p1.value = p + "00";}
  else if (p.length - p.indexOf('.') == 2 ) 
	{ p1.value = p + "0";}
  else if (p.length - p.indexOf('.') > 2 ) 
	{ p1.value = p.substr(0,(p.indexOf('.')+3));}
  else
	{};
}

function editint(m){
  p1=m;
  p = p1.value;
  if (p.indexOf(',') != -1) { p1.value = p.replace(/\,/g,"");  p = p1.value;};
  if (isNaN(p)) { alert("not a number"); p1.value = "0"; };
  if (p.indexOf('.') != -1) { p1.value = p.substr(0,p.indexOf('.')); };
}


function editAmt(m){
  total = 0;
  n=m.name;
  p1=m;
  p = p1.value;
  if (p.indexOf(',') != -1) { p1.value = p.replace(/\,/g,"");  p = p1.value;};
  if (isNaN(p)) { alert("not a number"); p1.value = ".00"; };
  if (p.indexOf('.') == -1) { p1.value = p + ".00";};
  totalAll();
}

function edit23(m){
  n=m.name;
  p1=m;
  p = p1.value;
  if (p.indexOf(',') != -1) { p1.value = p.replace(/\,/g,"");  p = p1.value;};
  if (isNaN(p)) { alert("Not a number"); p1.value = ".00"; };
  if (p.indexOf('.') == -1) { p1.value = p + ".00";};
  tot = parseFloat(document.getElementById('AMT1').value) / parseFloat(document.getElementById('AMT2').value);
  document.getElementById('TOT').innerHTML = tot.toFixed(0);
}

function totalAll(){
  total = 0;

  tot = parseFloat(document.getElementById('AMT1').value) * parseFloat(document.getElementById('PCT1').innerHTML) / 100.00;
  document.getElementById('TOT1').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT2').value) * parseFloat(document.getElementById('PCT2').innerHTML) / 100.00;
  document.getElementById('TOT2').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT3').value) * parseFloat(document.getElementById('PCT3').innerHTML) / 100.00;
  document.getElementById('TOT3').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT4').value) * parseFloat(document.getElementById('PCT4').innerHTML)  / 100.00;
  document.getElementById('TOT4').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT5').value) * parseFloat(document.getElementById('PCT5').innerHTML)  / 100.00;
  document.getElementById('TOT5').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT6').value) * parseFloat(document.getElementById('PCT6').innerHTML)  / 100.00;
  document.getElementById('TOT6').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT7').value) * parseFloat(document.getElementById('PCT7').innerHTML)  / 100.00;
  document.getElementById('TOT7').innerHTML = tot.toFixed(0);
  total = total + tot;

  tot = parseFloat(document.getElementById('AMT8').value) * parseFloat(document.getElementById('PCT8').innerHTML)  / 100.00;
  document.getElementById('TOT8').innerHTML = tot.toFixed(0);
  total = total + tot;

  document.getElementById('TOT').innerHTML = total.toFixed(0);


}

