
function copystatus(){
    window.status="© 2004 The Pennsylvania Golf Association.   All Rights Reserved.";
};

  
function launch(url,name) {
  window.open(url, name);
};

function userConfirm() { 
	return window.confirm ("Are you sure you want to delete this record?") 
} ;

function userConfirmF() { 
	return window.confirm ("Are you sure you want to remove the this file?") 
} ;

function userConfirmVal(msg,val) { 
	var newmsg = msg + ": " + val
	return window.confirm(newmsg) 
} ;

function userConfirmMsg(msg) { 
	var newmsg = msg
	return window.confirm(newmsg);
}

function popup(url,name,h,w) {
  window.open(url, name, 'left=340,top=80,width=' + w + ',height=' + h + ',scrollbars,resizable');
}

function limitext(TheForm,TheFld,Val,len,max)	{
	var maxlength = max;
	var currlength = len;	
	if(maxlength < currlength) {
		TheForm[TheFld].value = TheForm[TheFld].value.substring(0, maxlength);
		alert("Maximum Character Limit Met - " + maxlength);		
	}
};

function replace(string,text,by) {
    // Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function showtip(current,e,text) {
   if (document.all)
   {
      thetitle=text.split('<br>')
      if (thetitle.length > 1) {
        thetitles=""
        for (i=0; i<thetitle.length; i++)
           thetitles += thetitle[i] + "\r\n"
        current.title = thetitles
      }
      else current.title = text
    }
   else if (document.layers) {
       document.tooltip.document.write( 
           '<layer bgColor="#FFFFE7" style="border:1px ' +
           'solid black; font-size:12px;color:#000000;">' + text + '</layer>')
       document.tooltip.document.close()
       document.tooltip.left=e.pageX+5
       document.tooltip.top=e.pageY+5
       document.tooltip.visibility="show"
    }
}

function hidetip() {
    if (document.layers)
        document.tooltip.visibility="hidden";
}


function submitform(form,url) {
   form.action= url;   
   form.submit();  
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function disableButton(theButton)
{
 theButton.value="Processing...";
 theButton.disabled = true; 
}

function Form_Validator(theForm)
{
	var ismemb = parseFloat(theForm.ismemb.value);
	//alert(theForm.hindex1.value == "");
	if ((ismemb == 0) && (theForm.ptid.value != 2)) {
		if (theForm.hindex1.value == "") {
			alert("Please enter your \"Handicap Index\".");
			theForm.hindex1.focus();
			return (false);	
		} else {
			if (parseFloat(theForm.maxindx.value) < parseFloat(theForm.hindex1.value)) {
				alert("Your Handicap does not met the Index Requirement for this Tournament.");
				return (false);	
			}
		}
		var club1 = parseFloat(theForm.clubid1.value);
		if((club1 == 0) &&(theForm.ClubOth1.value == "")) {
			alert("Please provide your \"Club Affiliation\".");
			theForm.ClubOth1.focus();
			return (false);	
		}
		if ((getCheckedValue(theForm.hcprov1) == 0)&&(theForm.hcproth1.value == "")) {
			alert("Please provide your \"Handicap Provider\".");
			theForm.hcproth1.focus();
			return (false);			
		}	
	}
	
	//check multiple players
	var nump = parseFloat(theForm.nump.value);
	if (nump != 1) {	
		var i=1
		for (i=1;i<=nump;i++)
		{		
			if (theForm["hindex" + i].value == "") {
				alert("Please enter a \"Handicap Index\" for Player " + i + ".");
				//theForm["hindex" + i].focus();
				return (false);	
				break;
			} else {
				if (parseFloat(theForm.maxindx.value) < parseFloat(theForm["hindex" + i].value)) {
					alert("Player " + i + " Handicap does not met the Index Requirement for this Tournament.");
					//theForm["hindex" + i].focus();
					return (false);	
					break;
				}
			}
			if (theForm["ClubName" + i].value == "") {
				alert("Please enter a \"Club Affiliation\" for Player " + i + ".");
				theForm["ClubName" + i].focus();
				return (false);	
				break;
			}
						
		}		
	}
	//check billing info
   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 < 15))	{
    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);	  }
    
  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 \"Daytime Phone #\" field.");
    theForm.phbiz.focus();
    return (false);	  }
  
  return (true);
}
