function Form_Validator(theForm)
{
   if (theForm.bname.value == "")	  {
    alert("Please enter a value for the \"Cardholder Name\" field.");
    theForm.bname.focus();
    return (false);	  }

	// alter if allowing amex
   if ((theForm.x_card_num.value == "") || (theForm.x_card_num.value.length != 16))	{
    alert("Please enter a valid \"Credit Card Number\".");
    theForm.x_card_num.focus();
    return (false);	    }
    
    
  if ((theForm.x_card_code.value == "") || (theForm.x_card_code.value.length < 3)) {
    alert("Please enter a valid \"Security Code\".");
    theForm.x_card_code.focus();
    return (false);	  }
    
  if ((theForm.expmo.value == "") || (theForm.expyr.value == "")) {
    alert("Please enter a value for the \"Card Expiration\".");
    theForm.expmo.focus();
    return (false);	  
  }  else {
    
		var now = new Date();	// this function is designed to be Y2K compliant.
		var mo = theForm.expmo.value;
		var yr = theForm.expyr.value
        var expiresIn = new Date(yr,mo,0,0,0);		// create an expired on date object with valid thru expiration date
        expiresIn.setMonth(expiresIn.getMonth());		// adjust the month, to first day, hour, minute & second of expired month
        if( now.getTime() > expiresIn.getTime() ) {
       
			alert("Your Credit Card appears to have Expired.");
			theForm.expmo.focus();
			return (false);	  
		}
    }
    
  if ((theForm.baddr.value == "") || (theForm.bcity.value == "") || (theForm.bstate.value == "") || (theForm.bzip.value == "")) {
    alert("Please enter your Complete \"Billing Address\".");
    theForm.baddr.focus();
    return (false);	  }
    
  if (theForm.phbiz.value == "") {
    alert("Please enter a value for your \"Billing Phone #\" field.");
    theForm.phbiz.focus();
    return (false);	  } 
  return (true);
}

function ValidateEntry(theForm)
{	
   if (theForm.ismemb.value == "n") {
	// for non-members only - single player
		if (theForm.hindex1.value == "") {
		   alert("Please enter a value for your \"Current Index\".");
		   theForm.hindex1.focus();
		   return (false);	  }
		if (theForm.indxmax.value != 0){
			if (parseFloat(theForm.hindex1.value) > parseFloat(theForm.indxmax.value)) {
			   alert("This Event has a maximum handicap index limit of " + theForm.indxmax.value + ".");
			   theForm.hindex1.focus();
		       return (false);	  }
		}
		if (theForm.ClubOth1.value == "") {
		   alert("Please enter a value for your \"Club Affiliation\".");
		   theForm.ClubOth1.focus();
		   return (false);	  }  
   }
  	if (theForm.nump.value == 1)	{
        if (theForm.ismemb.value == "y")	{
	        var club = theForm.clubid.options[theForm.clubid.selectedIndex].value;
	        if (club == 0) {	
            alert("Please indicate your \"Club Affiliation\".");
            return (false);	  }}}
   
  	if (theForm.nump.value == 2)	{
        if (theForm.ismemb.value == "y")	{
	        var club = theForm.clubid2.options[theForm.clubid2.selectedIndex].value;
	        if (club == 0) {	
            alert("Please indicate your \"Club Affiliation\".");
            return (false);	  }}}
            
   if ((theForm.evid.value == "22") && (theForm.PartnerFirstName.value.length < 1))	{
    alert("Please enter a valid \"Partner First Name (Male)\".");
    theForm.PartnerFirstName.focus();
    return (false);	  }   
    
   if ((theForm.evid.value == "22") && (theForm.PartnerLastName.value.length < 1))	{
    alert("Please enter a valid \"Partner Last Name (Male)\".");
    theForm.PartnerLastName.focus();
    return (false);	  }   
    
    
   if ((theForm.evid.value == "22") && (theForm.AGANum.value.length < 1))	{
    alert("Please enter a valid \"Partner AGA #\".");
    theForm.AGANum.focus();
    return (false);	  }      
                   
   if (theForm.bname.value == "")	  {
    alert("Please enter a value for the \"Cardholder Name\" field.");
    theForm.bname.focus();
    return (false);	  }	

   if ((theForm.x_card_num.value == "") || (theForm.x_card_num.value.length != 16))	{
    alert("Please enter a valid \"Credit Card Number\".");
    theForm.x_card_num.focus();
    return (false);	  }
    
  if ((theForm.x_card_code.value == "") || (theForm.x_card_code.value.length < 3)) {
    alert("Please enter a valid \"Security Code\".");
    theForm.x_card_code.focus();
    return (false);	  }
    
    
  var min=1;
  var max = 12;
  var num = parseInt(theForm.expmo.value);
  if (min > num || max < num) {
    alert(num + ' is not a valid month. Please enter a month between ' + min + ' and ' + max + '.');
    theForm.expmo.focus();
    return false;    }    
    
  var dateVar = new Date();
  var minyr = dateVar.getFullYear();
  var maxyr = minyr + 15;
  var numyr = parseInt(theForm.expyr.value);
  if (minyr > numyr || maxyr < numyr) {
    alert('Please enter a year between ' + minyr + ' and ' + maxyr) + '.';
    theForm.expyr.focus();    
    return false;    }    
    
  if ((theForm.expmo.value == "") || (theForm.expyr.value == "")) {
    alert("Please enter a value for the \"Card Expiration\".");
    theForm.expmo.focus();
    return (false);	  	  
  }  else {
    
		var now = new Date();	// this function is designed to be Y2K compliant.
		var mo = theForm.expmo.value;
		var yr = theForm.expyr.value
        var expiresIn = new Date(yr,mo,0,0,0);		// create an expired on date object with valid thru expiration date
        expiresIn.setMonth(expiresIn.getMonth());		// adjust the month, to first day, hour, minute & second of expired month
        if( now.getTime() > expiresIn.getTime() ) {
       
			alert("Your Credit Card appears to have Expired.");
			theForm.expmo.focus();
			return (false);	  
		}
    }
    
  if ((theForm.baddr.value == "") || (theForm.bcity.value == "") || (theForm.bstate.value == "") || (theForm.bzip.value == "")) {
    alert("Please enter your Complete \"Billing Address\".");
    theForm.baddr.focus();
    return (false);	  }
    
  if (theForm.email.value == "") {
    alert("Please enter a value for your \"E-Mail Address\".");
    theForm.email.focus();
    return (false);	  }
    
  if (theForm.phbiz.value == "") {
    alert("Please enter a value for your \"Billing Phone #\".");
    theForm.phbiz.focus();
    return (false);	  }
    
  if (theForm.chkqual.value == 1) {
	var q = theForm.qevid1.options[theForm.qevid1.selectedIndex].value;
	if ( q == 0 ) {
		alert("Please indicate your preferred \"Qualifier Location\".");
	 return (false);	  }
  }
  return (true);
}

function ValidateCCData(theForm)
{	      
   if (theForm.fname.value == "" || theForm.lname.value == "")	  {
    alert("Please enter a value for the \"Cardholder Name\" field.");
    theForm.fname.focus();
    return (false);	  }
	// alter if allowing amex
   if ((theForm.x_card_num.value == "") || (theForm.x_card_num.value.length != 16))	{
    alert("Please enter a valid \"Credit Card Number\".");
    theForm.x_card_num.focus();
    return (false);	  }
    
  if ((theForm.x_card_code.value == "") || (theForm.x_card_code.value.lengthh < 3)) {
    alert("Please enter a valid \"Security Code\".");
    theForm.x_card_code.focus();
    return (false);	  }
    
  if ((theForm.expmo.value == "") || (theForm.expyr.value == "")) {
    alert("Please enter a value for the \"Card Expiration\".");
    theForm.expmo.focus();
    return (false);	  	  
  }  else {
    
		var now = new Date();	// this function is designed to be Y2K compliant.
		var mo = theForm.expmo.value;
		var yr = theForm.expyr.value
        var expiresIn = new Date(yr,mo,0,0,0);		// create an expired on date object with valid thru expiration date
        expiresIn.setMonth(expiresIn.getMonth());		// adjust the month, to first day, hour, minute & second of expired month
        if( now.getTime() > expiresIn.getTime() ) {
       
			alert("Your Credit Card appears to have Expired.");
			theForm.expmo.focus();
			return (false);	  
		}
    }
    
  if ((theForm.baddr.value == "") || (theForm.bcity.value == "") || (theForm.bstate.value == "") || (theForm.bzip.value == "")) {
    alert("Please enter your Complete \"Billing Address\".");
    theForm.baddr.focus();
    return (false);	  }
    
  if (theForm.phbiz.value == "") {
    alert("Please enter a value for your \"Billing Phone #\".");
    theForm.phbiz.focus();
    return (false);	  }
     
  return (true);
}


function VerifyTeamSrchForm(theForm)
{
	if (getCheckedValue(theForm.pid)=="") 	{
	 alert("Please select the Registrant.");
	 return (false);	  }
	if (getCheckedValue(theForm.pid2)=="") 	{
	 alert("Please select Player 2.");
	 return (false);	  }

}

function VerifyTeamForm(theForm)
{
	if (theForm.fname.value == "" && theForm.lname.value == "" && theForm.ghin.value == "")	  {
	 alert("Please enter a name or CDGA # for both players.");
	 theForm.ghin.focus();
	 return (false);	  }
	 
	if (theForm.fname2.value == "" && theForm.lname2.value == "" && theForm.ghin2.value == "")	  {
	 alert("Please enter a name or CDGA # for both players.");
	 theForm.ghin2.focus();
	 return (false);	  }

}

function VerifySemForm(theForm)
{		 
	if (theForm.fname.value == "" || theForm.lname.value == "")	  {
	 alert("Please enter your \"Full Name\".");
	 theForm.fname.focus();
	 return (false);	  }
		 
	if (theForm.addr1.value == "" || theForm.city.value == "" || theForm.state.value == "" || theForm.zip.value == "" )	  {
	 alert("Please enter your complete \"Address\".");
	 theForm.addr1.focus();
	 return (false);	  }	
		 
	if (theForm.email.value == "")	  {
	 alert("Please enter a valid \"Email Address\".");
	 theForm.email.focus();
	 return (false);	  }    
      	
  return (true);
}




