// ===================================================================
// Author: Matt Kruse <mkruse@netexpress.net>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. Instead,
// please just point to my URL to ensure the most up-to-date versions
// of the files. Thanks.
// ===================================================================

// -------------------------------------------------------------------
// TabNext()
// Function to auto-tab phone field
// Arguments:
//   obj :  The input object (this)
//   event: Either 'up' or 'down' depending on the keypress event
//   len  : Max length of field - tab when input reaches this length
//   next_field: input object to get focus after this one
// -------------------------------------------------------------------
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				if (next_field) {
					next_field.focus();
					}
				}
			}
		}
	}



function cf(form,pcid,holenum,total_holes) {
	//alert(form+':  '+holenum+' - '+pcid);
	//alert(total_holes);
   //Set up arrays
   holescore = new Array(18);
   var totalscore = 0;
   var frontscore = 0;
   var backscore = 0;


   //Initialize the array and capture the inputs for score
   for (i=1;i < eval(total_holes+1);i++) {
      holescore[i] = 0;
   }
  
   for (i=1;i<10;i++){    
      var holescorevalue=form+".HOLE_"+pcid+"_"+i+".value";

      if (eval(holescorevalue) != "") {
         holescore[i] = eval(holescorevalue);
      }
      else {
         holescore[i] = 0;
      }
      frontscore=frontscore + parseInt(holescore[i]);
   }
	
	if (total_holes == 18) {
		for (i=10;i<19;i++){    
			var holescorevalue=form+".HOLE_"+pcid+"_"+i+".value";
	
			if (eval(holescorevalue) != "") {
				holescore[i] = eval(holescorevalue);
			}
			else {
				holescore[i] = 0;
			}
			backscore=backscore + parseInt(holescore[i]);
		}
	}
//	alert(frontscore);

/*
   for (i=1;i<eval(18+1);i++){ 
      var holescorevalue=form+".HOLE_"+pcid+"_"+i+".value";
      
      if (eval(holescorevalue) != "") {
         holescore[i] = eval(holescorevalue);
      }
      else {
         holescore[i] = 0;
      }
      totalscore=totalscore + parseInt(holescore[i]);
   }
*/
   eval('SCORE_CARD.frontscore_'+pcid).value=frontscore;
   eval('SCORE_CARD.backscore_'+pcid).value=backscore;
   eval('SCORE_CARD.totalscore_'+pcid).value=frontscore + backscore;

}