




// DETERMINE BROWSER BRAND
var isNav = false;
var isIE  = false;
var tempscore = '';

// ASSUME IT'S EITHER NETSCAPE OR MSIE
if (navigator.appName == "Netscape") {
    isNav = true;
}
else {
    isIE = true;
}

function sendinfomm(){
document.myform.usersuffix.value = document.myform.multisuffixes.value
document.myform.username.value	= document.myform.GolferNumber.value
document.myform.submit()
}
function SubmitClubentry(mynumb1){
var e = window.event.keyCode;

 if(e == 13) {
			
			sendinfonew();

}
}
function Logout(){
mypage = document.myform.logoutflag.value + '&logoutflag=T'

location = mypage
//document.myform.submit();
}
function sendinfonew(){
	 
document.myform.submit();	

}

// GET CURRENTLY SELECTED LANGUAGE
function gettourney(myans){
	if (myans == 1) {
		document.myform.TourneyString.value = 'TOURNAMENT ROUND';
			document.myform.TourneyRound.value = 'Y';
	}
	else{
		document.myform.TourneyRound.value = 'N';
	}
	document.myform.Status.value = 'NeedAnswer';
	document.myform.submit();
}





function checkautokey(mynumb1){
	//alert(mynumb1)
	
	mynumb = document.myform.AutoNumb.value;

	if (isNav == true){
		
		var e = parseInt(mynumb1);
		nsformname = ''
		if (mynumb == 1) {
			nsformname = 'document.myform.Score2.value'
		}
		else if(mynumb == 2) {
			nsformname = 'document.myform.slope1.value'
		}
		else if(mynumb == 3) {
			nsformname = 'document.myform.cr1.value'
		}
		else if(mynumb == 12) {
			nsformname = 'document.myform.day.value'
		}
		else if(mynumb == 14) {
			nsformname = mynumb1
		}
		else if(mynumb == 16) {
			nsformname = 'document.myform.golfernumb.value'
		}
		else if(mynumb == 20) {
			if (document.myform.NumbOfScores.value > 0) {
				nsformname = 'document.myform.ScoreNumb.value'
			}
						
		}
		else if(mynumb == 22) {
			nsformname = 'document.myform.club1.value'
		}
		//alert(nsformname)
	}
	else{
		var e = window.event.keyCode;
	}
	
	
	if (e == 27) {
		self.close()
	}
	//scores
	if (mynumb == 1)  { 
		if (isNav == true){
		nspostnumbvalidate(nsformname)
		return;
		}
	  	if (e == 101 || e == 69) {
			e = checkKey(e,1);
			erasescore();
		}
		else if(e == 13) {
			e = checkKey(e,1);
			gotscore(1);
		}
		else if (document.myform.PostStatus.value == "O" && (e == 80 || e == 112)) {
			test(0);
		}
		else {
			e = checkKey(e,1);
		}

	//slope
	}
	else if (mynumb == 2) { 
		
	  	if (e == 101 || e == 69) {
			e = checkKey(1,1);
			checkslope(3);
		}
		else if(e == 13) {
		
			checkslope(1);
		}
		
		else if (e == 110 || e == 78) {

			checkslope(2);	
		}
		else{
			e = checkKey(e,1);
		}

	}
	//cr
	else if (mynumb == 3) { 

	  	if (e == 101 || e == 69) {
			e = checkKey(1,1);
			checkcr(2);
		}
		else if (e == 13) {
			getslope();
		}
		else {
			e = checkKey(1,1);
				
		}

	}
	//tourney round
	else if (mynumb == 4) { 
		if (e == 121 || e == 89) {
		
			
			gotanswer(1);
		}
		else if (e == 110 || e == 78) {
		
			gotanswer(2);	
		}

	}
	//tourney round
	else if (mynumb == 5) {

		if (e == 121 || e == 89) {		
			
			gettourney(1);
		}
		else if (e == 110 || e == 78) {
		
			gettourney(2);
		}

	}
	//did you play your course your tee
	else if (mynumb == 6) {
		var max = 48;
		var max1 = parseInt(document.myform.NumbOfCourses.value);
		max = max + max1;
		if (e > 48 && e <= max) {
			i = e - 48;
			gotcourse(i);
		}
		else if (e == 110 || e == 78) {
			nocourse();	
		
		}
	}	
	//did you play your club
	else if (mynumb == 7) {
		if (e == 121 || e == 89) {
			
			gotclubq(1);
		}
		else if (e == 110 || e == 78) {
			gotclubq(2);	
		}
	}
	//which tee
	else if (mynumb == 8) { 
		
		var max = 48;
		var max1 = parseInt(document.myform.NumbOfTees.value);
		max = max + max1;
		
		
		if (e > 48 && e <= max) {
			i = e - 49;
			
			if (document.myform.NumbOfTees.value == 1) {
				gottee(document.myform.iTee.value);
			}
			else{
				
				gottee(document.myform.iTee[i].value);
			}
		}
		else if (e == 110 || e == 78) {
			notee();	
		}

	}
	//PICKED WHICH 9 FOR 9 HOLERS
	else if (mynumb == 9) { 
		if (e == 49){
			gotnine(1);
		}	
		else if (e == 50) {
			gotnine(2);
		}	

	}
	//Did you play today
	else if (mynumb == 10) { 
		var i = parseInt(document.myform.icount.value);

		
		if (e == 121 || e == 89) {
			
			datetoday(i + 1);
		}
		else if (e == 110 || e == 78) { 
			datetoday(i + 2);	
		}

	}
	//select month
	else if (mynumb == 11) { 
		
		var i = 0;

		if (e > 48 && e < 58) {
		 	i = e - 48
		}
		else if (e == 46) {
			i = 10;
		}
		else if (e == 48) {
			i = 11;
		}
		else if (e == 103 || e == 71) {
			i = 12;

		} 	
		getmonth(i);
	
	}
	//select month	
	else if (mynumb == 12) { 
		if (e == 101 || e == 69) { 
			e = checkKey(1,1);
			eraseday();
		}
		else if (e == 13) {
			getday();
		}
		else{
			e = checkKey(1,1);
		}
	}	
	//strokes allowed message
	else if (mynumb == 13) { 
		
		if (document.myform.GroupHoles.value == 18) {
			if (e > 48 && e < 52) {
				i = e - 49;
				gotholes(i);
			}
		}
		else{
			gotholes(3);
		}

	}
	else if (mynumb == 14) {
		e = checkKey(1,1);
	}	
	//post new or erase
	else if (mynumb == 15) { 
		if (e == 80 || e == 112) {
			e = checkKey(1,1);
			alldone(1);
		}
		else if (e == 69 || e == 101) {
			alldone(2);
		}
	}
	else if (mynumb == 16) {
		if (e == 112 || e == 80) {
			e = checkKey(1,1);
			checkgolfer(1);
		}
		else{
			e = checkKey(1,1);
		}
	}
	//else if (mynumb == 17) {
	//	if (e == 69 || e == 101) {
	//		tryagain();
	//	}
	//	else if (e > 48 && e < 58) {
	//			i = e - 49;
			
	//		myfun8(i);
	//	}
	//}
	else if (mynumb == 18) {
		if (e == 13) {
			notagain2(2);
		}

	}
	else if (mynumb == 19) {
		if (e == 13) {
			notagain2(1);
		}



	}
	else if (mynumb == 20) {
		
		if (e == 80 || e == 112) {
			eraseascore(1);
		}
		else if (e == 13) {
			
			eraseascore(2);
		}	
		else{
			
			e = checkKey(1,1);	
			if  (document.myform.NumbOfScores.value > 0) {
			tempscore = document.myform.ScoreNumb.value;
			}	
		}
	}
	//which state
	else if (mynumb == 21) { 
		max = parseInt(document.myform.NumbOfStates.value) + 48;
		
		
		if (e > 48 && e <= max) {
			i = e - 49;
			
			
			if (document.myform.NumbOfStates.value == 1) {
				gotstate(document.myform.iState.value);
			}
			else{
				gotstate(document.myform.iState[i].value);
			}
		}
		else if (e == 110 || e == 78) { 
			nocourse();	
		}
	}
	else if (mynumb == 22) {
		
		if (e == 49) {
			noawaycourse();
		}
		else if (e == 13) {
			
			GotAwayClub();
				
		}
	}
	//did you play your course your tee
	else if (mynumb == 23) { 
		max = parseInt(document.myform.NumbOfAwayCourses.value) + 48

		if (e > 48 && e <= max) {
			i = e - 48;
			gotawaycourse(i);
		}
		else if (e == 110 || e == 78) { 
			nocourse();	
		}
	}
	//which away tee	
	else if (mynumb == 24) { 
		
		max = parseInt(document.myform.NumbOfAwayTees.value) + 48
		
		if (e > 48 && e <= max) {
			i = e - 49;
			if (document.myform.NumbOfAwayTees.value == 1) {
				gotawaytee(document.myform.iTee.value);
			}
			else{
				gotawaytee(document.myform.iTee[i].value);
			}
		}
		else if (e == 110 || e == 78) { 
			nocourse();	
		}
	}
	//strokes allowed message
	else if (mynumb == 25) { 
		
		if (document.myform.GroupHoles.value == 18) {
			if (e > 48 && e < 52) {
				i = e - 49;
				gotholes(i);
			}
		}
		else{
			gotholes(3);
		}
	}
	//PICKED WHICH 9 FOR 9 HOLERS
	else if (mynumb == 26) { 
		if (e == 49) {
			gotawaynine(1);
		}	
		else if (e == 50) {
			gotawaynine(2);
		}	
	



	}
	
	

}
function gotawaynine(mynumb){
	document.myform.NineNumber.value = mynumb;
	document.myform.HolesNumber.value = mynumb;
	//away tee for 9 holes
		document.myform.awayteeready.value = 'Y'
		document.myform.Status.value = "NeedAwayDate";
		document.myform.PlayerStatus.value = "";	
	
	document.myform.submit();
}



function gotawaytee(mynumb){
	
	document.myform.AwayTeeNumber.value = mynumb;
	
		if (document.myform.GroupHoles.value == '18'){
				//away tee 
				document.myform.awayteeready.value = 'Y'
			
				document.myform.Status.value = 'NeedAwayDate';
				document.myform.PlayerStatus.value = '';	
				
			document.myform.NineNumber.value = 0;
		}
		else{
			document.myform.Status.value = 'NEEDAWAYNINE';
				
		}
	
		
	
	document.myform.submit();
}


function gotawaycourse(mynumb){
	

	if (document.myform.NumbOfAwayCourses.value != 1) {
		var str=document.myform.AwayCourseName[mynumb - 1].value;
		document.myform.AwayCourse.value =  str.substr(3,str.length);
	}
	else{
		var str=document.myform.AwayCourseName.value;
		document.myform.AwayCourse.value =  str.substr(3,str.length);
	}
	
	
	
	document.myform.Course.value = document.myform.AwayCourse.value;
	
	document.myform.AwayCourseNumber.value = mynumb;
	document.myform.Status.value = 'NEEDAWAYTEE';
	
	document.myform.submit();
}


function GotAwayClub(){
	
	document.myform.AwayClubNumb.value = document.myform.CourseName1.value;
	document.myform.Status.value = 'NeedAwayCourse';
	document.myform.submit();
}


function noawaycourse(){
		
		if (document.myform.Score.value == ''){
		
			document.myform.Status.value = 'NeedScore';
			document.myform.PlayerStatus.value = 'NeedScore';
		}
		else{
			document.myform.Status.value = 'AwayCr';
			document.myform.PlayerStatus.value = '';
			
		}
		document.myform.AwayClubNumb.value = '99999';
		 document.myform.PlayerClubName.value = 'Unknown Away Club';
		document.myform.submit();
}

function gotstate(mystate){
	
	document.myform.StateId.value = mystate + '';
	document.myform.Status.value = 'NeedAwayClub';
	document.myform.submit();
	
}


function eraseascore(mynumb){
	
	if (mynumb == 1) {
		document.myform.Club.value = '';
		document.myform.Score.value = '';
       		document.myform.Course.value = '';
 		document.myform.Date.value = '';
    		document.myform.TeeName.value = '';
 		document.myform.PlayerClubName.value = '';
    		document.myform.Cr.value = '';
  		document.myform.TourneyString.value = '';
    		document.myform.Slope.value = '';
		document.myform.Status.value = document.myform.hbh.value;
		document.myform.GroupHoles.value = document.myform.StartGroupHoles.value;
		
		
		document.myform.submit();
	}
	//erase scores	
	else if (mynumb == 2) { 
		
		document.myform.DATEYESNO.disabled = true;
		if (document.myform.ScoreNumb.value > 0) {
			mymessage = '';
			if (document.myform.NumbOfScores.value > 1) {
				mymessage = document.myform.ScoreNumb.value;
				
				var mytop = parseInt(document.myform.NumbOfScores.value) - 1
				for (i = 0; i <= mytop ; i++){
					
					var str= document.myform.WebScores[i].value;
					var pos=str.indexOf(':');

					if (pos>=0){
						
								
						if (str.substring(0,pos) == document.myform.ScoreNumb.value) {
							mymessage = document.myform.WebScores[i].value;
						
						}
					}
						
				} 
			}
			else{
				mymessage = document.myform.WebScores.value;	
			}
			document.myform.scoreid.value = document.myform.ScoreNumb.value - 1;
			var myans = confirm('Are you sure you want to delete score ' + mymessage)
			if (myans == true){

			document.myform.submit();
			}
			else{
				document.myform.DATEYESNO.disabled = false;
			}
		}	
		else if (document.myform.ScoreNumb.value == 0) {
			document.myform.submit();
	
		}
	}
	
}




function myfun8(my){

	
	
 	if (parseInt(my) <= parseInt(document.myform.NumbOfGolfers.value)) {
		document.myform.NeedGolferInfo.value = '';
 		document.myform.CourseNumber1.value = my;
		document.myform.Status.value = document.myform.hbh.value;
		document.myform.submit();
	}	

}

function tryagain(){
	
	document.myform.TryAgain.value = 'TryAgain';
	document.myform.submit();
}

function checkgolfer(mynumb){
	 
	document.myform.NeedGolferInfo.value = document.myform.golfernumb.value;
	document.myform.LoggedOn.value = 'True';
	
	document.myform.submit();
}

function alldone(mynumb){

	if (mynumb == 1) {
		document.myform.Club.value = '';
		document.myform.Score.value = '';
       		document.myform.Course.value = '';
 		document.myform.Date.value = '';
    		document.myform.TeeName.value = '';
 		document.myform.PlayerClubName.value = '';
    		document.myform.Cr.value = '';
  		document.myform.TourneyString.value = '';
    		document.myform.Slope.value = '';
		document.myform.Status.value = document.myform.hbh.value;
		
		document.myform.submit();
	}
	//erase scores	
	else if (mynumb == 2)  { 
		document.myform.Status.value = 'EraseScores';
		document.myform.scoreid.value = '';
		document.myform.submit();	
	}
}

function gotholes(mynumb){
	
	if (mynumb != 3) {
		document.myform.HolesNumber.value = mynumb;
	}
	document.myform.NineNumber.value = mynumb;
	document.myform.Status.value = 'GOTHOLES';
	document.myform.submit();
}


function getday(){
	var d = new Date();
	

	iday = document.myform.day.value;
	result = document.myform.RoundYear.value/4;
	


	document.myform.RoundDay.value = iday ;
		
	nowday =  d.getDate()
	
	var str = nowday + '';
	
	
	if (str.length == 1) {
		nowday = '0' + str
	}



	nowmonth = d.getMonth() + 1;
	nowdate = nowmonth + nowday;


	var str1 = document.myform.RoundDay.value + '';
	
	
		
	if (str1.length == 1) {
		myday = '0' + document.myform.RoundDay.value;
	}
	else{
		myday = document.myform.RoundDay.value;
	}



		
	mydate2 = document.myform.RoundMonth.value + myday;
	oldyear = document.myform.RoundYear.value;
	
		
		
	mydate = document.myform.RoundMonth.value + '/' + document.myform.RoundDay.value + '/' + document.myform.RoundYear.value;	
	
	dateanswer = checkdate(mydate);

	if (dateanswer == 'ok'){
	

	var m =  parseInt(document.myform.RoundMonth.value)
	
	  if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m ==10 || m==12){

		
		if (iday < 32 && iday > 0) {
			result = 'Ok';	
		}
		else{
			result = 'notok';	
		}

	
	}	
 	else if (m == 4 || m == 6 || m == 9 || m == 11){

		if (iday < 31 && iday > 0) {
			result = 'Ok';	
		}
		else{
			result = 'notok';	
		}
	}	
	else if (m == 2){
		if (iday < 29 && iday > 0) {
			result = 'Ok';
		}	
		else if (iday == 29) {
			result = document.myform.RoundYear.value/4
			
			if (result == Math.round(result)) {
				result = 'Ok';
			}
			else{
				result = 'notok';
			}
		}
		else{
			result = 'notok';	
		}

	}



	if (result == 'notok') {
		alert('This is not a valid date. Please enter a valid date'); 
		document.myform.RoundYear.value = oldyear
		document.myform.day.focus();
	}
	else{
	
		if (document.myform.Club.value != '') {
			document.myform.Status.value = 'NEEDAWAYTOURNEY';
		}
		else{
			document.myform.Status.value = 'NEEDTOURNEY';
		}
		
		if (document.myform.GroupHoles.value == '9') {
			document.myform.TourneyRound.value = 'N';
	
			document.myform.Status.value = 'NeedAnswer';
		}

		formatdate(mydate);
		document.myform.submit();
	}
	}
	else{
		alert(mydate + ' is older than your 20th score of ' + document.myform.OldestScoreDate.value + ' so it is not allowed. \nPlease enter a valid date');
		document.myform.day.focus();
	}
}
function formatdate1(mydate){
	
	var d = new Date(mydate);
	var myday =  d.getDate();
	var mymonth = d.getMonth() + 1;
	myday1 = d.getDay();
	myyear = d.getFullYear() + '';
	var myday2 = myday + '';
	
	
	//myreturndate = weekday[myday1] + ', ' + monthname[mymonth - 1] + ' '  + myday2 + ' ' + myyear;
	//document.myform.Date.value =  myreturndate;
	//alert(myreturndate);

	//Tue, Apr 23 2002
			mymonth = mymonth + '';

			if (mymonth.length == 1) {
				mymonth = '0' + mymonth; 
			}

			

			if (myday2.length == 1) {
				myday2 = '0' + myday2; 
			}

			
			playeddate = myyear + mymonth + myday2;
			
			//20020423
			return playeddate;



}






function formatdate(mydate){

	var d = new Date(mydate);
	var weekday=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	var monthname=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');


	

	
	var myday =  d.getDate();
	var mymonth = d.getMonth() + 1;
	myday1 = d.getDay();
	myyear = d.getFullYear() + '';
	var myday2 = myday + '';
	
	
	myreturndate = weekday[myday1] + ', ' + monthname[mymonth - 1] + ' '  + myday2 + ' ' + myyear;
	document.myform.Date.value =  myreturndate;
	//alert(myreturndate);

	//Tue, Apr 23 2002
			mymonth = mymonth + '';

			if (mymonth.length == 1) {
				mymonth = '0' + mymonth; 
			}

			

			if (myday2.length == 1) {
				myday2 = '0' + myday2; 
			}

			
			playeddate = myyear + mymonth + myday2;

			//20020423
			document.myform.DatePlayed.value = playeddate;
	
			

}
function checkdate(mydate){

	var d = new Date(mydate);
	var e = new Date(document.myform.OldestScoreDate.value);
	
	if (e > d)  {
		
		return 'notok'; 
	}
	else{
		return 'ok'; 
	
	}
	
}


function eraseday(){

	if (document.myform.day.value != '') {
		document.myform.day.value = '';
	}
	else{
		document.myform.RoundMonth.value = '';
		document.myform.Status.value = 'GetMonth';
		document.myform.submit();
	}
	

}

function getmonth(mymonth){
	if (mymonth != 0) {
		var d = new Date()
	


		currmonth = d.getMonth() + 1
	
		if (currmonth >= mymonth)  {
			document.myform.RoundYear.value = d.getFullYear(); 
		}
		else{
			document.myform.RoundYear.value = d.getFullYear() - 1;
		}

		
	
		document.myform.RoundMonth.value = mymonth;
		document.myform.Status.value = 'GetDay';
		document.myform.submit();
	}
}



function datetoday(mynumb){
	// 1 or 2 for hbh
	// 3 or 4 for non hbh
	//alert(mynumb);
	
	if (mynumb == 3) { 
		//home club default tee and course
		document.myform.Status.value = 'NEEDTOURNEY';
		var pc = document.myform.PlayerCourse.value;
		var pt = document.myform.PlayerTee.value;
		var pcn = document.myform.PlayerCourseName.value;

		d = new Date();
		formatdate(d);
		
		document.myform.CourseNumber.value =  pc;
		document.myform.TeeNumber.value =  pt;
		document.myform.Course.value = pcn;
		document.myform.hometeeready.value = 'Y'
		document.myform.submit();
	}	
	else if (mynumb == 1) {
		d = new Date();
		formatdate(d);
		if (document.myform.Status.value != 'NeedAwayDate') {
			document.myform.Status.value = 'NEEDTOURNEY';
		}
		else{
			document.myform.Status.value = 'NEEDAWAYTOURNEY';
			
		}

		if (document.myform.GroupHoles.value == '9') {
			document.myform.TourneyRound.value = 'N';
	
			document.myform.Status.value = 'NeedAnswer';
			var pc = document.myform.PlayerCourse.value;
			var pt = document.myform.PlayerTee.value;
			var pcn = document.myform.PlayerCourseName.value;

		d = new Date();
		formatdate(d);
		
		document.myform.CourseNumber.value =  pc;
		document.myform.TeeNumber.value =  pt;
		if (document.myform.Course.value == '') {
		document.myform.Course.value = pcn;
		}
		}
		//alert(document.myform.Status.value);
		
		document.myform.submit();
	}
	else if (mynumb == 2) { 
		
		document.myform.Status.value = 'GetMonth';
		document.myform.submit();
	}
	else if (mynumb == 4) {
		
		document.myform.Status.value = 'Club';
		document.myform.PlayerStatus.value = 'Club';
		document.myform.submit();
	}

	
}



function gotnine(mynumb){
	//home course 9 hole score for 18 hole golfer
	document.myform.NineNumber.value = mynumb;
	document.myform.HolesNumber.value = mynumb;

	if (document.myform.PlayerStatus.value != 'Course' && document.myform.Score.value == '') {
		document.myform.Status.value = 'GOTTEE';
	}
	else{
		document.myform.Status.value = 'NeedDate';
		document.myform.PlayerStatus.value = '';	
	}
	document.myform.hometeeready.value = 'Y'
	document.myform.submit();
}


function notee(){
		
		if (document.myform.Score.value == '') {
			
			document.myform.Status.value = 'NeedScore';
			document.myform.PlayerStatus.value = 'NeedScore';
		}
		else{
			
			document.myform.Status.value = 'Cr';
			document.myform.PlayerStatus.value = '';
		}
		
		document.myform.submit();
}

function gotcourse(mynumb){
	
	if (document.myform.NumbOfCourses.value != 1) {
		document.myform.Course.value =  document.myform.iclubname[mynumb - 1].value;
	}
	else{
		document.myform.Course.value =  document.myform.iclubname.value;
	}
	document.myform.CourseNumber.value = mynumb;
	document.myform.Status.value = 'NEEDTEE';
	document.myform.submit();
}



function gottee(mynumb){
	
	
	document.myform.TeeNumber.value = mynumb;
		
	
		if (document.myform.GroupHoles.value == '18') {
			//one course not default home tee
			document.myform.hometeeready.value = 'Y'
			if (document.myform.PlayerStatus.value != 'Course' && document.myform.hbh.value != 'U' && document.myform.Score.value == '')  {
			
				document.myform.Status.value = 'GOTTEE';
			}	
			else{
				document.myform.Status.value = 'NeedDate';
				document.myform.PlayerStatus.value = '';	
				
			}
			document.myform.NineNumber.value = 0;
		}
		else{
			document.myform.Status.value = 'NEEDNINE';
				
		}
	
		
	
	document.myform.submit();
}


function gotcoursetee(mynumb){
	
	
	document.myform.TeeNumber.value = mynumb;
		
	
		if (document.myform.GroupHoles.value == '18') {
			if (document.myform.PlayerStatus.value != 'Course' && document.myform.hbh.value != 'U' && document.myform.Score.value == '')  {
			
				document.myform.Status.value = 'NeedScore';
			}	
			else{
				document.myform.Status.value = 'NeedDate';
				document.myform.PlayerStatus.value = '';	
				
			}
			
			
			if (document.myform.hbh.value != 'R'){	
			document.myform.NineNumber.value = 0;
			document.myform.hometeeready.value = 'Y'
			}
		}
		else{
			document.myform.Status.value = 'NEEDNINE';
			
			
				
		}
	
		
	
	document.myform.submit();
}
function gotclubq(myans){
	
	if (myans == 1) {
		if (document.myform.NumbOfCourses.value == 1) {
			document.myform.Status.value = 'NEEDTEE';
			document.myform.CourseNumber.value = 1;
		}
		else{
		
		document.myform.Status.value = 'Course';
		}
	}
	else{
		document.myform.TourneyString.value = 'AWAY ROUND';
		document.myform.PlayerClubName.value = 'Unknown Away Club';
		if (document.myform.Score.value == '') {
			document.myform.Status.value = 'NeedScore';
			document.myform.PlayerStatus.value = 'NeedScore';
		}
		else{

		if (document.myform.StateId.value == '1') {
			document.myform.Status.value = 'AwayCr';
			
		}
		else{
			document.myform.Status.value = 'NeedState';
		}
		}
		
	}
	document.myform.submit();
}


function nocourse(){
		
		if (document.myform.Score.value == '') {
		
			document.myform.Status.value = 'NeedScore';
			document.myform.PlayerStatus.value = 'NeedScore';
		}
		else{
			document.myform.Status.value = 'Cr';
			document.myform.PlayerStatus.value = '';
		}
		
		document.myform.submit();
}





function gettourney(myans){
	if (myans == 1) {
		document.myform.TourneyString.value = 'TOURNAMENT ROUND';
			document.myform.TourneyRound.value = 'Y';
	}
	else{
		document.myform.TourneyRound.value = 'N';
	}
	document.myform.Status.value = 'NeedAnswer';
	document.myform.submit();
}


function gotanswer(mynumb){




	
	if (mynumb == 1) {
		
		
		
		document.myform.Status.value = 'SCOREPOSTED';
		document.myform.submit();

	}	
	else{
		
		document.myform.Status.value = document.myform.hbh.value;
		document.myform.Score.value = '';
       		document.myform.Course.value = '';
 		document.myform.Date.value = '';
    		document.myform.TeeName.value = '';
 		document.myform.PlayerClubName.value = '';
    		document.myform.Cr.value = '';
  		document.myform.TourneyString.value = '';
    		document.myform.Slope.value = '';
		
		document.myform.Status.value = 'NOSCORE';
		document.myform.AwayClubNumb.value = '';
		document.myform.submit();
	}

}



function checkcr(mynumb){
	
	gotdec = 'F'
	if (mynumb == 1) {
		mycr = document.myform.cr1.value;
		var str= mycr
		var pos=str.indexOf('.')

		if (pos>=0){

		gotdec = 'T';
		}
			
		if (str.length == 2 && gotdec == 'F') {
			document.myform.cr1.value = document.myform.cr1.value + '.';
		}
		
	}	
	else{
		document.myform.cr1.value = '';
		document.myform.cr1.focus();
	}

}




function getslope(){
	mycr = document.myform.cr1.value;
	var str = mycr;
	
	
	if (str.length == 0) {
	alert ('Courses must be rated to post a score.');
			document.myform.cr1.focus();
			return;
			

	}
	else if(mycr < 20 || mycr > 90){	
		alert ('Acceptable course ratings are from 20 to 90.');
			document.myform.cr1.focus();
			return;
			
 	}
	else{
	if (str.substr(str.length - 1,1) == '.') {
		mycr = mycr + '0';
	}
	document.myform.Cr.value = mycr;

	if (document.myform.Status.value == 'AwayCr') {
		document.myform.Status.value = 'AwaySlope';
		
	}
	else{
		document.myform.Status.value = 'Slope';
	}

	document.myform.submit();
	}
}


function checkslope(mynumb){

	myslope = document.myform.slope1.value;
	
	if (mynumb == 1) {
		if (myslope < 55 || myslope > 155) {
			alert ('Acceptable slope ranges are from 55 to 155.') ;
			document.myform.slope1.focus();
			return;
		}
		else {
			document.myform.Slope.value = document.myform.slope1.value;
		}
	}	
	else if (mynumb == 2) {
		document.myform.Slope.value = 'Course Not Sloped';
	
	}		
	else if (mynumb == 3) {

	
		document.myform.slope1.value = '';
		document.myform.slope1.focus();
		return;
	}
	//home score course not rated
	document.myform.TeeName.value = 'Not Available';
	document.myform.Course.value = 'Unknown';
	//document.myform.hometeeready.value = 'Y'
	if (document.myform.Status.value == 'AwaySlope') {
		
		if (document.myform.Date.value == '') {

			document.myform.Status.value = 'NeedAwayDate';
			document.myform.awayteeready.value = 'Y';
		}
		else {




			if (document.myform.GroupHoles.value == '9') {
				document.myform.TourneyRound.value = 'N';
	
				document.myform.Status.value = 'NeedAnswer';
			}
			else {

				document.myform.Status.value = 'NEEDAWAYTOURNEY';
				document.myform.awayteeready.value = 'Y';
			}
		}
	}
	else {
		document.myform.Status.value = 'NeedDate';
	}	
	document.myform.AwayClubNumb.value = '00000';
	document.myform.submit();
	
}







function test(mynumb) {

	if (mynumb == 0) {
		document.myform.Status.value = 'R';
	}
	else {
		document.myform.Score.value = document.myform.T1.value;
		document.myform.Status.value = 'NeedDate';
		
	}	
	
	
	document.myform.submit();
}





function gotscore(mynumb){
	
	//document.myform.NineNumber.value = document.myform.GroupNine.value;
	document.myform.GroupHoles.value = document.myform.StartGroupHoles.value; 
	if (parseInt(document.myform.Score2.value) > '25')  { 	
		
		
		document.myform.Score.value = document.myform.Score2.value;
		if (document.myform.PlayerStatus.value == 'NeedScore') {
			document.myform.GroupHoles.value = document.myform.StartGroupHoles.value; 
			
			if (document.myform.TourneyString.value == 'AWAY ROUND') {
				document.myform.Status.value = 'NeedState'
				

			}
			else{
			document.myform.Status.value = 'Cr'
			document.myform.PlayerStatus.value = ''
		
			}

			
			
		}
		else{
			
	
			if ((parseInt(document.myform.Score2.value) < parseInt(document.myform.Min18Score.value)) && (document.myform.GroupHoles.value == '18')) {
				
				 document.myform.GroupHoles.value = 9;	
						
			

			document.myform.Status.value = 'Club';
			}
			else{ 
			document.myform.GroupHoles.value = document.myform.StartGroupHoles.value 
			if (document.myform.NumbOfCourses.value == '1') {
			
			document.myform.Status.value = 'NeedDate'
			}
			else if(document.myform.NumbOfCourses.value == '2'){
			document.myform.Status.value = 'NEEDCOURSETEE'

			}
			else{
				document.myform.Status.value = 'Course'
			}





				
		}
	
		}

		
		mynumb = document.myform.USGAHdcp.value;
		if (mynumb == "NONE" ){
			mynumb = 41;
		}
		var x = parseInt(mynumb);
		var strokes = 180;
		
		if (x <= 9){
		 	strokes = 109;
		}

		else if (x >= 10 && x <= 19){
			strokes = 126;
		}
		else if (x >= 20 && x <= 29){
			strokes = 144;
		}
		else if (x >= 30 && x <= 39){
			strokes = 162;
		}

		if (parseInt(document.myform.Score2.value) > parseInt(strokes)){
		//alert('Please enter a score.');
		alert('This score exceeds the maximum allowed by Equitable Stroke Control');
		document.myform.Score2.focus();
		}
		else {
                              

		document.myform.submit()
		}


	}
	else {
		alert('Please enter a score greater than 25.');
		document.myform.Score2.focus();
		
	}
		
}



function erasescore(){
	document.myform.Score2.value = '';
	document.myform.Score2.focus();
}

function checkKey9(e) {
//alert(String.fromCharCode(e));


}

function checkKeyforcb(mynumb,itext) {
	
	
	
	if (isNav == true){
		
		var e = parseInt(mynumb);
	}
	else{
		var e = window.event.keyCode;
	}

	if (itext == 0) {
		if (e < 48 || e > 57) {
			e = 0;
		}
	}
	
	else{
		//if !=((e > 64 && e < 91)  || (e > 96 && e < 123) || (e==39)) {
		if ((e > 64 && e < 91) || (e > 96 && e < 123) || (e=39)) {
			e = e;
		}
		else if (e > 96) {
			e = e - 32;
			
		}
		else{
			e = 0;
		}
	}
	
	if (isNav == true){
		if (e == 0){
			return false;
		}
	}
	else{
		window.event.keyCode = e;
		return e;
	}


	
}


function checkKey(mycontrol,i) {
	
	
	
	if (isNav == true){
		mystring = ""
	
	
	var str = mycontrol + '.value'
	
	mylen = str.length;
	
	for (i = 0; i <= parseInt(mylen) - 1; i++){
		thisasci = str.charCodeAt(i)
		if (thisasci > 47 && thisasci < 58){
			mystring = mystring + str.substr(i,1)
		}
        			
		
	}
	el.value = mystring
		return;
	}
	else{
		var e = window.event.keyCode;
	}
	
	
	if (i == 1) {
		if (e > 47 && e < 58){
			e = e;
		}
        	else {
			e = 0;
	
		
		}
	}
	 
	if (i == 2) {
		if ((e > 47 && e < 59) || (e == 65 ) || (e == 97) || (e == 77) || (e == 109) || (e == 32) || (e == 80) || (e == 112)){
			e = e;
		}
        	else {
			e = 0;
	
		
		}
	}
	
	if (isNav == true){
		if (e == 0){
			//return false;
			//alert("Hi Will")
			return false; 
			//alert("in1")
		}
	}
	else{
		window.event.keyCode = e;
		return e;
	}



	//window.event.keyCode = e;
	
//alert(e);
}

function checkKey1(mynumb) {
	var e = window.event.keyCode;
	
		if (e > 47 && e < 58){
			e = e;
		}
        	else {
			e = 0;
	
		
		}
	
	window.event.keyCode = e;
//alert(e);
}




function checkautokey31() {



 

	if (window.event.keyCode == 13) {

	alert('Please Click on the Submit button to send this');

	}
}


function checktotal(mynumb){

	

	if  (document.myform.HolesNumber.value == 2) {
		mynumb = mynumb - 9;
	}

	if (document.myform.Score1[mynumb - 1].value != '' && document.myform.Status.value != 'NeedDate') {
	

	 fronttotal = 0;
	 backtotal = 0;
	 dotsfronttotal = 0;
	 dotsbacktotal = 0;
	 escfronttotal = 0;
	 escbacktotal = 0;

	


	if  (document.myform.HolesNumber.value == 0) {
		iStart = 0;
		iEnd = 17;	
		iTotal = 18;
	}
	else{
		iStart = 0;
		iEnd = 8;
		iTotal = 9;
	}

	
	escfront = 0;
	escback = 0;
	


		for (i = 0; i <= 8 ; i++){
	   	
		

			if (document.myform.Score1[i].value == '') {
				TEMP = 0;
			}
			else{
				TEMP = parseInt(document.myform.Score1[i].value);
			}
			fronttotal = fronttotal + TEMP;
			
		}
	   		
	   

	
	   if (iTotal == 18) {	

		for (i = 9; i <= 17 ; i++){	
		
			if (document.myform.Score1[i].value == '') {
				TEMP = 0;
			}
			else{
				TEMP = parseInt(document.myform.Score1[i].value);
			}
			backtotal = backtotal + TEMP;
		}
	   
	   }
		

		
		


	   if (document.myform.HolesNumber.value == 0) {
		document.myform.in1.value = backtotal;	
		document.myform.out.value = fronttotal;	 
	 	document.myform.totalall.value = backtotal + fronttotal;
		myscore = backtotal + fronttotal;
	   }	

	   else if(document.myform.HolesNumber.value == 1) {
		document.myform.out.value = fronttotal;
		myscore = fronttotal;
	   }
		
	   else{
		myscore = fronttotal;
		document.myform.in1.value = fronttotal;
	   }	

	
	for (i = 0; i <= iTotal - 1 ; i++){
	

		if (document.myform.Score1[i].value != '') {
			scr = parseInt(document.myform.Score1[i].value);
	 		dots = 0;
	
			if (document.myform.maxallow.value == 'Double Bogey') {
				THISMAX = parseInt(document.myform.Pars[i].value) + 2;
			}
			else{
				THISMAX = parseInt(document.myform.maxallow.value);
			}

			if (scr > THISMAX) {
				dots = scr - THISMAX ;
				scr = THISMAX;
				
			}
			document.myform.ESC[i].value = scr;
			if (i < 9) {
					dotsfronttotal = dotsfronttotal + dots;
					escfronttotal = escfronttotal + scr;
			}
			else{
					dotsbacktotal = dotsbacktotal + dots;
					escbacktotal = escbacktotal + scr;
			}
		}
		
	}


	if  (document.myform.HolesNumber.value == 0) {
		document.myform.DOTSOUT.value = dotsfronttotal;	
		document.myform.ESCOUT.value = escfronttotal;
		document.myform.DOTSIN.value = dotsbacktotal;
		document.myform.ESCIN.value = escbacktotal;
		document.myform.DOTSTOTAL.value = dotsfronttotal + dotsbacktotal;
		document.myform.ESCTOTAL.value = escfronttotal + escbacktotal;
		myscore = escfronttotal + escbacktotal;
	}	
	else if  (document.myform.HolesNumber.value == 1) {
		document.myform.DOTSOUT.value = dotsfronttotal;	
		document.myform.ESCOUT.value = escfronttotal;
		myscore = escfronttotal; 
	}
	 else{
		document.myform.DOTSIN.value = dotsfronttotal;
		document.myform.ESCIN.value = escfronttotal;
		myscore = escfronttotal ;
	   }	
		
	
	



	if (document.myform.maxallow.value == 'Double Bogey') {
		THISMAX = parseInt(document.myform.Pars[mynumb - 1].value) + 2;
	}
	else{
		THISMAX = parseInt(document.myform.maxallow.value);
	}
	
	scr = parseInt(document.myform.Score1[mynumb - 1].value);
	 		dots = 0;

			if (scr > THISMAX) {
				dots = scr - THISMAX; 
				
			}
	



	if (dots != 0) {
		dotsstring = '';
		
		if (dots <= 7) {
			for (i = 0; i <= dots; i++){
			
				dotsstring = dotsstring + '.'
			}
		}
		else{
			for (i = 8; i <= dots; i++){
				dotsstring = dotsstring + ':'
			}
			if (dots < 14) {
				for (i = dots + 1; i <= 14; i++){
				
					dotsstring = dotsstring + '.'
				}
			}
			
		}		
		
		document.myform.DOTS[mynumb - 1].value = dotsstring;
	}
	else{
		document.myform.DOTS[mynumb - 1].value = '';						
		

	}
	

	GotOne = 'False';
	for (i = 0; i <= iTotal - 1; i++){
			
		if (document.myform.Score1[i].value == '' ){
			GotOne = 'True';
		}
	}
	if (GotOne == 'False') {
		
		var name = confirm('Your ESC score is ' + myscore + ' Is this correct?')
		if (name == false){

			var name1 = prompt('ENTER THE HOLE WHICH IS NOT CORRECT','')
			if (name1 != null && name1 != ''){
	
		
		
				ANS1 = parseInt(name1);
				if(isNaN(ANS1)){

				
					//alert(ANS1);
					ANS1 = 1;
				}
				if  (document.myform.HolesNumber.value == 2) {
					document.myform.Score1[ANS1 - 10].value = '';
					document.myform.Score1[ANS1 - 10].focus();
				}	
				else{
					document.myform.Score1[ANS1 - 1].value = '';
					document.myform.Score1[ANS1 - 1].focus();
				}
			}
			
		}
		else{
			document.myform.hometeeready.value = 'Y';
			document.myform.Score.value = myscore;
			document.myform.Status.value = 'NeedDate';
			document.myform.submit();

		}
		return;

	}

	if (document.myform.Score1[mynumb - 1].value > 1 && mynumb < iTotal) {
		document.myform.Score1[mynumb].focus();
	
	}
	else if (document.myform.Score1[mynumb - 1].value > 1 && mynumb == iTotal) {
		

	}
	
	}
}
function checkvalue(mynumb){
	
	mynumb1 = parseInt(document.myform.AutoNumb.value);
	
	if (mynumb1 == 20) {	
		if ((document.myform.NumbOfScores.value < document.myform.ScoreNumb.value) && document.myform.NumbOfScores.value > 0 ){
			document.myform.ScoreNumb.value = tempscore;
	
		}
	}	
	else{
	tempnumb = mynumb;

		if  (document.myform.HolesNumber.value == 2) {
		tempnumb = mynumb - 9;
		}

		if (document.myform.Score1[tempnumb - 1].value != '' && document.myform.Score1[tempnumb - 1].value != 1) {	
	
  		checktotal(mynumb)
		}
	}


}
function notagain2(mynumb){
	document.myform.B1.disabled = true;
	
	if (mynumb == 2) {
		
		document.myform.Status.value = 'SCOREPOSTED';
	}
	else{

		document.myform.Status.value = document.myform.hbh.value;

		
	}
	document.myform.submit();	
			
}

function checkthiscourse(){
	var str=document.myform.club1.value;

	mylen = str.length;
	
	MYclub = str.toUpperCase()
	istart = 0

	if (mylen == 1) {
		myresult = document.myform.iclubname[0].value;
	}
	
	else if (document.myform.OldSearchString.value <= MYclub) {
		istart = document.myform.FoundNumber.value;
	
	}
	else{
		myresult = document.myform.iclubname[0].value;
	}

	if (istart >= parseInt(document.myform.NumbOfAwayClubs.value)) {
		myresult = document.myform.NumbOfAwayClubs.value;
	}
	else{
		for (i = istart; i <= parseInt(document.myform.NumbOfAwayClubs.value) - 1; i++){
		
						
			
			mystr = document.myform.iclubname[parseInt(i)].value;
			


			Myclublist =  mystr.substr(0,mylen);
			//alert(Myclublist);
			//alert(MYclub);
			
			//Myclublist = ucase(cstr(left(document.myform.iclubname[i].value,mylen)))
			if (MYclub == Myclublist) {
				myresult = parseInt(i) + 1;
				//exit for
				break;
			}
			else{
			
				if (MYclub < Myclublist) {
					myresult = parseInt(i);
					//exit for
					break;

				}
			}
		}
	}

	if (myresult < 0) {
		myresult = 0;
	}
	else if (myresult == document.myform.NumbOfAwayClubs.value) {
		myresult = parseInt(document.myform.NumbOfAwayClubs.value) - 1;
	}
	
	document.myform.CourseName1[myresult].selected = 'True';

	document.myform.FoundNumber.value = myresult;
	document.myform.OldSearchString.value = MYclub;

	document.all.clubid.innerText = document.myform.iclubname[myresult - 1].value;
}

function displayclub(){
	
	
	
	for (i = 0; i <= parseInt(document.myform.NumbOfAwayClubs.value) - 1; i++){
 
		if (document.myform.iclubnmbr[i].value == document.myform.CourseName1.value) {
		document.all.clubid.innerText = document.myform.iclubname[i].value;
		break;
		}

	}

}

function noawaytee(){
		
		if (document.myform.Score.value == '') {
			
			document.myform.Status.value = 'NeedScore';
			document.myform.PlayerStatus.value = 'NeedScore';
		}
		else{
			
			document.myform.Status.value = 'AwayCr';
			document.myform.PlayerStatus.value = '';
		}
		
		document.myform.submit();
}

function changeblur(mynumb){
	if (mynumb < 19) {
		document.myform.Score1[mynumb - 1].focus();
	}
	else{
		document.myform.Score1[17].focus();
	}
}

function closeposting(){

	self.close();
}

function continueoutofseason(){
	document.myform.Status.value = document.myform.hbh.value;
	document.myform.submit();
}




function Toggle(){
	
	if (document.myform.Toggle1.value == 'Keyboard Legend') {
		document.myform.Toggle1.value = 'No Legend';
	}
	else{
		document.myform.Toggle1.value = 'Keyboard Legend';
	}
	
	document.myform.submit();


}







function changeview(){
	

	if (document.myform.r1(0).checked) {
		document.myform.OptSelected.value = 'App';
	}
	else{
		document.myform.OptSelected.value = 'Int';
	}
	document.myform.submit();

}

function gotawayholes(mynumb){
	if (mynumb != 3) {
		document.myform.HolesNumber.value = mynumb;
	}
	document.myform.Status.value = 'GOTAWAYHOLES';
	document.myform.submit();
}



		
function initButton() {
if (document.all) {
document.all.topButton.style.fontsize = '2pt';
document.all.topButton.style.pixelLeft = 5;
document.all.topButton.style.visibility = 'hidden';
}
else if (document.layers) {
document.topButton.left = window.innerWidth - document.topButton.clip.width - 15;
document.topButton.visibility = 'hide';
document.topButton.fontsize = '2pt';
}
else if (document.getElementById) {
document.getElementById('topButton').style.left = (window.innerWidth - 35) + 'px';
document.getElementById('topButton').style.visibility = 'hidden';
document.getElementById('topButton').style.fontsize = '2pt';
   }
}
function testy(){
	
	
	var myheight = parseInt(window.screen.height) - (parseInt(window.screen.height) * .05);
	var mywidth = window.screen.width - (window.screen.width * .01);
	//var mystring = "toolbar=0,location=0,copyhistory=0,scrollbars=yes,status=0,toolbar=no,menubar=no,directories=0,location=no,top=0,left=0,height=" + myheight + ",width=" + mywidth ;
	var mystring = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=400,height=400,top=0,left=0"
	mypage = "poststart1.asp?CourseNum=" + document.myform.clubnumber.value + "&New=1";
	//window.close()
	//window.open(mypage,"_self","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,,resizable=no,copyhistory=yes,width=400,height=400");
	//window.open(mypage,"_self","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=" + mywidth + ",height=" + myheight + ",top=0,left=0")
	window.open(mypage,"mynew_self","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=" + mywidth + ",height=" + myheight + ",top=0,left=0")
	//,top=0,left=0",height=" + myheight + ",width=" + mywidth
}
function submitclubselectform(){
	if (document.myform.nc1[0].checked) {
		document.myform.OptSelected.value = '1';
	}
	else if (document.myform.nc1[1].checked) {
		document.myform.OptSelected.value = '2';
	}
	else if (document.myform.nc1[2].checked) {
		document.myform.OptSelected.value = '3';
	}
	else if (document.myform.nc1[3].checked) {
		document.myform.OptSelected.value = '4';
	}
	else {
		document.myform.OptSelected.value = '5';
	}
document.myform.submit();
}
function nsnumbvalidate(el) {
	mystring = ""
	
	
	var str = el.value //+ String.fromCharCode(e);
	//alert (str)

	mylen = str.length;
	
	for (i = 0; i <= parseInt(mylen) - 1; i++){
		thisasci = str.charCodeAt(i)
		if (thisasci > 47 && thisasci < 58){
			mystring = mystring + str.substr(i,1)
		}
        			
		
	}
	el.value = mystring
}
function nspostnumbvalidate(el) {
	mystring = ""
	
	var str = el //+ String.fromCharCode(e);
	//alert (str)

	mylen = str.length;
	//alert (mylen)
	for (i = 0; i <= parseInt(mylen) - 1; i++){
		thisasci = str.charCodeAt(i)
		if (thisasci > 47 && thisasci < 58){
			mystring = mystring + str.substr(i,1)
		}
        			
		
	}
	el = mystring
	//alert(el)
}