
function copystatus(){
    window.status="© 2006 The Golf Association of Philadelphia.   All Rights Reserved.";
};

function netscapeKeyPress(e) {
        //alert (e.which);
};

function check(button,i) {
	var pval = form1["na" + i].value
	//alert(
	if (button.checked && pval == button.value) {
	button.checked=false;
		form1["na" + i].value = "x"
		button.checked=false;
	}
	else
	{	
		form1["na" + i].value = button.value
	}

};

function swaponeimage(loc,img) {
  if (document.images) {
	document[loc].style.visibility = "visible";
    document[loc].src = img
  }
  return false;
}

  
function launch(url,name) {
  window.open(url, name);
};

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function chkVal(TheForm,TheFld,Val)	{
	
	if(Left(Val,1) == "<") {TheForm[TheFld].value = "";}	
};

function chkVal2(TheForm,TheFld,Val,nVal)	{
	
	if(Val == "") {TheForm[TheFld].value = nVal;}	
};

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 validate(form) {
ini = form.ini.value;
if (ini=='') 
	{
		alert('Your initials are a required field. Please enter before Submitting.');
		return false;
	}
else
	{
		if (form.bAccept.checked==false)
			{
				alert('You must check that you certify the information is accurate.');
				return false;
			}
	}
}

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 userConfirm() { 
	return window.confirm ("Are you sure you want to delete this record?") 
} ;

function userConfirmMsg(msg) { 
	var newmsg = msg
	return window.confirm(newmsg) 
} ;

function userConfirmSubmitForm2(msg) { 
	var newmsg = msg
	var x = window.confirm(newmsg)
	if (x) {
		document.form2.submit();
				
	} 
	
	
	
} ;

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 launchRpt(url,name,cmd,fmt,yr) {
	var loc = url + '?cmd=' + cmd + '&yr=' + yr + '&rfmt=' + fmt
  window.open(loc, name);
};

function launchRpt2(url,name,sdate,fmt,edate) {
	var loc = url + '?sdate=' + sdate + '&edate=' + edate + '&rfmt=' + fmt
  window.open(loc, name);
};

function popup(url,name,h,w) {
  window.open(url, name, 'left=340,top=80,width=' + w + ',height=' + h + ',scrollbars,resizable');
}

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 Clickheretoprint(title)
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=800, height=600, left=100, top=25"; 
  var content_vlue2 = document.getElementById("print_content").innerHTML; 

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>The Golf Association of Philadelphia (www.gapgolf.org)</title>'); 
   docprint.document.write('<link rel="stylesheet" type="text/css" href="http://www.gapgolf.org/menu.css">')
   docprint.document.write('<link rel="stylesheet" type="text/css" href="http://www.gapgolf.org/style.css">')
   docprint.document.write('<link rel="stylesheet" type="text/css" href="http://www.gapgolf.org/generic.css">')
   docprint.document.write('<link rel="stylesheet" type="text/css" href="http://www.gapgolf.org/login.css">')
  
   docprint.document.write('</head><body onLoad="self.print()"><center>');  
   
   
   
   //docprint.document.write('<div id="container2">'); 
   docprint.document.write('<div class=titleweb style="width:98%;text-transform:uppercase;">' + title + '</div>'); 
   //docprint.document.write('<div id="underlap"></div>'); 
   docprint.document.write('</div>'); 
   
   
   docprint.document.write('<div>');          
   docprint.document.write(content_vlue2);        
   docprint.document.write('</div></center></body></html>');
   docprint.document.close(); 
   docprint.focus(); 
}

function visiList(nr)
{
	
	
		if (document.layers)
		{
			vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
			dista = (document.layers[nr].visibility == 'hide') ? '' : 'none'
			document.layers[nr].visibility = vista;
			document.layers[nr].display = dista;
		}
		else if (document.all)
		{
			vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
			dista = (document.all[nr].style.visibility == 'hidden') ? '' : 'none';
			document.all[nr].style.visibility = vista;
			document.all[nr].style.display = dista;
		}
		else if (document.getElementById)
		{
			vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
			dista = (document.getElementById(nr).style.visibility == 'hidden') ? '' : 'none';
			document.getElementById(nr).style.visibility = vista;
			document.getElementById(nr).style.display = dista;
		}
	
}

function visiMenu(nr,bt)
{	
		if (document.layers)
		{
			vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
			dista = (document.layers[nr].visibility == 'hide') ? '' : 'none'
			visbt = (document.layers[nr].visibility == 'hide') ? '-' : '+'
			document.layers[nr].visibility = vista;
			document.layers[nr].display = dista;
			document.layers[bt].value = visbt;
		}
		else if (document.all)
		{
			vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
			dista = (document.all[nr].style.visibility == 'hidden') ? '' : 'none';
			visbt = (document.all[nr].style.visibility == 'hidden') ? '-' : '+';
			document.all[nr].style.visibility = vista;
			document.all[nr].style.display = dista;
			document.all[bt].value = visbt;
		}
		else if (document.getElementById)
		{
			vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
			dista = (document.getElementById(nr).style.visibility == 'hidden') ? '' : 'none';
			visbt = (document.getElementById(nr).style.visibility == 'hidden') ? '+' : '-';
			document.getElementById(nr).style.visibility = vista;
			document.getElementById(nr).style.display = dista;
			document.getElementById(bt).value = visbt;
			
			
		}
		//alert(visbt);
	
}

function matchdd(theForm)
{
	var val = theForm.altglnum.options[theForm.altglnum.selectedIndex].value;
	document.all['mdd'].style.visibility = 'hidden';
	document.all['mdd'].style.display = 'none';	
	document.all['memdd'].style.visibility = 'hidden';
	document.all['memdd'].style.display = 'none';	
	
	if (val==2) {
		document.all['mdd'].style.visibility = 'visible';
		document.all['mdd'].style.display = '';
	}
	if (val==3) {
		document.all['memdd'].style.visibility = 'visible';
		document.all['memdd'].style.display = '';
	}
	
}

function visi(nr)
{
 
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';		
		document.getElementById(nr).style.visibility = vista;

	}
}


function visibRM(nr)
{
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
		document.getElementById(nr).style.visibility = vista;

	}
}

function hidetip() {
    if (document.layers)
        document.tooltip.visibility="hidden";
}


function submitform(form,url) {
   form.action= url;   
   form.submit();  
}

function disableButton(theButton)
{
 theButton.value="Processing...";
 theButton.disabled = true; 
}

function sendValue(s,fld)
{
	var selvalue = s.value;
	window.opener.document.form1.fld.value = selvalue;
	window.close();
}

function fMoveDown(yr)
{
	var cyYear = yr;
	var lyYear = form2.cyYear.value;
	var lyoncamp = form2.cyoncamp.value;
	var lyoffcamp = form2.cyoffcamp.value;
	var lycommute = form2.cycommute.value;
	
	form2.lyYear.value = lyYear
	form2.lyoncamp.value = lyoncamp
	form2.lyoffcamp.value = lyoffcamp
	form2.lycommute.value = lycommute
	form2.cyYear.value = cyYear
	form2.cyoncamp.value = ''
	form2.cyoffcamp.value = ''
	form2.cycommute.value = ''

}

function Form_Validator(theForm)
{
   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);
}

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 netscapeKeyPress(e) {
        //alert (e.which);
}


function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function SetFieldValue(TheForm,radio,fld,nval) {
	//this is based on a 0/1 radio value
	
	var val = TheForm[radio].value;
	//alert(val);
	if(val==1) {
		TheForm[fld].value = nval
	} else {
		TheForm[fld].value = ''
	}


}

function VerifyTeamSrchForm(theForm)
{
	var x = theForm.inum.value;
	if (getCheckedValue(theForm.pid)=="") 	{
	 alert("Please select the Registrant.");
	 return (false);	  }
	if (getCheckedValue(theForm.pid2)=="") 	{
	 alert("Please select Player 2.");
	 return (false);	  }
	if(x>2){
		if (getCheckedValue(theForm.pid3)=="") 	{
		alert("Please select Player 3.");
		return (false);	  }	
	} 
	if(x>3){
		if (getCheckedValue(theForm.pid4)=="") 	{
		alert("Please select Player 4.");
		return (false);	  }	
	} 

}

function VerifyTeamForm(theForm)
{
	if (theForm.fname.value == "" && theForm.lname.value == "" && theForm.ghin.value == "")	  {
	 alert("Please enter a name or GHIN # for all players.");
	 theForm.ghin.focus();
	 return (false);	  }
	 
	if (theForm.fname2.value == "" && theForm.lname2.value == "" && theForm.ghin2.value == "")	  {
	 alert("Please enter a name or GHIN # for all players.");
	 theForm.ghin2.focus();
	 return (false);	  }

}







