<!--
function ScrollMessage() {
   window.status = msg.substring(pos, msg.length) + spacer + msg.substring(0, pos);
   pos++;
   if (pos > msg.length) pos = 0;
   window.setTimeout("ScrollMessage()",150);
}

function ClearHC() {
   document.forms[0].HC.value = "";
   var x= dirty_calculator();
}

function ClearScreen() {
   document.forms[0].MSG.value = "";
   document.forms[0].HC.value = "";
   document.forms[0].SP.value = "";
   document.forms[0].TP1.value = "";
   document.forms[0].TP2.value = "";
   document.forms[0].TP3.value = "";
   document.forms[0].TP4.value = "";
   document.forms[0].FP.value = "";
   document.forms[0].LP.value = "";  
   document.forms[0].AP.value = "";  
   document.forms[0].LatDeg.value = "0";
   document.forms[0].LatMin.value = "0";
   document.forms[0].LonDeg.value = "0";
   document.forms[0].LonMin.value = "0";
   document.forms[0].EW.selectedIndex=0;
   document.forms[0].LatDegA.value = "0";
   document.forms[0].LatMinA.value = "0";
   document.forms[0].LonDegA.value = "0";
   document.forms[0].LonMinA.value = "0";
   document.forms[0].EWA.selectedIndex=0;
   document.forms[0].Hours.value = "0";
   document.forms[0].Minutes.value = "0";
   document.forms[0].Seconds.value = "0";
   document.forms[0].Declared.checked=false;   
   document.forms[0].Sector[0].checked = true;     
   document.forms[0].chkTP0.checked=false;   
   document.forms[0].chkTP1.checked=false;   
   document.forms[0].chkTP2.checked=false;   
   document.forms[0].chkTP3.checked=false;   
   document.forms[0].chkTP4.checked=false;   
   document.forms[0].chkTP5.checked=false;      
   for (i=0; i < 5; i++) {
      document.forms[0].D[i].value = "";
      document.forms[0].SD[i].value = "";
   }   
   for (i=0; i < 7; i++) {   
      document.forms[0].TPNM[i].value=""
   }      
   document.forms[0].DTOT.value = "";
   document.forms[0].SDTOT.value = "";
   document.forms[0].V.value = "";
   document.forms[0].TXT1.value = "";
   document.forms[0].TXT2.value = "";
   document.forms[0].PTS.value = "";
   document.forms[0].LowPoint.value = "";
   document.forms[0].HighPoint.value = "";
   document.forms[0].HeightGain.value = "";
   document.forms[0].HPTS.value = "";
   document.forms[0].LowUnits[0].checked = true;   
   document.forms[0].HighUnits[0].checked = true;    
   document.forms[0].chkHL[0].checked = false; 
   document.forms[0].chkHL[1].checked = false;     
   document.forms[0].HeightLoss.value = "";     
}

function DisplayTPs() {
  var tp=window.open("TPList.asp",null,"titlebar=yes,resizable=yes,scrollbars=yes,width=480,height=600");

  //var tp=window.open("TPList.asp","TPList","titlebar=yes,resizable=yes,scrollbars=yes,width=480,height=600");
  return false;
}

function DispTPPic(z) {
   var x="TPPic.asp?TP=" + z;
   var pic=window.open(x,z,"width=435,height=650,resizable=yes");
   return false;
}

function show_handicaps() {
  var hc=window.open("Handicap.asp","Handicaps","titlebar=yes,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=680,height=500");
  return false;
}

function clear_info(z) {
	dirty_calculator();
	if (z=="A") {
   	   document.forms[0].AP.value = "";
   	   document.forms[0].TPNM[6].value = "";
	   document.forms[0].LatDegA.value = "0";
	   document.forms[0].LatMinA.value = "0";
	   document.forms[0].LonDegA.value = "0";
	   document.forms[0].LonMinA.value = "0";
	   document.forms[0].EWA.selectedIndex=0;
	}
	if (z=="T") {
	   document.forms[0].LP.value = "";
	   document.forms[0].TPNM[7].value = "";
	   document.forms[0].LatDeg.value = "0";
	   document.forms[0].LatMin.value = "0";
	   document.forms[0].LonDeg.value = "0";
	   document.forms[0].LonMin.value = "0";
	   document.forms[0].EW.selectedIndex=0;
	}
}


function set_TP(z) {  
   var i = 0;
   switch(z) {
      case 0:
      	var tp = document.forms[0].SP.value.toUpperCase();
        document.forms[0].SP.value=tp;         
        var sp = document.forms[0].SP.value;
        var fp = document.forms[0].FP.value;
        if (sp!="" && fp=="") {  
            document.forms[0].FP.value = sp;
        }
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span0").style.visibility="visible";
      	} else {
      		document.getElementById("span0").style.visibility="hidden";	
      	}
        break;
      case 1:      	
      	var tp = document.forms[0].TP1.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span1").style.visibility="visible";
      	} else {
      		document.getElementById("span1").style.visibility="hidden";	
      	}
        document.forms[0].TP1.value=tp;
        break;
      case 2:
      	var tp = document.forms[0].TP2.value.toUpperCase();	   
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span2").style.visibility="visible";
      	} else {
      		document.getElementById("span2").style.visibility="hidden";	
      	}
        document.forms[0].TP2.value=tp;
        break;
      case 3:   
        var tp = document.forms[0].TP3.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span3").style.visibility="visible";
      	} else {
      		document.getElementById("span3").style.visibility="hidden";	
      	}        
        document.forms[0].TP3.value=tp;
        break;
      case 4:   
      	var tp = document.forms[0].TP4.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span4").style.visibility="visible";
      	} else {
      		document.getElementById("span4").style.visibility="hidden";	
      	}      	
      	document.forms[0].TP4.value=tp;
      	break;
      case 5:           
      	var tp = document.forms[0].FP.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span5").style.visibility="visible";
      	} else {
      		document.getElementById("span5").style.visibility="hidden";	
      	}      	
      	document.forms[0].FP.value=tp;
      	break;
      case 6:           
      	var tp = document.forms[0].LP.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span6").style.visibility="visible";
      	} else {
      		document.getElementById("span6").style.visibility="hidden";	
      	}      	
        document.forms[0].LP.value=tp;
        break;
      case 7:           
      	var tp = document.forms[0].AP.value.toUpperCase();
      	if (tp.substring(0,1)=="#") {
      		document.getElementById("span7").style.visibility="visible";
      	} else {
      		document.getElementById("span7").style.visibility="hidden";	
      	}      	
        document.forms[0].AP.value=tp;
        break;
   }
   switch(z) {
      case 6:           
         document.forms[0].TPNM[7].value="";
         break;	
      case 7:           
         document.forms[0].TPNM[6].value="";
         break;	
      default:
         document.forms[0].TPNM[z].value="";
         break;
   }      
   var ok = ""
   var y = tp.substring(0,1)
   if (y=="*"||y=="#") {var y1="QQ"} else {var y1=y}
   var x=document.getElementsByName(y1+"Trigraph");
   if(x.length>0) {
	var str = "document.forms[0]."+y1+"Trigraph.length";  			
	cnt=eval(str);   	
   	for (i=0;i<=cnt-1;i++) {
	   	var str1 = "document.forms[0]."+y1+"Trigraph["+i+"].value"   	
	   	var ztp = eval(str1);  			
	   	if (tp==ztp) {	   		
			var str2 = "document.forms[0]."+y1+"TPName["+i+"].value";
			var ztpn = eval(str2);
			switch(z) {
			   case 6:           
			      document.forms[0].TPNM[7].value=ztpn;
			      break;	
			   case 7:           
			      document.forms[0].TPNM[6].value=ztpn;
			      break;	
			   default:
			      document.forms[0].TPNM[z].value=ztpn;
			      if (z==0 && fp=="") {		   			      
			      	document.forms[0].TPNM[5].value=ztpn;
			      }
			      break;
			}
			ok = "Y";
	   		i=cnt;
	   	}
	}
   } 
   var pid = document.forms[0].PilotID.value;
   if (tp!="" && ok=="") {
   	if(tp.substring(0,1)=="*" && pid=="0") {
   		document.forms[0].TPNM[z].value="** LOG ON TO USE PERSONAL WAYPOINTS  **";
   	} else {
  		document.forms[0].TPNM[z].value="** UNKNOWN WAYPOINT **";   		
	        switch(z) {
      			case 0:
				document.getElementById("span0").style.visibility="hidden";		      		
				break;
			case 1:
				document.getElementById("span1").style.visibility="hidden";		      		
				break;
      			case 2:
				document.getElementById("span2").style.visibility="hidden";		      		
				break;
      			case 3:
				document.getElementById("span3").style.visibility="hidden";		      		
				break;
      			case 4:
				document.getElementById("span4").style.visibility="hidden";		      		
				break;
      			case 5:
				document.getElementById("span5").style.visibility="hidden";		      		
				break;
      			case 6:
				document.getElementById("span6").style.visibility="hidden";		      		
				break;
      			case 7:
				document.getElementById("span0").style.visibility="hidden";		      		
				break;
		}   		
   	}
   }
   document.forms[0].Declared.disabled=false;
   var x = dirty_calculator();     
}

function set_Reg() {  
   document.forms[0].Reg.value=document.forms[0].Reg.value.toUpperCase();         
}

function valPScores() {
   var err = 0;
   var lc = document.forms[0].LadderCount.value;
   
   document.forms[0].OpenPoints.style.color="black";
   document.forms[0].OpenFlights.style.color="black";
   document.forms[0].WeekendPoints.style.color="black";
   document.forms[0].WeekendFlights.style.color="black";          
   document.forms[0].JuniorPoints.style.color="black";
   document.forms[0].JuniorFlights.style.color="black";          
   if (lc > 3) {
      document.forms[0].LocalPoints1.style.color="black";
      document.forms[0].LocalFlights1.style.color="black";          
   }
   if (lc > 4) {   
      document.forms[0].LocalPoints2.style.color="black";
      document.forms[0].LocalFlights2.style.color="black";          
   }
   if (lc > 5) {
      document.forms[0].LocalPoints3.style.color="black";
      document.forms[0].LocalFlights3.style.color="black";          
   }
   if (lc > 6) {
      document.forms[0].LocalPoints4.style.color="black";
      document.forms[0].LocalFlights4.style.color="black";                
   }   
        
   for (i=0;i<lc;i++) {     
     switch (i) {
       case 0:
          p = document.forms[0].OpenPoints.value;
          f = document.forms[0].OpenFlights.value;
          if (p != 0 && f <= 0) {
             document.forms[0].OpenPoints.style.color="red";
             document.forms[0].OpenFlights.style.color="red";
             err = 1;
          }
          if (i < 3 && f > 4) {
             document.forms[0].OpenFlights.style.color="red";
             err = 2;
          }
          if (p < 0) {
             document.forms[0].OpenPoints.style.color="red";
             err = 3;
          } 
          break;
       case 1:
          p = document.forms[0].WeekendPoints.value;
          f = document.forms[0].WeekendFlights.value;
          if (p != 0 && f <= 0) {
             document.forms[0].WeekendPoints.style.color="red";
             document.forms[0].WeekendFlights.style.color="red";            
             err = 1;             
          }
          if (i < 3 && f > 4) {
             document.forms[0].WeekendFlights.style.color="red";            
             err = 2;
          }
          if (p < 0) {
             document.forms[0].WeekendPoints.style.color="red";
             err = 3;
          }
          break;
       case 2:
          p = document.forms[0].JuniorPoints.value;
          f = document.forms[0].JuniorFlights.value;
          if (p != 0 && f <= 0) {
             document.forms[0].JuniorPoints.style.color="red";
             document.forms[0].JuniorFlights.style.color="red";          
             err = 1;
          } 
          if (i < 3 && f > 4) {
             document.forms[0].JuniorFlights.style.color="red";          
             err = 2;
          }
          if (p < 0) {
             document.forms[0].JuniorPoints.style.color="red";
             err = 3;
          }
          break;
       case 3:
          p = document.forms[0].LocalPoints1.value;
          f = document.forms[0].LocalFlights1.value;
          if (p != 0 && f <= 0) {
             document.forms[0].LocalPoints1.style.color="red";
             document.forms[0].LocalFlights1.style.color="red";          
             err = 1;
          }
          if (i < 3 && f > 4) {
             document.forms[0].LocalFlights1.style.color="red";          
             err = 2;
          }
          if (p < 0) {
             document.forms[0].LocalPoints1.style.color="red";
             err = 3;
          }
          break;
       case 4:
          p = document.forms[0].LocalPoints2.value;
          f = document.forms[0].LocalFlights2.value;
          if (p != 0 && f <= 0) {
             document.forms[0].LocalPoints2.style.color="red";
             document.forms[0].LocalFlights2.style.color="red";          
             err = 1;
          }
          if (i < 3 && f > 4) {
             document.forms[0].LocalFlights2.style.color="red";          
             err = 2;             
          }
          if (p < 0) {
             document.forms[0].LocalPoints2.style.color="red";
             err = 3;
          }

          break;
       case 5:
          p = document.forms[0].LocalPoints3.value;
          f = document.forms[0].LocalFlights3.value;
          if (p != 0 && f <= 0) {
             document.forms[0].LocalPoints3.style.color="red";
             document.forms[0].LocalFlights3.style.color="red";          
             err = 1;
          }
          if (i < 3 && f > 4) {
             document.forms[0].LocalFlights3.style.color="red";          
             err = 2;
          }
          if (p < 0) {
             document.forms[0].LocalPoints3.style.color="red";
             err = 3;
          }
          break;
       case 6:
          p = document.forms[0].LocalPoints4.value;
          f = document.forms[0].LocalFlights4.value;
          if (p != 0 && f <= 0) {
             document.forms[0].LocalPoints4.style.color="red";
             document.forms[0].LocalFlights4.style.color="red";          
             err = 1;
          }
          if (i < 3 && f > 4) {
             document.forms[0].LocalFlight4s.style.color="red";          
             err = 2;
          }
          if (p < 0) {
             document.forms[0].LocalPoints4.style.color="red";
             err = 3;
          }
          break;
       }   
   }             
      	
   if (err != 0) {
     	switch (err) {
    	   case 1:
  	         w = "You have not entered the number of flights";
  	         break;
          case 2:
 	         w = "Maximum 4 flights for National Ladders";
 	         break;
          case 3:
 	         w = "Points must be greater than or equal to zero"
 	         break;
      }  
      alert(w);      
      return false;
   }   
   else {
      return true;
   }     
}

Date.prototype.getCalendarDay = getCalendarDay;
function validate() {
   if (document.UploadForm.FileName.value.length < 1) { 
      alert("Please select a logger file");
      return false;
   }
   if (document.UploadForm.PilotName.value.length < 1) { 
      alert("Please enter the pilot's name");
      return false;
   }
   var dd = parseInt(document.UploadForm.DD.value);
   var mm = parseInt(document.UploadForm.MM.value);
   var yy = parseInt(document.UploadForm.YY.value);
   var rc = ValidDate(yy,mm,dd);   
   if (rc) {    
   }else{
      alert("The date you have supplied is not valid");
      return false;   
   }   
   if (document.UploadForm.Glider.selectedIndex < 1) { 
      alert("Please select a glider type");
      return false;   
   }      
   return true;   
}

function SetClaimDayName() {
   	var dd = parseInt(document.ConfirmClaim.DD.value);
   	var mm = parseInt(document.ConfirmClaim.MM.value);
   	var yy1 = document.ConfirmClaim.YY1.value;
   	var yy2 = document.ConfirmClaim.YY2.value;
   	var pts = document.ConfirmClaim.PTS.value;
   	var hpts = document.ConfirmClaim.HPTS.value;
   	var dpts = document.ConfirmClaim.DPTS.value;
	var vpts = document.ConfirmClaim.VPTS.value;
	var bpts = document.ConfirmClaim.BPTS.value;
	var cf = document.ConfirmClaim.CF.value;
	var dpts2 = document.ConfirmClaim.DPTS.value;
	var vpts2 = 0;
	var bpts2 = Math.round(dpts2*(cf-1));
	var pts2 = parseInt(dpts2)+parseInt(bpts2);
	var noscore = document.ConfirmClaim.NoScore.checked;
   	var pen = "";
   	var invday = "";       
   	var dayname = "";   

	if (dd!=-1 && mm!=-1) {         
	   	var nowdate = new Date();     
	   	if (yy2>=2007) {
   			if (mm==0) {
   				yy = yy1;
   				mm=12;
       			} else {
         			yy = yy2;
   			}
   		} else {
   			if (mm<3) {
   				mm = mm + 10;
   				yy = yy1;
			} else {
   				mm = mm - 2;
   				yy = yy2;
			}
		}				

   		var rc = ValidDate(yy,mm,dd);
   		var fdate = new Date(yy,mm-1,dd);         		      	   			

		if (yy<2007){
			document.ConfirmClaim.JYear.value = "(Pilot under 26 years old on 1st October 2005)";
		} else {
	      		document.ConfirmClaim.JYear.value = "(Pilot under 26 years old on 1st January " + yy + ")";      		
	}
	
      	if (rc && fdate <= nowdate) {       
		//Valid flight date
	   	dayname = fdate.getCalendarDay();         
	   	if (dayname == "Saturday" || dayname == "Sunday") {
          		 document.ConfirmClaim.Weekend.checked = true;
	       	} else {   
   		        document.ConfirmClaim.Weekend.checked = false;
       		}
        	pen = (check_submission(nowdate,fdate));
         	
         	if (pen!="") {
          	  	pts = Math.round(pts * 0.9);
          	  	hpts = Math.round(hpts * 0.9);
          	  	dpts = Math.round(dpts * 0.9);
   			vpts = Math.round(vpts * 0.9);
   			bpts = Math.round(bpts * 0.9);          	  	
          	  	dpts2 = Math.round(dpts2 * 0.9);
   			bpts2 = Math.round(bpts2 * 0.9);
   			pts2 = parseInt(dpts2)+parseInt(bpts2);
         	}
         	document.ConfirmClaim.FDD.value = dd;
         	document.ConfirmClaim.FMM.value = mm;
        	document.ConfirmClaim.FYY.value = yy;         	
        	
      	} else {			               
       		invday = "*** Invalid Date ***";       
       	}	
   }   
      
   document.ConfirmClaim.DayName.value = dayname;
   document.ConfirmClaim.InvalidDay.value = invday;   

   document.ConfirmClaim.PTS1.value = 0;   
   document.ConfirmClaim.HPTS1.value = 0;   
   document.ConfirmClaim.DPTS1.value = 0;
   document.ConfirmClaim.VPTS1.value = 0;
   document.ConfirmClaim.BPTS1.value = 0;

   document.ConfirmClaim.PTS2.value = 0;   
   document.ConfirmClaim.DPTS2.value = 0;
   document.ConfirmClaim.VPTS2.value = 0;
   document.ConfirmClaim.BPTS2.value = 0;


   if (invday=="") {        
      if (pts>0) {      	
        document.ConfirmClaim.PTS1.value = pts;
        document.ConfirmClaim.Penalty.value = pen;
	document.ConfirmClaim.DPTS1.value = dpts;
	document.ConfirmClaim.VPTS1.value = vpts;         
  	document.ConfirmClaim.BPTS1.value = bpts;         
	
        document.ConfirmClaim.PTS2.value = pts2;
        document.ConfirmClaim.DPTS2.value = dpts2;
	document.ConfirmClaim.VPTS2.value = vpts2;
  	document.ConfirmClaim.BPTS2.value = bpts2;         
      }         
      if (hpts>0) {
         document.ConfirmClaim.HPTS1.value = hpts;
         document.ConfirmClaim.HPenalty.value = pen;
      }            
      document.ConfirmClaim.Points.value = 0;
   }
   if (noscore) {     
	document.ConfirmClaim.PTS1.value = 0;   
	document.ConfirmClaim.HPTS1.value = 0;   
	document.ConfirmClaim.DPTS1.value = 0;
	document.ConfirmClaim.VPTS1.value = 0;
	document.ConfirmClaim.BPTS1.value = 0;
	document.ConfirmClaim.PTS2.value = 0;   
   	document.ConfirmClaim.DPTS2.value = 0;
   	document.ConfirmClaim.VPTS2.value = 0;
   	document.ConfirmClaim.BPTS2.value = 0;
   	document.ConfirmClaim.Weekend.checked=false;
   	document.ConfirmClaim.Junior.checked=false;
   	document.ConfirmClaim.Penalty.value="";
   	document.ConfirmClaim.HPenalty.value="";
   }
}

function SetDayName() {
   var dd = parseInt(document.UploadForm.DD.value);
   var mm = parseInt(document.UploadForm.MM.value);
   var yy = parseInt(document.UploadForm.YY.value);
   var dayname = "";   

   if (dd!=-1 && mm!=-1 && yy!=-1) {         
      var rc = ValidDate(yy,mm,dd);
      if (rc) {       
         var fdate = new Date(yy,mm-1,dd);   
         dayname = fdate.getCalendarDay();                         
      } else {         
         dayname = "*** Invalid Date ***";       
      }         
   }   
   document.UploadForm.DayName.value = dayname; 
}

function SetEditDD() {
	document.form1.FDD.value = parseInt(document.form1.DD.value);
	var rc = SetEditDayName();
}

function SetEditMM() {
	var mm = parseInt(document.form1.MM.value);
	var yy = document.form1.Season.value;
	if (mm==0) {
		document.form1.FMM.value = 12;
		document.form1.FYY.value = yy-1;
	} else {
		document.form1.FMM.value = mm;
		document.form1.FYY.value = yy;
	}	
	var rc = SetEditDayName();
}

function SetEditDayName() {
   	var dd = document.form1.FDD.value;
   	var mm = document.form1.FMM.value;
  	var yy = document.form1.FYY.value;

   	var ddx = document.form1.FDDX.value;
   	var mmx = document.form1.FMMX.value;
  	var yyx = document.form1.FYYX.value;

   	var add = document.form1.ADD.value;
   	var amm = document.form1.AMM.value;
  	var ayy = document.form1.AYY.value;

   	var dayname = "";
   	var msg = "";   
   	if (dd!=-1 && mm!=-1 && yy!=-1) {         
      	var rc = ValidDate(yy,mm,dd);
    	if (rc) {       
         	var fdate = new Date(yy,mm-1,dd);   
			if (dd==ddx && mm==mmx && yy==yyx) {
		       dayname = fdate.getCalendarDay();   
   		       document.form1.InvalidDay.value = "";                      	    		
      			document.form1.btnUpdate.disabled=false;
  				document.form1.DayName.value = dayname; 
      			return;
         	}         	
         	var fdatex = new Date(yyx,mmx-1,ddx);   
         	var adate = new Date(ayy,amm-1,add);   
			if (fdate>adate) {
   	      		msg = "Flight Date ("+dd+"/"+mm+"/"+yy+") is later than the original claim date ("+add+"/"+amm+"/"+ayy+")!"
   	      		msg = msg + "\nYou must delete this claim and resubmit a new one"
   	      		alert(msg);
   	      		document.form1.btnUpdate.disabled=true;
	         	dayname = fdate.getCalendarDay();
   	      		document.form1.InvalidDay.value = "*** Invalid Date ***";
   	      		return;
			}
			var cdate = new Date(adate.getTime() - (14 * 86400000));			
			if (cdate>fdate) {
   	      		msg = "Flight date ("+dd+"/"+mm+"/"+yy+") is more than 14 days before the original claim date ("+add+"/"+amm+"/"+ayy+")"
   	      		msg = msg + "\nYou must delete this claim and resubmit a new one"
   	      		alert(msg);
   	      		document.form1.btnUpdate.disabled=true;   	      		
	         	dayname = fdate.getCalendarDay();
   	      		document.form1.InvalidDay.value = "*** Late submission penalty ***";
   	      		return;	       	
			}
	       dayname = fdate.getCalendarDay();   
   	       document.form1.InvalidDay.value = "";                      	    		
      		document.form1.btnUpdate.disabled=false;
      	} else {         
         	dayname = "";
         	document.form1.InvalidDay.value = "*** Invalid Date ***";
 	      	document.form1.btnUpdate.disabled=true;
      	}         
   	}   
   	document.form1.DayName.value = dayname; 
}

function SetGPSMsg() {
   if (document.forms[0].GPSLandout[0].checked) {     
      document.ConfirmClaim.GPSMsg.value = "Logger file required for scoring";
   } else {
      document.ConfirmClaim.GPSMsg.value = "";  
   }  
}

function check_submission(nowdate,fdate) {
   var cdate = new Date();
   var cmm = nowdate.getMonth();
   var fmm = fdate.getMonth();
   cdate.setDate(nowdate.getDate()-14);
	if ((cmm==0) && (fmm==0)) {
		pen=""
   } else {
   		if (cdate>fdate) {
       	pen="(Late submission - 10% penalty)";     
		} else {
			pen=""
   		}
   	}	
   	return pen;
}
 
function ChkSatSun() {
   var dayname = document.ConfirmClaim.DayName.value;
   if (dayname == "Saturday" || dayname == "Sunday") {
       document.ConfirmClaim.Weekend.checked = true;
      }    
}

function valid_claim() {
   var z = document.ConfirmClaim.InvalidDay.value;   
   var clubid = parseInt(document.ConfirmClaim.LaunchPoint.value);
   var dd = parseInt(document.ConfirmClaim.DD.value);
   var mm = parseInt(document.ConfirmClaim.MM.value);
   var pts1 = parseInt(document.ConfirmClaim.PTS1.value);
   var hpts1 = parseInt(document.ConfirmClaim.HPTS1.value);

   if (clubid==0) {
      alert("You must select the launch point for this flight!");
      return false;
   }
   if (dd==-1 || mm==-1) {
      alert("You must enter the date of your flight!");
      return false;
   }      
   if (z!="") {
   		alert("Your flight date either does not exist or lies in the future!");
       return false;
   }
   var fdd = document.ConfirmClaim.FDD.value;
   var fmm = document.ConfirmClaim.FMM.value;
   var fyy = document.ConfirmClaim.FYY.value;
   var dc = document.ConfirmClaim.DUPCNT.value;
   document.ConfirmClaim.MULTI.value="False";
   
   var rc = false;
	if (dc>0) {
		if (dc==1) {
			var dupdt = document.ConfirmClaim.DUPDATE.value;
			var xdd = Number(dupdt.substring(0,2));
			var xmm = Number(dupdt.substring(3,5));
			var xyy = Number(dupdt.substring(6,10));
			if (xdd==fdd && xmm==fmm && xyy==fyy) {
				rc=true;
			}		
		} else {
			for (i = 0; i < dc; i++){    		
				dupdt = document.ConfirmClaim.DUPDATE[i].value;
				var xdd = Number(dupdt.substring(0,2));
				var xmm = Number(dupdt.substring(3,5));
				var xyy = Number(dupdt.substring(6,10));
				if (xdd==fdd && xmm==fmm && xyy==fyy) {
					rc=true;
					break;
				}
			}	
   		}
		if (rc==true) {
			var msg = "These flight details have already been submitted to the ladder!";
			msg = msg + "\n\nPlease click OK if this claim is part of a multiple lap task";
			msg = msg + "\nor click CANCEL to quit";
			var rc = confirm(msg);
			if (rc==false) {
				msg = "You must delete the duplicate flight first, then resubmit";
				alert(msg);
				return false;
			}
			document.ConfirmClaim.MULTI.value="True";
		}
   }
	return true;
}
     
function ValidDate(yy,mm,dd) {
  switch (mm) {
    case 2 :
      var x = yy/4
      var y = Math.ceil(x)
      if (y-x>0) {
         var maxdd = 28;
      }else{
         var maxdd = 29;
      } 
      break;  
    case 4 :
      var maxdd = 30;
      break;
    case 6 :
      var maxdd = 30;
      break;
    case 9 :
      var maxdd = 30;
      break;
    case 11 :
      var maxdd = 30;
      break;
    default:
      var maxdd = 31;
      break;
  }  
  if (dd > maxdd) {
     return false;
  }else{
     return true;
  }   
}
  
function getCalendarDay() {
  var n = this.getDay();
  var dow = new Array(7);
  dow[0] = "Sunday";
  dow[1] = "Monday";  
  dow[2] = "Tuesday";   
  dow[3] = "Wednesday";
  dow[4] = "Thursday";
  dow[5] = "Friday";
  dow[6] = "Saturday";
  return dow[n];   
}

function popClubInfo() {
  window.open('ClubInfo.htm','ClubInfo','titlebar=no,toolbar=no,scrollbars=no,status=no,width=460,height=230');
  return false;  
}

function popPhotoInfo() {
  window.open('PhotoInfo.htm','ClubInfo','titlebar=no,toolbar=no,scrollbars=no,status=no,width=440,height=200');
  return false;  
}

function popVersionInfo() {
  window.open('VersionInfo.htm','VersionInfo','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=400');
  return false;  
}

function popInfo2003() {
  window.open('Info2003.htm','VersionInfo','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=400');
  return false;  
}

function popup2() {
  window.open('PopUp2.htm','DistanceLadder','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=no,status=no,width=450,height=220');
  return false;  
}

function popup3() {
  window.open('PopUp3.htm','Quadrilaterals','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=470,height=550');
  return false;  
}

function popup4() {
  window.open('PopUp4.htm','GPSLandouts','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=300');
  return false;  
}
function popup5(z) {
  window.open('PopUp5.asp?LogFile='+z,'DistanceLadder','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=no,status=no,width=450,height=220');
  return false;  
}
function popup6() {
  window.open('PopUp6.htm','News','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=410,height=550');
  return false;  
}
function popup7() {
  window.open('PopUp7.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=400');
  return false;  
}

function popup8() {
  window.open('PopUp8.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=550');
  return false;  
}

function popup9() {
  window.open('PopUp9.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=320');
  return false;  
}

function popup10() {
  window.open('PopUp10.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=400');
  return false;  
}

function popup11() {
  window.open('PopUp11.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=330');
  return false;  
}

function popup12() {
  window.open('PopUp12.htm','Info','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=270');
  return false;  
}

function popup13() {
  window.open('PopUp13.htm','Info','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=350');
  return false;  
}

function popup14() {
  window.open('PopUp14.htm','Info','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=200');
  return false;  
}

function popup15() {
  window.open('PopUp15.htm','Info','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=310');
  return false;  
}

function popup16() {
  window.open('PopUp16.htm','Info','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=280');
  return false;  
}

function popup17() {
  window.open('PopUp17.htm','Forum','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=350');
  return false;  
}

function popup18() {
  window.open('PopUp18.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=520');
  return false;  
}

function popup19() {
  window.open('PopUp19.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=750');
  return false;  
}

function popup20() {
  window.open('PopUp20.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=520');
  return false;  
}
function popup21() {
  window.open('PopUp21.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=400,height=520');
  return false;  
}
function popup22() {
  window.open('PopUp22.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=460');
  return false;  
}
function popup23() {
  window.open('PopUp23.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=520');
  return false;  
}
function popup24() {
  window.open('PopUp24.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=520');
  return false;  
}
function popup25() {
  window.open('PopUp25.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=420');
  return false;  
}
function popup26() {
  window.open('PopUp26.htm','Info','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,status=no,width=420,height=420');
  return false;  
}
function popUpdateInfo() {
  window.open('UpdateInfo.htm','UpdateInfo','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=400');
  return false;  
}

function LogonInfo() {
  window.open('LogonInfo.htm','LogonInfo','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=no,status=no,width=380,height=230');
  return false;  
}

function GliderInfo() {
  window.open('GliderInfo.htm','GliderInfo','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=no,status=no,width=380,height=180');
  return false;  
}

function LaunchSiteInfo() {
  window.open('LaunchSiteInfo.htm','LaunchSiteInfo','titlebar=no,menubar=no,resizable=no,toolbar=no,scrollbars=no,status=no,width=380,height=180');
  return false;  
}

function popAwardsInfo() {
  window.open('BGAAwardsInfo.htm','AwardsInfo','titlebar=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,status=no,width=450,height=450');
  return false;  
}

function valreg01() {
  if (document.reg01.ClubID.value == "") {
     alert("Please select a club");
     return false;
  }else{
     return true;
  }
}

function valreg02() {
  var pilotid = parseInt(document.reg02.PilotID.value);
  var fname = Trim(document.reg02.Forename.value);
  var sname = Trim(document.reg02.Surname.value);
  var email = Trim(document.reg02.Email.value);
  var pw = document.reg02.PW.value;
  var pwc = document.reg02.PWC.value;

  if (pilotid < 0) {     
     if (fname=="" || sname=="") {
        alert("Please either select a name from the list or enter family/given names where shown");
        return false;
     } 
  }else{
    if (fname!="" || sname!="") {
        alert("Please EITHER select from the list, OR enter your name in the boxes - not both!");
        return false;
     } 
  }   
       
  if (email=="") {     
     alert("You must provide an email address");
     return false;
  } 
    
  if (strOccurrences(email,"@")!=1) {
     alert("This does not look like a valid Email address!");
     return false;
  }

  if (validPassword(pw)==false) {
     alert("Invalid password - 4-8 digits and/or alphabetic characters only, please!");
     return false;
  }

  if (pw!=pwc) {
     alert("Confirm password not correct - please try again");
     return false;
  }
   
return true;
}

function valEditPilot() {
  var email = document.EditPilot.Email.value;
  var pw = document.EditPilot.PW.value;
  var pwc = document.EditPilot.PWC.value;
      
  if (email=="") {     
     alert("You must provide an email address");
     return false;
  } 
    
  if (strOccurrences(email,"@")!=1) {
     alert("This does not look like a valid Email address!");
     return false;
  }

  if (validPassword(pw)==false) {
     alert("Invalid password - 4-8 digits and/or alphabetic characters only, please!");
     return false;
  }

  if (pw!=pwc) {
     alert("Confirm password not correct - please try again");
     return false;
  }
   
return true;
}

function show_ladder() {
  var season = document.SelLadder.Season.value;
  var ladder = document.SelLadder.Ladder.value;  
  if (season<="2002/2003" && ladder=="H") {     
     alert("The height ladder is not available for this season");
     return false;
  } 
  return true;
}

function strOccurrences(txt,str){

  var num=-1;
  var pos=0;  
  var i=-1;
  
  while (pos != -1) {
    pos=txt.indexOf(str,i+1)
    num+=1;
    i=pos;
  }

return num;
}

function validPassword(pw){

  var len = pw.length
  var pos=0;
  var i=1;
  var c = "";
  
  if (len < 4 || len > 8) {
     return false;
  }   
  
  while (i<len) {
    c=pw.substr(i,1);
    c=c.toUpperCase()
    if ((c >= "0" && c <= "9") || (c >= "A" && c <= "Z")) {
    }else{
       return false;
    }   
    i+=1
  }
  
return true;
}

function show_myflight(f,y) {
   var x
   x="dscore.asp?FlightID=" + f;
   if (y=="H" || y=="*"){
      window.open(x,"","status=no,location=no,toolbar=no,titlebar=no,menubar=no,scrollbars=yes,resizable=yes,width=495,height=560");
   } else if (y=="C"){   
      window.open(x,"","status=no,location=no,toolbar=no,titlebar=no,menubar=no,scrollbars=yes,resizable=yes,width=495,height=760");
   } else {
      window.open(x,"","status=no,location=no,toolbar=no,titlebar=no,menubar=no,scrollbars=yes,resizable=yes,width=495,height=810");
   }
return false;   
} 

function delete_myflight(cseason,pseason,sseason,mm,dd,f) {  
   if (cseason == sseason) {
         return window.confirm("Are you sure you want to delete this flight?");
   } else {      
   		if (sseason==pseason && mm==1 && dd<=30) {
	      	return window.confirm("Are you sure you want to delete this flight?");
   		} else {	
      		alert("This flight is no longer available for deletion");
      		return false;
   		}
   }   
}

function edit_myflight(cseason,pseason,sseason,mm,dd,f) {  
	if (cseason!=sseason) {
		if(sseason!=pseason || mm!=1 || dd>30) {
  	 		alert("This flight is no longer available for editing");
    		return false;
    	}	
   	}
   	return true;
}

function LoadLadderCombos() {
  var i = 0
  var opts = 7
  var cnt = document.forms[0].LadderCount.value;
  var ClubID=document.forms[0].ClubID.value;
  var LadderID=document.forms[0].Ladder.value;  
  document.forms[0].Ladder.length = opts
  for (i = 0; i <= cnt; i++){
    var LClubID = document.forms[0].LClubID[i].value;
    if (LClubID == ClubID) {
       var x = document.forms[0].LLadderID[i].value;
       var y = document.forms[0].LLadderDesc[i].value;
       if (y != ""){
          opts = opts + 1;
          document.forms[0].Ladder.length = opts;
          document.forms[0].Ladder.options[opts-1].value = x;
          document.forms[0].Ladder.options[opts-1].text = y;
       }
    }    
    if (LClubID > ClubID) break;
  }  
  if (LadderID!="O" && LadderID!="W" && LadderID!="J" && LadderID!="H" && LadderID!="D" && LadderID!="A" ) {
      document.forms[0].Ladder.options[0].selected = true      
  }  
}
function click_rdologger(s,c,p) {
   if (document.Scores.rdoLogger[0].checked) { 
   	document.Scores.LOGONLY.value = "Y";
   } else {	
   	document.Scores.LOGONLY.value = "N";
   }
   var z = show_table(s,c,p);	
}
function show_table(s,c,p) {
   var x=document.Scores.cmbLadder.value;
   var y=""
   var y1=""
   var y2=""
   if (document.Scores.chkExcludeComps.checked){ 
   	y="Y";
   }
   if (document.Scores.chkExcludeTurbos.checked){ 
   	y2="Y";
   }
   y1 = document.Scores.LOGONLY.value;
   if (x=="{NEW}") {
       window.location="SelLadder.asp";
   }
   else {
      window.location="DispLadder.asp?Season="+s+"&ClubID="+c+"&Ladder="+x+"&PageSize="+p+"&ExComps="+y+"&ExTurbos="+y2+"&Log="+y1;
   }
}
function show_tableD(s,c,p) {
   var z=document.Scores.PID.value;
   var y=""
   var y2=""
   if (document.Scores.chkExcludeComps.checked){ 
   		y="Y";
   	}
   if (document.Scores.chkExcludeTurbos.checked){ 
   	y2="Y";
   }   	
   window.location="DispLadder.asp?Season="+s+"&ClubID="+c+"&Ladder=D&PageSize="+p+"&ExComps="+y+"&ExTurbos="+y2+"&PID="+z;
}

function show_myflights() {
   var x=document.MyFlights.MySeason.value;
   window.location="MyFlights.asp?MySeason=" + x;
}

function show_clubscores() {
   var x=document.UpdateTable.SelSeason.value;
   window.location="UpdateTable.asp?MySeason=" + x;
}

function dirty_calculator() {
   document.forms[0].Dirty.value = "True";
}

function submit_claim() {
   if (calculate_score()==false) {	
   	return false;
   }	
   var x = document.forms[0].Dirty.value;
   var g = document.forms[0].Glider.value;
   var pts = document.forms[0].PTS.value;
   var hpts = document.forms[0].HPTS.value;
   var lpts = document.forms[0].PTS.value.length;
   var lhpts = document.forms[0].HPTS.value.length;

   if (pts-0==0 && hpts-0==0) {
      alert("Nothing to submit! Please complete the cross country or height section, click calculate and then submit");
      return false;
   } else if (lhpts==0 && lpts==0) {
      alert("Nothing to submit! Please complete the cross country or height section, click calculate and then submit");
      return false;
   } else if (g==0) {
      alert("Which glider were you flying? Please choose from the list then press the Calculate and Submit buttons again");     
      return false;      
   } else if (x == "True") {
      alert("Flight details have been changed! You must recalculate the score before submitting your claim");     
      return false;
   } else {
     return true;		
   }
}
function click_HLoss(z) {
	if (z=="Y") {
		document.forms[0].HeightLoss.value = "";
		//document.forms[0].DIVHL.visibility = hidden;
	}
	if (z=="N") {
		//document.forms[0].DIVHL.visibility = visible;
	}
	document.forms[0].HLOK.value = z;
	var x= dirty_calculator();
}
function keydown_HL() {
	document.forms[0].chkHL[0].checked = false;  
	document.forms[0].chkHL[1].checked = true;
	document.forms[0].HLOK.value = "N";
	var x= dirty_calculator();
}
function calculate_score() {	
 	//Check time fields
  	var hh = document.forms[0].Hours.value;
	if (isNaN(hh)) {
		alert("Invalid Hours: use numeric characters only please");
		return false;
	}
  	var mm = document.forms[0].Minutes.value;
	if (isNaN(mm)) {
		alert("Invalid Minutes: use numeric characters only please");
		return false;
	}
	if (mm < 0 || mm >= 60) {
		alert("Invalid Minutes: must be between 0 and 60");
		return false;	
	}
  	var ss = document.forms[0].Seconds.value;
	if (isNaN(ss)) {
		alert("Invalid Seconds: use numeric characters only please");
		return false;
	}
	if (ss < 0 || ss >= 60) {
		alert("Invalid Seconds: must be between 0 and 60");
		return false;	
	}
	//XC-only checks
	if (is_xc()==true) {		
		if (document.forms[0].Declared.checked==false) {
			if (document.forms[0].AP.value!="" || (document.forms[0].LatDegA.value !="0" && document.forms[0].LatDegA.value !="")) {
				alert("Point of Abandonment may not be used for Undeclared tasks");
				return false;
			}	
		}
	}
	if (is_xc()==true) {
	  	var z = document.forms[0].HLOK.value;
		ht = document.forms[0].HeightLoss.value;
  		if (z=="Y" && ht=="")  {
			return true;
		}    
		if (z=="Y" && ht!="") {
   			alert("There is no need to specify a height loss if you have clicked '1000m or less'");
   			document.forms[0].HeightLoss.value = "";
			return false;
		}
  		if (z!="N" && z!="Y") {
   			alert("Please provide your cross-country height loss details:\n(start height-finish height) in metres");
			return false;
		}
		if (ht=="") {
			alert("Please enter the actual height loss (start height-finish height) in metres");
			return false;
		}
		if (isNaN(ht)) {
			alert("Invalid Height Loss: use numeric characters only please");
			return false;
		}
		if (ht<=1000) {
			alert("You have indicated that your height loss is over 1000m\nbut your supplied height loss is 1000m or less");
			return false;
		}
	}
	return true;
}

function is_xc() {
	if (document.forms[0].TP1.value!="") {
		return true;
	}
	if (document.forms[0].TP2.value!="") {
		return true;
	}
	if (document.forms[0].TP3.value!="") {
		return true;
	}
	if (document.forms[0].TP4.value!="") {
		return true;
	}
	if (document.forms[0].FP.value!="" && document.forms[0].FP.value!=document.forms[0].SP.value) {
		return true;
	}
	if (document.forms[0].LP.value!="") {
		return true;
	}
	if (document.forms[0].LatDeg.value!="" && document.forms[0].LatDeg.value!="0") {
		return true;
	}
	if (document.forms[0].LatMin.value!="" && document.forms[0].LatMin.value!="0") {
		return true;
	}
	if (document.forms[0].LonDeg.value!="" && document.forms[0].LonDeg.value!="0") {
		return true;
	}
	if (document.forms[0].LonMin.value!="" && document.forms[0].LonMin.value!="0") {
		return true;
	}
	return false;
}

function click_units(p1,p2) {
	if (p1=="L") {
		document.forms[0].LUNITS.value=p2;
	}
	if (p1=="H") {
		document.forms[0].HUNITS.value=p2;
	}
	//alert(document.forms[0].LUNITS.value=p2);
	var rc=dirty_calculator();
}
function count_hts(ladder) {
   var x = 0;
   if (ladder == "O" || ladder == "ALL") {
      if (document.UpdateScores.OH1.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.OH2.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.OH3.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.OH4.checked==true) {
         x = x + 1;    
      }                     
      document.UpdateScores.OHT.value = x
   }
   
   x = 0   
   if (ladder == "W" || ladder == "ALL") {
      if (document.UpdateScores.WH1.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.WH2.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.WH3.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.WH4.checked==true) {
         x = x + 1;    
      }                     
      document.UpdateScores.WHT.value = x      
   } 
   
   x = 0
   if (ladder == "J" || ladder == "ALL") {
      if (document.UpdateScores.JH1.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.JH2.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.JH3.checked==true) {
         x = x + 1;    
      }
      if (document.UpdateScores.JH4.checked==true) {
         x = x + 1;    
      }                     
      document.UpdateScores.JHT.value = x
   }
} 

function check_hts() {
   var oht = document.UpdateScores.OHT.value;
   var wht = document.UpdateScores.WHT.value;
   var jht = document.UpdateScores.JHT.value;

   if (oht>2) {
      alert("You may not specify more than 2 height claims in the Open Ladder!");
      return false;
   } else if (wht>2) {
      alert("You may not specify more than 2 height claims in the Weekend Ladder!");
      return false;
   } else if (jht>2) {
      alert("You may not specify more than 2 height claims in the Junior Ladder!");
      return false;
   } else
      return true;
   }            

function disable_SFText() {
   var pilotid = document.reg02.PilotID.value;
   if (pilotid == -1) {
       document.reg02.Surname.onfocus=""
       document.reg02.Forename.onfocus=""
   }else{
       document.reg02.Surname.value=""
       document.reg02.Surname.onfocus=document.reg02.Surname.blur
       document.reg02.Forename.value=""
       document.reg02.Forename.onfocus=document.reg02.Forename.blur
   }
}

function LTrim(str){
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
       var j=0, i = s.length;
       while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
       j++;
       s = s.substring(j, i);
   }
   return s;
}

function RTrim(str) {
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
       var i = s.length - 1;       // Get length of string
       while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
       i--;
       s = s.substring(0, i+1);
    }
    return s;
}

function Trim(str) {
  return RTrim(LTrim(str));
}  

function set_action(z) {
  document.login.Action.value=z;
  return true;
}  

function set_actionc(){ 
  document.Calculator.Action.value="Calculate";
  return true;
}  

function valfilename() {
  if (document.UploadForm.FileName.value == "") {
     alert("Please select a logger file");
     return false;
  }       
return true;
}

function delete_logger() {  
   return window.confirm("Are you sure you want to delete this flight's logger file?");
}

function override_penalty(cseason,sseason,mm) {
   if (cseason != sseason && mm != "1") {
      alert("This flight is no longer available for modification");
      return false;
   }else{
       return window.confirm("Are you sure you want to override the penalty for this flight?");
   }   
}

function validate_flight(obj,cseason,sseason,mm,fid,pid) {
   if (cseason != sseason && mm != "1") {
      alert("This flight is no longer available for validation");
      return false;
   }   
	if (obj.checked==true) {
  		var m = "I confirm that this claim fully meets current ladder rules";
		m = m+"\nand does not show unapproved airspace penetration";
     	if (window.confirm(m)==false) {
     		return false;
     	}	
	}
	//Validate/unvalidate record
	var url = "validate_flight.asp?FlightID="+fid+"&PilotID="+pid+"&Season="+sseason+"&Validated="+obj.checked;
	window.location=url;
}
function jb(){ 
  return true;
}  

function print_tasksheet() {
  var sp=document.forms[0].SP.value;
  var tp1=document.forms[0].TP1.value;
  var tp2=document.forms[0].TP2.value;
  var tp3=document.forms[0].TP3.value;
  var tp4=document.forms[0].TP4.value;
  var fp=document.forms[0].FP.value;
  var sector=document.forms[0].Sector[0].checked;
  
  if (sector==true) {
     var s = "F";
  } else {   
     var s = "B";
  }
  
  if (sp == "") {
     alert("You must specify a start point!");   
  } else if (fp == "") {
      alert("You must specify a finish point!");
  } else if (tp1 == "" && tp2 == "" && tp3 == "" && tp4 == "" && fp == sp) {
    alert("You must specify a task!");    
  } else {
    var x = "TaskBrief.asp?SP=" + sp + "&TP1=" + tp1 + "&TP2=" + tp2 + "&TP3=" + tp3 + "&TP4=" + tp4 + "&FP=" + fp + "&Sector=" + s;
    var x1=x.replace("#","_")
    window.open(x1,"","scrollbars=yes,resizable=yes,width=700,height=600,left=5,top=5");
  } 
  return false;
}  

function popSurvey() {
  window.open('Survey.asp','Survey','titlebar=no,toolbar=no,scrollbars=yes,status=no,width=680,height=600');
  return false;  
}

function popSurvey01() {
  window.open('comparescores.asp','CompareScores','titlebar=no,toolbar=no,scrollbars=yes,status=no,width=580,height=600');
  return false;  
}

function SubmitSurvey() {
   var c1 = document.forms[0].C1.value;   
   var c2 = document.forms[0].C2.value;   
   var c3 = document.forms[0].C3.value;   
   var c4 = document.forms[0].C4.value;   
   var c5 = document.forms[0].C5.value;   
   var c6 = document.forms[0].C6.value;   
   var c7 = document.forms[0].C7.value;   
   var c8 = document.forms[0].C8.value;   
   var c9 = document.forms[0].C9.value;   
      
   var r2 = getRadioValue(document.forms[0].R2);   
   var r3 = getRadioValue(document.forms[0].R3);   
   var r4 = getRadioValue(document.forms[0].R4);   
   var r5 = getRadioValue(document.forms[0].R5);   
   var r6 = getRadioValue(document.forms[0].R6);   
   var r7 = getRadioValue(document.forms[0].R7);   
   var r8 = getRadioValue(document.forms[0].R8);   
   
   var rc = false;

   if (c1 != "" || c2 != "" || c3 != "" || c4 != "" || c5 != "" || c6 != "" || c7 != "" || c8 != "" || c9 != "") {
       return true;  
   } else if (r2 != "" || r3 != "" || r4 != "" || r5 != "" || r6 != "" || r7 != "" || r8 != ""){   
       return true;      
   } else {
       alert("You haven't provided any input...!");     
       return false;
   }   
}

function getRadioValue(radioObject) {
  var value = ""
  for (var i=0; i<radioObject.length; i++) {
       if (radioObject[i].checked) {
           value = radioObject[i].value;
           break; 
       } 
  }
  return value;      
}

function validate_stewardentry(s) {
  if (s=='2002/2003') {
     return true;
  } else if (document.MyFlights.Height.checked==false) {
     return true;
  } else if (document.MyFlights.Weekend.checked==false && document.MyFlights.Junior.checked==false) {     
     return true;
  } else {
     alert("Height Claims may no longer be included in Weekend and Junior Ladders");
     return false;
  }   
}

function val_searchpilot() {
if (document.Scores.SearchPilot.value == "") {
     alert("Please enter the Pilot's name");
     return false;
  }       
return true;
}

function filter_pilot(z) {
	document.form1.PilotID.value=z;
	document.form1.submit();
	return false;	
}

function valid_login02() {
	var x = document.login.Password.value;
	if (x.length==0) {
		alert("You must logon to view the guide");
		return false;
	}
	return true;		
}

function show_guide() {
	var g = document.login.Guide.value;
	if (g=='True') {
   	   window.open('StewardGuide.htm','StewardGuide','titlebar=no,toolbar=no,scrollbars=yes,status=no,width=530,height=600');
   	   return false;
	}	
}

function reset_enq_default() {
	var selfld = document.form1.SortField.value;
	var selfld2 = document.form1.SortField2.value;
	
	if (document.form1.SortOrder[0].checked) {
		var selord = document.form1.SortOrder[0].value;
	} else {
		var selord = document.form1.SortOrder[1].value;
	}

	if (document.form1.SortOrder2(0).checked) {
		var selord2 = document.form1.SortOrder2[0].value;
	} else {
		var selord2 = document.form1.SortOrder2[1].value;
	}

	var chkfld = document.form1.ckSortField.value;
	var chkfld2 = document.form1.ckSortField2.value;
	var chkord = document.form1.ckSortOrder.value;
	var chkord2 = document.form1.ckSortOrder2.value;

	var tf = true;
	if (selfld!=chkfld) {
		tf=false;
	}
	if (selfld2!=chkfld2) {
		tf=false;
	}
	if (selord!=chkord) {
		tf=false;
	}
	if (selord2!=chkord2) {
		tf=false;
	}
	document.form1.chkDefault.checked=tf;
}

function set_month_combo() {
	var season = document.forms[0].Season.value;
	document.forms[0].Month.options[0].value = "0";
  	document.forms[0].Month.options[0].text = "{All Months}";

	if (season=="2005/2006") {
		document.forms[0].Month.length = 16;
	 	for (i = 1; i <= 15; i++){
	 		if (i<4) {
			 	document.forms[0].Month.options[i].value = i+12;
			 	document.forms[0].Month.options[i].text = monthname(i+9)+" 2005";
			} else {
			 	document.forms[0].Month.options[i].value = i-3;
			 	document.forms[0].Month.options[i].text = monthname(i-3)+" 2006";				
			}	 	
	 	}
	} else {
		if (season < "2005/2006") {
			var s1 = season.substring(0,4);
			var s2 = season.substring(5,9);
			document.forms[0].Month.length = 13;
		 	for (i = 1; i <= 12; i++){
		 		if (i<4) {
				 	document.forms[0].Month.options[i].value = i+9;
				 	document.forms[0].Month.options[i].text = monthname(i+9)+" "+s1;
				} else {
				 	document.forms[0].Month.options[i].value = i-3;
				 	document.forms[0].Month.options[i].text = monthname(i-3)+" "+s2;				
				}
		 	
		 	}
		} else {
			document.forms[0].Month.length = 13;
		 	for (i = 1; i <= 12; i++){
			 	document.forms[0].Month.options[i].value = i;
			 	document.forms[0].Month.options[i].text = monthname(i)+" "+season;					 	
		 	}
		}
	}
	document.forms[0].Month.options[0].selected = true
}

function monthname(mm) {
	var mmm="";
	switch (mm) {
		case 1: 
			mmm="January";
			break;
		case 2: 
			mmm="February";
			break;
		case 3: 
			mmm="March";
			break;
		case 4: 
			mmm="April";
			break;
		case 5: 
			mmm="May";
			break;
		case 6: 
			mmm="June";
			break;
		case 7: 
			mmm="July";
			break;
		case 8: 
			mmm="August";
			break;
		case 9: 
			mmm="September";
			break;
		case 10: 
			mmm="October";
			break;
		case 11: 
			mmm="November";
			break;
		case 12: 
			mmm="December";
			break;
	}	
	return mmm;
}

function sort_racing(d) {
	document.form1.SORTBY.value = d;
	document.form1.submit();
}

function sort_summary(cs) {
	document.form1.COLSORT.value = cs;
	document.form1.submit();
}

function click_addcmt() {
	var z =	document.form1.LOGGEDON.value;
	if (z != "True") {
		alert("You must be logged on to add a comment")
		return false;
	}
	document.form1.ACTION.value = "A";	
	document.form1.submit();

}

function click_viewcmt() {
	document.form1.ACTION.value = "V";	
	document.form1.submit();
}

function click_nocmt() {
	document.form1.ACTION.value = "";	
	document.form1.submit();
}

function click_btncmt() {
	var z =	document.form1.txtCmt.value;
	if (z=="") {
		alert("Please provide a comment....");
		return false;
	}
	return true;	
}	

function click_delcmt(id,del) {
	var z =	document.form1.LOGGEDON.value;
	var z1 = document.form1.ADMLOGGEDON.value;
	if (z1!="True") {
		if (z!="True") {
			alert("You must be logged on to delete a comment")
			return false;
		}
		if (del!="Y") {
			alert("Only the pilot or comment author may delete this comment")
			return false;
		}
	}	
	var m = "Are you sure you want to delete this comment?"
	m = m+"\nClick OK to Continue or Cancel to Quit"
	if (confirm(m)) {
		document.form1.ACTION.value = "D";	
		document.form1.CMTID.value = id;	
		document.form1.submit();
	}	
}

function valid_WPform() {
var z=document.form1.Trigraph.value;
if (z=="") {
	alert("Please enter a Trigraph");
	return false;
}
if (z.length>3 || z.length<1) {
	alert("Trigraph must be 1-3 characters");
	return false;
}

cnt=document.forms[0].ZTrigraph.length;
if(cnt>0) {  	
	for (i=0;i<=cnt-1;i++) {
		var ztp = document.forms[0].ZTrigraph[i].value;   					
		if ("*"+z.toUpperCase()==ztp) {	   		
			alert("Trigraph ["+ztp+"] already exists in your library.\nPlease select another trigraph.");
			return false;
		}
	}		
}

var z=document.form1.Name.value;
if (z=="") {
	alert("Please enter a waypoint name");
	return false;
}
var z=document.form1.LatD.value;
if (z=="" || isNaN(z)) {
	alert("Please enter degrees latitude");
	return false;
}
var x = new Number(z);
var y = x.toFixed();
if (y<0 || y>89) {
	alert("Degrees latitude must lie between 0 and 90");
	return false;
}
document.form1.LatD.value = y;

var z=document.form1.LatM.value;
if (z=="" || isNaN(z)) {
	alert("Please enter minutes latitude");
	return false;
}
var x = new Number(z);
var y = x.toFixed(3);
if (y<0 || y>=60) {
	alert("Minutes latitude must lie between 0 and 60");
	return false;
}
document.form1.LatM.value = y;

var z=document.form1.LonD.value;
if (z=="" || isNaN(z)) {
	alert("Please enter degrees longitude");
	return false;
}
var x = new Number(z);
var y = x.toFixed();
if (y<0 || y>89) {
	alert("Degrees longitude must lie between 0 and 90");
	return false;
}
document.form1.LonD.value = y;

var z=document.form1.LonM.value;
if (z=="" || isNaN(z)) {
	alert("Please enter minutes longitude");
	return false;
}
var x = new Number(z);
var y = x.toFixed(3);
if (y<0 || y>=60) {
	alert("Minutes longitude must lie between 0 and 60");
	return false;
}
document.form1.LonM.value = y;


return true;
}
//-->
