//*********
//* Screen variables
//*********

var requiredfield= new Array(21);
var datefield= new Array(21);
var numfield= new Array(21);
var screenfieldname= new Array(21);
var screeninitvalue= new Array(21);

var tablename;
var goNext;
var goPrev;
var goMenu;
var keepProcessing;
var insideSubmit = 0;
var formInUse = false;
var cursign= "$z,";

function setFocus()
{
 if(!formInUse) {
  document.KettleForm.myTXT_0.focus();
 }
}
function setFocus00()
{
 if(!formInUse) {
  document.KettleForm.myTXT_00.focus();
 }
}

function printWindow() { 
bV = parseInt(navigator.appVersion); 
if (bV >= 4) window.print(); 
} 
function fixNumber(the_number)
{
	if (the_number < 10)
	{
		the_number = "0" + the_number;
	}
	return the_number;
}
function stripSSN(mystr){
var b = "-";
mystr = mystr.replace(new RegExp(b, "g"), "")
var b = " ";
mystr = mystr.replace(new RegExp(b, "g"), "")
return mystr

}

function fixupdateslash() {
if (document.KettleForm.myTXT_00 == 'undefined') {
keepProcessing= 0;
self.alert("Please update " + screenfieldname[0] + ", it is a required field!");
return false;
}
if (document.KettleForm.myTXT_00.value == "") {
keepProcessing= 0;
// self.alert("Please update " + screenfieldname[0] + ", it is a required field!!");
return false;
}
if (document.KettleForm.myTXT_00.value == " ") {
keepProcessing= 0;
self.alert("Please update " + screenfieldname[0] + ", it is a required field!!!");
return false;
}
var mydt=document.KettleForm.myTXT_00;
var s = "z" + mydt.value;
   if (s.length != 7) {
       keepProcessing= 0;
       // self.alert("mydt length = " + s.length)
       alert("Start date must contain only 6 digits -- mmddyy. Please try again");
       return false;
       } 
// self.alert("s_string = "+ s);
mydtfixed=s.substring(1, 3)+ "/"+s.substring(3, 5)+ "/20"+s.substring(5);
// self.alert("s_substring = "+ s.substring(1, 3));
// self.alert("s_substring = "+ s.substring(3, 5));
// self.alert("s_substring = "+ s.substring(5));
// self.alert("before date value: "+ document.KettleForm.myTXT_0.value);
document.KettleForm.myTXT_0.value = mydtfixed
// self.alert("new date value: "+ document.KettleForm.myTXT_0.value);

var dt=document.KettleForm.myTXT_0;
if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[0] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_00.focus();
      return false;
   }
}
function checkselected_myTXT_2(newunit) {
user_input = newunit.options[newunit.selectedIndex].value;
// self.alert("myTXT_2 selected value = "+user_input);
if(user_input != ""){
  if(user_input != "None selected"){
    // self.alert("changing it now");
    document.getElementById('myTXT_3').selectedIndex = 0;
  }
}


}

function checkselected_myTXT_3(newgroup) {
user_input = newgroup.options[newgroup.selectedIndex].value;
// self.alert("myTXT_3 selected value = "+user_input);
if(user_input != ""){
  if(user_input != "None selected"){
    // self.alert("changing it now");
    document.getElementById('myTXT_2').selectedIndex = 0;
  }
}


}


function validaterate(num) {
// self.alert("validaterate before strip_currency"+ num);
num = num.toString().replace(/\$|\,/g,'');
// self.alert("validaterate after strip_currency"+ num);
if(isNaN(num))
   {alert("Sorry, the rate does not seem to be a number");
    }
if(num < 0)
   {alert("Sorry, the rate is less than zero.  Please fix this.");
    }
if(num > 25)
   {alert("Sorry, the rate is more than $25.00.  Please check this.");
    }

}
function formatCurrencyneg(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))
   {alert("Sorry, only currency and numeric characters allowed");
    num = "0";
    }
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function emailCheck(emailStr) {
// checks if the e-mail address is valid
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var matchArray = emailStr.match(emailPat);
if (matchArray == null) {
alert("Your email address seems incorrect or blank.  Please try again (check the '@' and '.'s in the email address)");
return false;
}
// make sure the IP address domain is valid
var IPArray = matchArray[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
if (IPArray != null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!")
return false;
      }
   }
}
return true;
}

function ContinueButtonClick()
   {
   debugtext= "Not updated";
   if (document.KettleForm.FLD_MODIFIED.value == 1) {
      debugtext= "Updated";
      }
   if (debugopen == 1) {
     mydebug.document.writeln('Inside ContinueButtonClick<br>');
     mydebug.document.writeln('Modified Status: ' + debugtext + '<br>');
                       }
    // Make sure that the required fields have all been filled in...
   keepProcessing= 1
   if (debugopen == 1) {
       mydebug.document.writeln('before validateForm - keepProcessing = ' + keepProcessing + '<br>');
   }

   validateForm();
      
    if (debugopen == 1) {
       mydebug.document.writeln('Done with Validate Form from ContinueButtonClick<br>');
       mydebug.document.writeln('After validateForm - keepProcessing = ' + keepProcessing + '<br>');
       }
  if (keepProcessing == 1){
     if (debugopen == 1) {mydebug.document.writeln('Going to submit form<br>');}
     document.KettleForm.hidactionflag.value = "2";
     document.KettleForm.submit();
     }

   }

   
function DeleteButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside DeleteButtonClick<br>');}
   var answer = confirm ("Do you want to DELETE this record? \n\nClick OK(Yes) to delete or \nCancel(No) to stop and return to this screen.");
   if (answer){
         self.alert("Delete Completed.");
         document.KettleForm.hidactionflag.value = "3";
	 document.KettleForm.submit();
               }
   }
      
function isNumericcur(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.,-$";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    if (s.length > 10) return false;  // 9 billion largest number accepted
    return true;
}
function isNumeric(s)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < s.length && IsNumber == true; i++) 
      { 
      Char = s.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    //self.alert(s);
    //self.alert(s.length);
    //self.alert(bag);
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        //self.alert(c);
        if (bag.indexOf(c) == -1) returnString += c;
        //self.alert(returnString);
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}


function textCounter(field, countfield, maxlimit) 
{
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}  
function calcKettleCash()  
{
var mynum=document.KettleForm.myTXT_01d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 01 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_01d.focus();
       return false;
   }
   var s2mynum = "z" + mynum.value + "z";
   var s3mynum = stripCharsInBag(s2mynum, cursign);
   var nKettleTotal = s3mynum - 0;
   var nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
var nKettleCashtot = nKettleTotal - 0;
    mynum=document.KettleForm.myTXT_05d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 05 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_05d.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
    mynum=document.KettleForm.myTXT_10d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 10 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_10d.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
    mynum=document.KettleForm.myTXT_20d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 20 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_20d.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
    mynum=document.KettleForm.myTXT_50d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 50 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_50d.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
    mynum=document.KettleForm.myTXT_100d;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 100 Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_100d.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
    mynum=document.KettleForm.myTXT_Othd;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but Other Bills, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_Othd.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
       nKettleTotal2 = Math.round (nKettleTotal);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash fields must be whole dollars only, no cents. (total not recalculated)");
      return false;
   }
nKettleCashtot = nKettleCashtot + nKettleTotal;
document.KettleForm.myTXT_6.value = formatCurrency(nKettleCashtot);
document.KettleForm.calccash.value = formatCurrency(nKettleCashtot);
}
function calcKettleCoin()  
{
var mynum=document.KettleForm.myTXT_01c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 01 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_01c.focus();
       return false;
   }
   var s2mynum = "z" + mynum.value + "z";
   var s3mynum = stripCharsInBag(s2mynum, cursign);
   var nKettleTotal = s3mynum - 0;
var nKettleCointot = nKettleTotal - 0;
    mynum=document.KettleForm.myTXT_05c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 05 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_05c.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
    mynum=document.KettleForm.myTXT_10c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 10 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_10c.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
    mynum=document.KettleForm.myTXT_25c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 25 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_25c.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
    mynum=document.KettleForm.myTXT_50c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 50 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_50c.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
    mynum=document.KettleForm.myTXT_100c;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but 100 coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_100c.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
    mynum=document.KettleForm.myTXT_Othc;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but Other coins, is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_Othc.focus();
       return false;
   }
       s2mynum = "z" + mynum.value + "z";
       s3mynum = stripCharsInBag(s2mynum, cursign);
       nKettleTotal = s3mynum - 0;
nKettleCointot = nKettleCointot + nKettleTotal;
document.KettleForm.myTXT_7.value = formatCurrency(nKettleCointot);
document.KettleForm.calccoin.value = formatCurrency(nKettleCointot);
}
function calcKettleTotal()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside calcKettleTotal<br>');}
   var mynum=document.KettleForm.myTXT_6;
   if (isNumericcur(mynum.value)==false){
       keepProcessing= 0;
       self.alert("Sorry, but " + screenfieldname[6] + ", is too large or does not appear to be a valid number.");
       document.KettleForm.myTXT_6.focus();
       return false;
   }
   var s2mynum = "z" + mynum.value + "z";
   var s3mynum = stripCharsInBag(s2mynum, cursign);
   var nKettleTotal = s3mynum - 0;
   // self.alert("nKettletot : "+ nKettleTotal);
   var nKettleTotal2 = Math.round (nKettleTotal);
   // self.alert("nKettletot2 : "+ nKettleTotal2);
   if (nKettleTotal != nKettleTotal2) {
      keepProcessing= 0;
      self.alert("Sorry, but the Cash field must be whole dollars only, no cents. (total not recalculated)");
  //  document.KettleForm.myTXT_6.focus();
      return false;
   }
   
   var mynum2=document.KettleForm.myTXT_7;
      if (isNumericcur(mynum2.value)==false){
          keepProcessing= 0;
          self.alert("Sorry, but " + screenfieldname[7] + ", is too large or does not appear to be a valid number.");
          document.KettleForm.myTXT_7.focus();
          return false;
   }
    // 	self.alert(mynum.value);
    // 	self.alert(cursign);
   
   
   var s2mynum = "z" + mynum2.value + "z";
   var s3mynum = stripCharsInBag(s2mynum, cursign);
   var nKettleTotal2 = s3mynum - 0;
   // self.alert(nKettleTotal2);
   
   var nKettleTotal3 = nKettleTotal+nKettleTotal2

   document.KettleForm.calccash.value = formatCurrency(nKettleTotal);
   document.KettleForm.calccoin.value = formatCurrency(nKettleTotal2);
   document.KettleForm.calckettle.value = formatCurrency(nKettleTotal3);
   document.KettleForm.calckettle2.value = formatCurrency(nKettleTotal3);
     //	self.alert(document.KettleForm.calckettle.value);

  } 
function SaveButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside SaveButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "0") {
       self.alert("No updates required.");
       }
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){mydebug.document.writeln('field_modified=1<br>');}
      
      //do the save action
      keepProcessing= 1
      if (debugopen == 1) {mydebug.document.writeln('before validateForm - keepProcessing = ' + keepProcessing + '<br>');}
      
      validateForm();
      if (debugopen == 1) {mydebug.document.writeln('After validateForm - keepProcessing = ' + keepProcessing + '<br>');}
      
      if (keepProcessing == 1){
	  document.KettleForm.FLD_MODIFIED.value = "0";
          document.KettleForm.hidactionflag.value = "1";
          self.alert("Save completed");
          document.KettleForm.submit();
          }
      }
   
   }function NextButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside NextButtonClick<br>');}
      
      //do the save action
      keepProcessing= 1
      if (debugopen == 1) {mydebug.document.writeln('before validateForm - keepProcessing = ' + keepProcessing + '<br>');}
      
      validateForm();
      if (debugopen == 1) {mydebug.document.writeln('After validateForm - keepProcessing = ' + keepProcessing + '<br>');}
      
      if (keepProcessing == 1){
	  document.KettleForm.FLD_MODIFIED.value = "0";
          document.KettleForm.hidactionflag.value = "5";
          //self.alert("Save completed, moving to Next record");
          document.KettleForm.submit();
          }
   
   }
function PreviousButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside PreviousButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){
          mydebug.document.writeln('field_modified=1<br>');
          }
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to the Previous screen or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
   	     }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       history.back();

   }

   }
function BackRefreshClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside PreviousButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){
          mydebug.document.writeln('field_modified=1<br>');
          }
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to the Previous screen or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       document.KettleForm.hidactionflag.value = "4";
       document.KettleForm.submit();

   }

   }

function MenuButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside MenuButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){
          mydebug.document.writeln('field_modified=1<br>');
          }
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Menu or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "menu.asp";
   }

   }
function ReportButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside ReportButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){
          mydebug.document.writeln('field_modified=1<br>');
          }
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Reports or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "reportmenu.asp";
   }

   }
function ScheduleButtonClick()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside ScheduleButtonClick<br>');}
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      if (debugopen == 1){
          mydebug.document.writeln('field_modified=1<br>');
          }
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Schedule or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "schedulemenu.asp";
   }

   }
   
function CheckMilTime(myvalue)
{
   //self.alert("MilTime check: starting with- " +myvalue)

   var re = /^([0-1]?[0-9]|2[0-3])[0-5][0-9]$/;
   if (!re.test(myvalue))
    {
      // self.alert (" error in MilTime check ");
       return false;
        }
    return true;
}


function calctotaltime()
   {
   if (debugopen == 1) {mydebug.document.writeln('Inside calcttltm<br>');}
   var mynumstart=document.KettleForm.myTXT_3;
  // self.alert("Starting with:" +mynumstart.value)
   if (mynumstart == null) {
       keepProcessing= 0;
       alert("You must enter a start time.  Please try again");
       return false;
       }
  if (CheckMilTime(document.KettleForm.myTXT_3.value)==false){
       keepProcessing= 0;
       alert("Start time does not appear to be in military time; ex: 1415 = 2:15 PM. Please try again");
       return false;
       }
   var s = "z" + mynumstart.value;
   if (s.length != 5) {
       keepProcessing= 0;
       // self.alert("calcttltmstart length = " + s.length)
       alert("Start time does not appear to be in military time; use 2 digit hours + 2 digit minutes ex: 14:15 = 2:15 PM. Please try again");
       return false;
       } 

   var mynumend=document.KettleForm.myTXT_4;
   if (mynumend == null) {
         self.alert("end time is null 1");
          keepProcessing= 0;
          return false;
       }
    if (mynumend.value == '') {
       // self.alert("end time is null 2");
       keepProcessing= 0;
       return false;
       }

   var s = "z" + mynumend.value;
   if (s.length = 0) {
       keepProcessing= 0;
       // alert("end time has zero length");
       return false;
       } 

   if (CheckMilTime(document.KettleForm.myTXT_4.value)==false){
          keepProcessing= 0;
          alert("End time does not appear to be in military time; ex: 1415 = 2:15 PM, so I can't calculate the total yet.");
          return false;
       }
   var s = "z" + mynumend.value;
   if (s.length != 5) {
       keepProcessing= 0;
       // self.alert("calcttltmstart length = " + s.length)
       alert("End time does not appear to be in military time; use 2 digit hours + : + 2 digit minutes ex: 14:15 = 2:15 PM. Please try again");
       return false;
       } 
       
   var mynum=document.KettleForm.myTXT_5;
      if (isNumeric(mynum.value)==false){
          keepProcessing= 0;
          self.alert("Sorry, but " + screenfieldname[5] + ", is too large or does not appear to be a valid number.");
         // document.KettleForm.myTXT_5.focus();
          return false;
      }
      if (mynumend.value > mynumstart.value)
      {
          keepProcessing= 1;
       }
          else
       {
          keepProcessing= 0;
          self.alert("Sorry, but the end time must be greater than the start time.");
          // document.KettleForm.myTXT_4.focus();
          return false;
   }
    // times are validated as Mil time.  Now split hours from minutes.
    // //  self.alert(mynumstart.value);
      var s = "z" + mynumstart.value;
    // self.alert(s);
      var starthour= s.charAt(1) + s.charAt(2);
      var startmin= s.charAt(3) + s.charAt(4);
     // self.alert("starthour "+ starthour);
     // self.alert("startmin "+ startmin);
      var s = "z" + mynumend.value;
    // self.alert(s);
      var endhour= s.charAt(1) + s.charAt(2);
      var endmin= s.charAt(3) + s.charAt(4);
     // self.alert("endhour "+ endhour);
     // self.alert("endmin "+ endmin);

	workerstarttime = new Date(2007, 11, 25, starthour, startmin, 0);
        // self.alert(workerstarttime);
	workerendtime = new Date(2007, 11, 25, endhour, endmin, 0);
        // self.alert(workerendtime);
        var mworkerstarttime = workerstarttime.getTime();
        // self.alert("mworkerstarttime "+ mworkerstarttime);
        var mworkerendtime = workerendtime.getTime();
        // self.alert("mworkerendtime "+ mworkerendtime);


	mdifference = (mworkerendtime - mworkerstarttime);
        // self.alert("mdifference"+ mdifference);
        hour_divisor = mdifference%(1000 * 60 * 60 * 24);

	fcalchours = Math.floor(mdifference/(1000 * 60 * 60));
	// self.alert("fcalchours = "+ fcalchours);
	
	minutes_divisor = hour_divisor%(1000 * 60 * 60);
	calcminutes = Math.round(minutes_divisor/(1000 * 60));
	// self.alert(calcminutes);
   // 	self.alert("hours: "+ fcalchours + "  Min: "+ calcminutes);
     	minpart=Math.round((calcminutes/60)*100)/100;  // figure out the portion of an hour
   //  	self.alert("calculated minpart: "+ minpart);
     	calctotal = fcalchours+ minpart;
     	// self.alert("calculated total: "+ calctotal);


        inttotaltime = (calctotal- Number(mynum.value));
        // self.alert("Subtracting mynum: "+ mynum.value + " making new total "+ inttotaltime);
       
   //self.alert("total time second check- " +inttotaltime.value);
   if(inttotaltime < 0)
      {alert("Please check the time calculations, the total time is less than zero.  Please fix this.");
      }
   if(inttotaltime > 24)
      {alert("Please check the time calculations, the total time is more than 24 hours.  Please check this.");
      }
   
   document.KettleForm.myTXT_10Tot.value = inttotaltime;
     //  	self.alert(document.KettleForm.myTXT_10Tot.value);

   // self.alert("Starting checks");
   A = document.KettleForm.emprate.value;
   B = document.KettleForm.myTXT_10Tot.value;
   A = Number(A);
   B = Number(B);
   C = (A * B);
   // self.alert("new cost: "+ C);
   document.KettleForm.myTXT_11Cost.value = formatCurrency(C);
   
   // self.alert("Starting checks2");
   D = document.KettleForm.emptax.value;
   D = Number(D);
   C = Number(C);
   E = (C * D);
   // self.alert("new tax: "+ E);
   F = E.toFixed(2);
   // self.alert("new tax2: "+ F);

   document.KettleForm.myTXT_12Tax.value = formatCurrency(F);
   
   F = Number(F);
   G = (C + F);
   document.KettleForm.myTXT_13Total.value = formatCurrency(G);

   
  }

function PrintappClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and print the application or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "printapp.asp";
   }
   }  
function adjustmentfinddlwClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Adjustmentfinddlw or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "adjustmentfinddlw.asp";
   }
   }  
   
function kettlefinddlwClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Kettlefinddlw or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "kettlefinddlw.asp";
   }
   }  

function kettlefindldwClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Kettlefindldw or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "kettlefindldw.asp";
   }
   }  
function kettlefindwdlClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Kettlefindwdl or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "kettlefindwdl.asp";
   }
   }  
function locationfindClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Locationfind or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "locationfind.asp";
   }
   }  
function workerfindClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Workerfind or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "workerfind.asp";
   }
   }  
function routefindClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to Routefind or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "routefind.asp";
   }
   }  
 function menuClick()
   {
   if (document.KettleForm.FLD_MODIFIED.value == "1") {
      var answer = confirm ("Do you want to save your changes first? \n\nClick OK(Yes) to abort changes and move to the Menu or \nCancel(No) to stop and return to this screen.");
   	  if (answer){
   	     document.KettleForm.FLD_MODIFIED.value = "0";
      }
   }
   if (document.KettleForm.FLD_MODIFIED.value == "0"){
       location.href= "menu.asp";
   }
   }  



function validateForm() {
//call this from update, next, previous buttons.
var checkreq;


if (debugopen == 1) {
  mydebug.document.writeln('Inside validateForm<br>');
  debugtext= "requiredfield[0] = " + requiredfield[0];
  mydebug.document.writeln(debugtext + '<br>');
  debugtext= "requiredfield[1] = " + requiredfield[1];
  mydebug.document.writeln(debugtext + '<br>');
  debugtext= "requiredfield[2] = " + requiredfield[2];
  mydebug.document.writeln(debugtext + '<br>');
  debugtext= "requiredfield[3] = " + requiredfield[3];
  mydebug.document.writeln(debugtext + '<br>');
  debugtext= "requiredfield[4] = " + requiredfield[4];
  mydebug.document.writeln(debugtext + '<br>');
}

checkreq=requiredfield[0];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq0 is 1<br>');}
   if (document.KettleForm.myTXT_0.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[0] + ", it is a required field!");
      document.KettleForm.myTXT_0.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with checkreq0<br>');}

checkreq=requiredfield[1];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq1 is 1<br>');}
   if (document.KettleForm.myTXT_1.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[1] + ", it is a required field!");
      document.KettleForm.myTXT_1.focus();
      return false;
   }
}
checkreq=requiredfield[2];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq2 is 1<br>');}
   if (document.KettleForm.myTXT_2.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[2] + ", it is a required field!");
      document.KettleForm.myTXT_2.focus();
      return false;
   }
}
checkreq=requiredfield[3];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq3 is 1<br>');}
   if (document.KettleForm.myTXT_3.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[3] + ", it is a required field!");
      document.KettleForm.myTXT_3.focus();
      return false;
   }
}
checkreq=requiredfield[4];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq4 is 1<br>');}
   if (document.KettleForm.myTXT_4.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[4] + ", it is a required field!");
      document.KettleForm.myTXT_4.focus();
      return false;
   }
}
checkreq=requiredfield[5];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq5 is 1<br>');}
   if (document.KettleForm.myTXT_5.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[5] + ", it is a required field!");
      document.KettleForm.myTXT_5.focus();
      return false;
   }
}
checkreq=requiredfield[6];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq6 is 1<br>');}
   if (document.KettleForm.myTXT_6.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[6] + ", it is a required field!");
      document.KettleForm.myTXT_6.focus();
      return false;
   }
}
checkreq=requiredfield[7];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq7 is 1<br>');}
   if (document.KettleForm.myTXT_7.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[7] + ", it is a required field!");
      document.KettleForm.myTXT_7.focus();
      return false;
   }
}
checkreq=requiredfield[8];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq8 is 1<br>');}
   if (document.KettleForm.myTXT_8.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[8] + ", it is a required field!");
      document.KettleForm.myTXT_8.focus();
      return false;
   }
}
checkreq=requiredfield[9];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq9 is 1<br>');}
   if (document.KettleForm.myTXT_9.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[9] + ", it is a required field!");
      document.KettleForm.myTXT_9.focus();
      return false;
   }
}
checkreq=requiredfield[10];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq10 is 1<br>');}
   if (document.KettleForm.myTXT_10.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[10] + ", it is a required field!");
      document.KettleForm.myTXT_10.focus();
      return false;
   }
}
checkreq=requiredfield[11];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq11 is 1<br>');}
   if (document.KettleForm.myTXT_11.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[11] + ", it is a required field!");
      document.KettleForm.myTXT_11.focus();
      return false;
   }
}
checkreq=requiredfield[12];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq12 is 1<br>');}
   if (document.KettleForm.myTXT_12.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[12] + ", it is a required field!");
      document.KettleForm.myTXT_12.focus();
      return false;
   }
}
checkreq=requiredfield[13];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq13 is 1<br>');}
   if (document.KettleForm.myTXT_13.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[13] + ", it is a required field!");
      document.KettleForm.myTXT_13.focus();
      return false;
   }
}
checkreq=requiredfield[14];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq14 is 1<br>');}
   if (document.KettleForm.myTXT_14.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[14] + ", it is a required field!");
      document.KettleForm.myTXT_14.focus();
      return false;
   }
}
checkreq=requiredfield[15];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq15 is 1<br>');}
   if (document.KettleForm.myTXT_15.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[15] + ", it is a required field!");
      document.KettleForm.myTXT_15.focus();
      return false;
   }
}
checkreq=requiredfield[16];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq16 is 1<br>');}
   if (document.KettleForm.myTXT_16.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[16] + ", it is a required field!");
      document.KettleForm.myTXT_16.focus();
      return false;
   }
}
checkreq=requiredfield[17];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq17 is 1<br>');}
   if (document.KettleForm.myTXT_17.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[17] + ", it is a required field!");
      document.KettleForm.myTXT_17.focus();
      return false;
   }
}
checkreq=requiredfield[18];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq18 is 1<br>');}
   if (document.KettleForm.myTXT_18.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[18] + ", it is a required field!");
      document.KettleForm.myTXT_18.focus();
      return false;
   }
}
checkreq=requiredfield[19];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq19 is 1<br>');}
   if (document.KettleForm.myTXT_19.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[19] + ", it is a required field!");
      document.KettleForm.myTXT_19.focus();
      return false;
   }
}
checkreq=requiredfield[20];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq20 is 1<br>');}
   if (document.KettleForm.myTXT_20.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[20] + ", it is a required field!");
      document.KettleForm.myTXT_20.focus();
      return false;
   }
}
checkreq=requiredfield[21];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq21 is 1<br>');}
   if (document.KettleForm.myTXT_21.value == "") {
      keepProcessing= 0;
      self.alert("Please update " + screenfieldname[21] + ", it is a required field!");
      document.KettleForm.myTXT_21.focus();
      return false;
   }
}
/*
***************
**  Now check for any date validation needed
***************
*/

checkreq=datefield[0];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq0 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_0;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[0] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_0.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck0<br>');}

checkreq=datefield[1];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq1 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_1;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[1] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_1.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck1<br>');}
checkreq=datefield[2];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq2 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_2;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[2] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_2.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck2<br>');}
checkreq=datefield[3];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq3 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_3;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[3] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_3.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck3<br>');}
checkreq=datefield[4];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq4 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_4;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[4] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_4.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck4<br>');}
checkreq=datefield[5];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq5 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_5;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[5] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_5.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck5<br>');}
checkreq=datefield[6];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq6 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_6;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[6] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_6.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck6<br>');}
checkreq=datefield[7];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq7 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_7;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[7] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_7.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck7<br>');}
checkreq=datefield[8];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq8 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_8;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[8] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_8.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck8<br>');}
checkreq=datefield[9];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq9 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_9;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[9] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_9.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck9<br>');}
checkreq=datefield[10];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq10 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_10;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[10] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_10.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck10<br>');}
checkreq=datefield[11];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq11 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_11;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[11] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_11.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck11<br>');}
checkreq=datefield[12];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq12 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_12;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[12] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_12.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck12<br>');}
checkreq=datefield[13];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq13 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_13;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[13] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_13.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck13<br>');}
checkreq=datefield[14];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq14 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_14;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[14] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_14.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck14<br>');}
checkreq=datefield[15];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq15 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_15;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[15] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_15.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck15<br>');}
checkreq=datefield[16];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq16 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_16;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[16] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_16.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck16<br>');}
checkreq=datefield[17];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq17 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_17;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[17] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_17.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck17<br>');}

checkreq=datefield[18];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq18 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_18;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[18] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_18.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck18<br>');}

checkreq=datefield[19];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq19 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_19;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[19] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_19.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck19<br>');}

checkreq=datefield[20];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq20 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_20;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[20] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_20.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck20<br>');}

checkreq=datefield[21];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq21 is 1 for DateCheck<br>');}
   var dt=document.KettleForm.myTXT_21;
   if (isDate(dt.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[21] + ", does not appear to be a valid date.");
      document.KettleForm.myTXT_21.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck21<br>');}

/*
***************
**  Now check for any numeric validation needed
***************
*/

checkreq=numfield[0];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq0 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_0;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[0] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_0.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck0<br>');}

checkreq=numfield[1];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq1 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_1;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[1] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_1.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck1<br>');}

checkreq=numfield[2];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq2 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_2;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[2] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_2.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck2<br>');}

checkreq=numfield[3];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq3 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_3;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[3] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_3.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck3<br>');}

checkreq=numfield[4];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq4 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_4;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[4] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_4.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck4<br>');}

checkreq=numfield[5];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq5 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_5;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[5] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_5.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck5<br>');}

checkreq=numfield[6];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq6 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_6;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[6] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_6.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck6<br>');}

checkreq=numfield[7];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq7 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_7;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[7] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_7.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck7<br>');}

checkreq=numfield[8];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq8 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_8;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[8] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_8.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck8<br>');}

checkreq=numfield[9];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq9 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_9;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[9] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_9.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck9<br>');}

checkreq=numfield[10];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq10 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_10;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[10] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_10.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck10<br>');}

checkreq=numfield[11];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq11 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_11;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[11] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_11.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck11<br>');}

checkreq=numfield[12];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq12 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_12;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[12] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_12.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck12<br>');}

checkreq=numfield[13];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq13 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_13;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[13] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_13.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck13<br>');}

checkreq=numfield[14];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq14 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_14;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[14] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_14.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck14<br>');}
 
checkreq=numfield[15];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq15 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_15;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[15] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_15.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck15<br>');}
checkreq=numfield[16];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq16 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_16;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[16] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_16.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck16<br>');}
checkreq=numfield[17];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq17 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_17;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[17] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_17.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck17<br>');}

checkreq=numfield[18];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq18 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_18;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[18] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_18.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck18<br>');}

checkreq=numfield[19];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq19 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_19;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[19] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_19.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck19<br>');}

checkreq=numfield[20];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq20 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_20;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[20] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_20.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck20<br>');}

checkreq=numfield[21];
if (checkreq == 1) {
   if (debugopen == 1) {mydebug.document.writeln('checkreq21 is 1 for NumCheck<br>');}
   var mynum=document.KettleForm.myTXT_21;
   if (isInteger(mynum.value)==false){
      keepProcessing= 0;
      self.alert("Sorry, but " + screenfieldname[21] + ", is too large or does not appear to be a valid number.");
      document.KettleForm.myTXT_21.focus();
      return false;
   }
}
if (debugopen == 1) {mydebug.document.writeln('Done with Datecheck21<br>');}

}

function calcSetModified(nFieldIndex){
	document.KettleForm.FLD_MODIFIED.value = "1";
	if (debugopen == 1) {
	//mydebug.document.writeln('calcSetModified<br>');
	//debugtext= "tablename = " + tablename;
	//mydebug.document.writeln(debugtext + '<br>');
	//debugtext= "screenfieldname[0] = " + screenfieldname[0];
	//mydebug.document.writeln(debugtext + '<br>');
	//debugtext= "screenfieldname[1] = " + screenfieldname[1];
	//mydebug.document.writeln(debugtext + '<br>');
	//debugtext= "screenfieldname[2] = " + screenfieldname[2];
	//mydebug.document.writeln(debugtext + '<br>');
	//debugtext= "screenfieldname[3] = " + screenfieldname[3];
	//mydebug.document.writeln(debugtext + '<br>');
	//debugtext= "screenfieldname[4] = " + screenfieldname[4];
	//mydebug.document.writeln(debugtext + '<br>');
	debugtext= "nFieldIndex = " + nFieldIndex;
	mydebug.document.writeln(debugtext + '<br>');
	var sFieldName = screenfieldname[nFieldIndex];
	debugtext= "sFieldName = " + sFieldName;
	mydebug.document.writeln(debugtext + '<br>');
	if (nFieldIndex == 0) {
	debugtext= document.getElementById("myTXT_0");
	mydebug.document.writeln("New value for myTXT_0 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 1) {
	debugtext= document.getElementById("myTXT_1");
	mydebug.document.writeln("New value for myTXT_1 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 2) {
	debugtext= document.getElementById("myTXT_2");
	mydebug.document.writeln("New value for myTXT_2 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 3) {
	debugtext= document.getElementById("myTXT_3");
	mydebug.document.writeln("New value for myTXT_3 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 4) {
	debugtext= document.getElementById("myTXT_4");
	mydebug.document.writeln("New value for myTXT_4 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 5) {
	debugtext= document.getElementById("myTXT_5");
	mydebug.document.writeln("New value for myTXT_5 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 6) {
	debugtext= document.getElementById("myTXT_6");
	mydebug.document.writeln("New value for myTXT_6 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 7) {
	debugtext= document.getElementById("myTXT_7");
	mydebug.document.writeln("New value for myTXT_7 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 8) {
	debugtext= document.getElementById("myTXT_8");
	mydebug.document.writeln("New value for myTXT_8 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 9) {
	debugtext= document.getElementById("myTXT_9");
	mydebug.document.writeln("New value for myTXT_9 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 10) {
	debugtext= document.getElementById("myTXT_10");
	mydebug.document.writeln("New value for myTXT_10 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 11) {
	debugtext= document.getElementById("myTXT_11");
	mydebug.document.writeln("New value for myTXT_11 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 12) {
	debugtext= document.getElementById("myTXT_12");
	mydebug.document.writeln("New value for myTXT_12 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 13) {
	debugtext= document.getElementById("myTXT_13");
	mydebug.document.writeln("New value for myTXT_13 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 14) {
	debugtext= document.getElementById("myTXT_14");
	mydebug.document.writeln("New value for myTXT_14 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 15) {
	debugtext= document.getElementById("myTXT_15");
	mydebug.document.writeln("New value for myTXT_15 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 16) {
	debugtext= document.getElementById("myTXT_16");
	mydebug.document.writeln("New value for myTXT_16 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 17) {
	debugtext= document.getElementById("myTXT_17");
	mydebug.document.writeln("New value for myTXT_17 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 18) {
	debugtext= document.getElementById("myTXT_18");
	mydebug.document.writeln("New value for myTXT_18 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 19) {
	debugtext= document.getElementById("myTXT_19");
	mydebug.document.writeln("New value for myTXT_19 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 20) {
	debugtext= document.getElementById("myTXT_20");
	mydebug.document.writeln("New value for myTXT_20 = " + debugtext.value + '<br>');}
	if (nFieldIndex == 21) {
	debugtext= document.getElementById("myTXT_21");
	mydebug.document.writeln("New value for myTXT_21 = " + debugtext.value + '<br>');}
	                        }	
}


//------------------------------------------------------------------
//-- Functions to Set/Reset the background color of current field --
//------------------------------------------------------------------
	function setFieldBGColor (Field)
	{
	Field.style.backgroundColor='#FFFFC6';
        //if (debugopen == 1) {mydebug.document.writeln('Setting backgroundcolor<br>');}
	}
	function resetFieldBGColor (Field) 
	{
	Field.style.backgroundColor='#FFFFFF';
	//if (debugopen == 1) {mydebug.document.writeln('Reset backgroundcolor<br>');}
	}
//------------------------------------------------------------------
//-- Function for setting focus to Current Field
//------------------------------------------------------------------
	function setCurField (Field, sFieldName, sFieldType, nFieldIndex){
		//	Set Background color
		formInUse = true;
		if (sFieldType != '5' && sFieldType != '6')
			{
			setFieldBGColor	(Field);
			 //if (debugopen == 1) {mydebug.document.writeln('return from SetFieldBGColor<br>');}
			 }
		}