﻿/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jim Stiles | www.jdstiles.com */
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  var all = "0";
  var one = document.autoSumForm.f21.value;
  if (one > "") { all++;}
  var two = document.autoSumForm.f22.value;
  if (two > "") { all++;}
  var thr = document.autoSumForm.f23.value;
  if (thr > "") { all++;}
  var fou = document.autoSumForm.f24.value;
  if (fou > "") { all++;}
  var fiv = document.autoSumForm.f25.value;
  if (fiv > "") { all++;}
  var six = document.autoSumForm.f26.value;
  if (six > "") { all++;}
  var sev = document.autoSumForm.f27.value;
  if (sev > "") { all++;}
  var eig = document.autoSumForm.f28.value;
  if (eig > "") { all++;}
  var nin = document.autoSumForm.f29.value;
  if (nin > "") { all++;}
  if (all > "3") {
  	document.getElementById("warning").innerHTML='<font color=red><span class=arial10>Enter values for three items only.</span></font>';
  	document.autoSumForm.total.value = 0;
  	stopCalc();return null;
  }
//  tot = document.autoSumForm.total.value;
  document.autoSumForm.total.value = (one * 1) + (two * 1) + (thr * 1) + (fou * 1) + (fiv * 1) + (six * 1) + (sev * 1) + (eig * 1) + (nin * 1);
 var tot = (one * 1) + (two * 1) + (thr * 1) + (fou * 1) + (fiv * 1) + (six * 1) + (sev * 1) + (eig * 1) + (nin * 1);
  if (tot > 10) {
  	document.getElementById("warning").innerHTML='<font color=red><span class=arial10>You have exceeded the maximum</span></font>';
  	stopCalc();return null;
  }
  if (tot < 10) {
  	document.getElementById("warning").innerHTML='<font color=006600><span class=rss_article>(Total cannot exeed &quot;10&quot;)</span></font>';
  	stopCalc();return null;
  }
  if (tot == 10) {
  	document.getElementById("warning").innerHTML='<font color=green><span class=arial10>(Submit now)</span></font>';
  	stopCalc();return null;
  }
}
function stopCalc(){
  clearInterval(interval);
}
