// JavaScript Document

// Dreamweaver functions for navigation menu buttons.

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// LAC Registration functions

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


var MotherAddress = "";
var MotherCity = "";
var MotherState = "";
var MotherStateIndex = 0;
var MotherZipCode = "";
var EmergFirstName = "";
var EmergLastName = "";
var EmergPhone = "";
var EmergRelation = "";
var FamilyDoctor = "";
var FamilyDoctorPhone = "";
var FamilyDentist = "";
var FamilyDentistPhone = "";

function InitSaveVariables(form) {

MotherAddress = form.txtMotherAddress.value;
MotherCity = form.txtMotherCity.value;
MotherZipCode = form.txtMotherZipCode.value;
MotherStateIndex = form.sltMotherState.selectedIndex;
MotherState = form.sltMotherState[MotherStateIndex].value;

}

function copyAddress(form) {

	if (form.chkSameAddress.checked) {
		InitSaveVariables(form);

		form.txtMotherAddress.value = form.txtFatherAddress.value;
		form.txtMotherCity.value = form.txtFatherCity.value;
		form.txtMotherZipCode.value = form.txtFatherZipCode.value;
		form.sltMotherState.selectedIndex = form.sltFatherState.selectedIndex;

	} else {

		form.txtMotherAddress.value = MotherAddress;
		form.txtMotherCity.value = MotherCity;
		form.txtMotherZipCode.value = MotherZipCode;       
		form.sltMotherState.selectedIndex = MotherStateIndex;

   	}
}

function InitSaveVariables(form) {

EmergFirstName = form.txtEmerg1FirstName.value;
EmergLastName = form.txtEmerg1LastName.value;
EmergPhone = form.txtEmerg1Phone.value;
EmergRelation = form.txtEmerg1Relation.value;
FamilyDoctor = form.txtFamilyDoctor1.value;
FamilyDoctorPhone = form.txtFamilyDoctor1Phone.value;
FamilyDentist = form.txtFamilyDentist1.value;
FamilyDentistPhone = form.txtFamilyDentist1Phone.value;

}

function myReload()
{
  window.location.reload();
}

function GoHome(){
  document.location = "default.htm";
}


function updateForm(){
  document.frmPayment.submit();
}

function checkPriceLimit(){

   var tempString = "";
   var priceString = "";
   var priceStringValue = 0;
   var priceStringValueReduced = 100;
   var indexDollarSign = 0;
   var indexPeriod = 0;
   var priceLength = 0;
   var beginString = "";
   var endString = "";
   var diffPriceStringValue = 0;
   var tempStringDiff = "";
   var tempStringReduced = "";
   var priceDiff = "";
   var priceReduced = "";
   
   tempString = document.getElementById('totalPrice').innerHTML;
   indexDollarSign = tempString.indexOf('$');
   indexPeriod = tempString.indexOf('.');
   priceLength = indexPeriod - (indexDollarSign + 1);
   beginString = tempString.substr(0, (indexDollarSign + 1));
   endString = tempString.substr(indexPeriod);
   priceString = tempString.substr((indexDollarSign + 1), priceLength);
   priceStringValue = Number(priceString);
   if(priceStringValue > 100){
	 //priceStringValueReduced = 100;
	 diffPriceStringValue = priceStringValue - priceStringValueReduced;
	 priceString = String(priceStringValue);
	 priceDiff = String(diffPriceStringValue);
	 priceReduced = String(priceStringValueReduced);
	 tempString = "";
	 tempStringDiff = "";
	 tempStringReduced = "";
	 tempString = tempString.concat(beginString, priceString, endString);
	 tempStringDiff = tempStringDiff.concat(beginString, "-", priceDiff, endString);
	 tempStringReduced = tempStringReduced.concat(beginString, priceReduced, endString);
	 document.getElementById('totalPriceMax').innerHTML = "$100 MAXIMUM";
	 document.getElementById('totalPrice').innerHTML = tempString;
	 document.getElementById('diffPrice').innerHTML = tempStringDiff;
	 document.getElementById('maxPrice').innerHTML = tempStringReduced;
   } else {
     priceString = String(priceStringValue);
     tempString = "";
     tempString = tempString.concat(beginString, priceString, endString);
	 document.getElementById('totalPriceMax').innerHTML = "";
     document.getElementById('totalPrice').innerHTML = tempString;
     document.getElementById('diffPrice').innerHTML = "";
     document.getElementById('maxPrice').innerHTML = "";
   }
}

function teeballOrPeewee(form){
var PlayerDivisionTeeBall = "";
var PlayerDivisionPeeWee = "ALL SIX (6) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF TEE-BALL TO BE ELIGIBLE FOR PEE-WEE LEAGUE.";
var PlayerDivision1314 = "ALL FOURTEEN (14) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF 13-14 BOYS LEAGUE TO BE ELIGIBLE FOR 15 & OLDER BOYS LEAGUE.";
var PlayerDivision = "";
var PlayerDivisionIndex = 0;
var TotalPrice = "";
var indexDollarSign = 0;
var currentPrice = "";
var indexOnes = 0;
var currentTotalPrice = "";
var currentTotalPriceValue = 0;
var currentPlayerPrice = 0;
var updatedPriceString = "";
var beginString = "";
var endString = "";
var updatedPriceString = "";
var revisedTotalPrice = "";
var priceLength = 0;
var numberPlayers = 0;

  
  if(form.sltDivision[form.sltDivision.selectedIndex].value == "Tee-Ball"){
    document.getElementById('peeweeNotifyRestrictions').innerHTML = "";
	document.getElementById('leaguePrice').innerHTML = "&nbsp;&nbsp;$25.00";
	//document.all.totalPrice.innerHTML = "&nbsp;&nbsp;$.00<br>";
	TotalPrice = document.getElementById('totalPrice').innerHTML;
	currentTotalPrice = TotalPrice.substr(13, 2);
	indexDollarSign = TotalPrice.indexOf('$');
	indexPeriod = TotalPrice.indexOf('.');
	priceLength = indexPeriod - (indexDollarSign + 1);
	//document.all.totalPrice.innerHTML = 
	beginString = TotalPrice.substr(0, (indexDollarSign + 1));
	endString = TotalPrice.substr(indexPeriod);
	currentTotalPrice = TotalPrice.substr((indexDollarSign + 1), priceLength);
	currentTotalPriceValue = Number(currentTotalPrice);
	currentTotalPriceValue = currentTotalPriceValue - 15;
    updatedPriceString = String(currentTotalPriceValue);
	revisedTotalPrice = "";
	revisedTotalPrice = revisedTotalPrice.concat(beginString, updatedPriceString, endString);
	document.getElementById('totalPrice').innerHTML = revisedTotalPrice;
	
  } else {
    document.getElementById('peeweeNotifyRestrictions').innerHTML = "ALL SIX (6) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF TEE-BALL TO BE ELIGIBLE FOR PEE-WEE LEAGUE.";
	document.getElementById('leaguePrice').innerHTML = "&nbsp;&nbsp;$40.00";
	TotalPrice = document.getElementById('totalPrice').innerHTML;
	currentTotalPrice = TotalPrice.substr(13, 2);
	indexDollarSign = TotalPrice.indexOf('$');
	indexPeriod = TotalPrice.indexOf('.');
	priceLength = indexPeriod - (indexDollarSign + 1);
	//document.all.totalPrice.innerHTML = 
	
	beginString = TotalPrice.substr(0, (indexDollarSign + 1));
	endString = TotalPrice.substr(indexPeriod);
	currentTotalPrice = TotalPrice.substr((indexDollarSign + 1), priceLength);
	currentTotalPriceValue = Number(currentTotalPrice);
	currentTotalPriceValue = currentTotalPriceValue + 15;
    updatedPriceString = String(currentTotalPriceValue);
	revisedTotalPrice = "";
	revisedTotalPrice = revisedTotalPrice.concat(beginString, updatedPriceString, endString);
	document.getElementById('totalPrice').innerHTML = revisedTotalPrice;
	
  }
  checkPriceLimit();
}

function fourteenOrFifteen(form){
var PlayerDivisionTeeBall = "";
var PlayerDivisionPeeWee = "ALL SIX (6) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF TEE-BALL TO BE ELIGIBLE FOR PEE-WEE LEAGUE.";
var PlayerDivision1314 = "ALL FOURTEEN (14) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF 13-14 BOYS LEAGUE TO BE ELIGIBLE FOR 15 & OLDER BOYS LEAGUE.";
var PlayerDivision = "";
var PlayerDivisionIndex = 0;
var TotalPrice = "";
var indexDollarSign = 0;
var currentPrice = "";
var indexOnes = 0;
var currentTotalPrice = "";
var currentTotalPriceValue = 0;
var currentPlayerPrice = 0;
var updatedPriceString = "";
var beginString = "";
var endString = "";
var updatedPriceString = "";
var revisedTotalPrice = "";
var priceLength = 0;

  if(form.sltDivision2[form.sltDivision2.selectedIndex].value == "13-14 Boys"){
    document.getElementById('thirteenFourteenNotifyRestrictions').innerHTML = "";
	document.getElementById('leaguePrice2').innerHTML = "&nbsp;&nbsp;$55.00";
	//document.all.totalPrice.innerHTML = "&nbsp;&nbsp;$.00<br>";
	TotalPrice = document.getElementById('totalPrice').innerHTML;
	
	indexDollarSign = TotalPrice.indexOf('$');
	indexPeriod = TotalPrice.indexOf('.');
	//currentTotalPrice = TotalPrice.substr(13, 2);
	priceLength = indexPeriod - (indexDollarSign + 1);
	//document.all.totalPrice.innerHTML = 
	beginString = TotalPrice.substr(0, (indexDollarSign + 1));
	endString = TotalPrice.substr(indexPeriod);
	currentTotalPrice = TotalPrice.substr((indexDollarSign + 1), priceLength);
	currentTotalPriceValue = Number(currentTotalPrice);
	currentTotalPriceValue = currentTotalPriceValue - 10;
    updatedPriceString = String(currentTotalPriceValue);
	revisedTotalPrice = "";
	revisedTotalPrice = revisedTotalPrice.concat(beginString, updatedPriceString, endString);
	document.getElementById('totalPrice').innerHTML = revisedTotalPrice;
	
  } else {
    document.getElementById('thirteenFourteenNotifyRestrictions').innerHTML = "ALL FOURTEEN (14) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF 13-14 BOYS LEAGUE TO BE ELIGIBLE FOR 15 & OLDER LEAGUE.";
	document.getElementById('leaguePrice2').innerHTML = "&nbsp;&nbsp;$65.00";
	TotalPrice = document.getElementById('totalPrice').innerHTML;
	//currentTotalPrice = TotalPrice.substr(13, 2);
	indexDollarSign = TotalPrice.indexOf('$');
	indexPeriod = TotalPrice.indexOf('.');
	priceLength = indexPeriod - (indexDollarSign + 1);
	//document.all.totalPrice.innerHTML = 
	beginString = TotalPrice.substr(0, (indexDollarSign + 1));
	endString = TotalPrice.substr(indexPeriod);
	currentTotalPrice = TotalPrice.substr((indexDollarSign + 1), priceLength);
	currentTotalPriceValue = Number(currentTotalPrice);
	currentTotalPriceValue = currentTotalPriceValue + 10;
    updatedPriceString = String(currentTotalPriceValue);
	revisedTotalPrice = "";
	revisedTotalPrice = revisedTotalPrice.concat(beginString, updatedPriceString, endString);
	document.getElementById('totalPrice').innerHTML = revisedTotalPrice;
	
  }
  checkPriceLimit();
}

function InitSaveLeaguePrice(form) {

PlayerPrice = form.playerPriceString.value;
PlayerDivisionIndex = form.sltDivision.selectedIndex;
PlayerDivision = form.sltDivision[PlayerDivisionIndex].value;

}

function changeDivision(form) {

  if (form.sltDivision[PlayerDivisionIndex].value == "Tee-Ball") {
  
  //InitSaveLeaguePrice(form);

  form.playerPriceString.value = "";
  form.peeweeNotifyRestriction.value = "";
  } else if(form.sltDivision2[PlayerDivisionIndex].value == "13-14 Boys") {
  
  //InitSaveLeaguePrice(form);

  form.playerPriceString.value = "";
  form.thirteenFourteenNotifyRestriction.value = "";
  } else {
  form.playerPriceString.value = "";
  form.peeweeNotifyRestriction.value = "ALL SIX (6) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF TEE-BALL TO BE ELIGIBLE.";
  }
  /*
  if (form.sltDivision2[PlayerDivisionIndex].value == "13-14 Boys") {
  
  //InitSaveLeaguePrice(form);

  form.playerPriceString.value = "";
  form.thirteenFourteenNotifyRestriction.value = "";
  } 
  else {
  form.playerPriceString.value = "";
  form.thirteenFourteenNotifyRestriction.value = "ALL FOURTEEN (14) YEAR OLDS MUST HAVE PARTICIPATED IN AT LEAST ONE (1) YEAR OF 13-14 BOYS LEAGUE TO BE ELIGIBLE.";
  }
  */
}
function FreezeScreen(msg){
  scroll(0,0);
  var outerPane = document.getElementById('FreezePane');
  var innerPane = document.getElementById('InnerFreezePane');
  if (outerPane) outerPane.className = 'FreezePaneOn';
  if (innerPane) innerPane.innerHTML = msg;
}

function printMe(){
  window.print();
}

function submitForm(isValid){
  if (isValid){
	FreezeScreen('Processing Payment Confirmation . . . . . . Please Wait.');
    document.frmPayment.submit();
  }
}

function validateCheckNumber(){

  var valid = true;
  
  if ((document.frmPayment.txtCheckNumber.value == "") && (document.frmPayment.sltPaymentType.value == "Personal Check")){
  //if (document.frmPayment.sltPaymentType.value == "Personal Check"){
    alert("Please fill in your check number in the space above.");
	valid = false;  
  }
  
  return valid;
}

function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
  			{alert(alerttxt);return false}
		else {return true}
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(txtCheckNumber,"Please enter a check/order number in the space provided to continue!")==false)
  			{txtCheckNumber.focus();return false}
		else {FreezeScreen('Processing Payment Confirmation . . . . . . Please Wait.');
    		  document.frmPayment.submit();}
	}
}

function formatPaymentType(form){
  if(form.sltPaymentType.value == "Personal Check"){
    document.getElementById('paymentFormat').innerHTML = 'Check No.:';
	document.getElementById('paymentString').innerHTML = 'Please write the following confirmation code in the memo portion of your check.<br>(See Example below)'; 
	document.getElementById('imagePayment').innerHTML = '<img src=\"images/example_check.jpg\" width=\"390\" height=\"233\">';
  }
  if(form.sltPaymentType.value == "Money Order"){
    document.getElementById('paymentFormat').innerHTML = 'Order No.:';
	document.getElementById('paymentString').innerHTML = 'Please write the following confirmation code in the memo portion of your money order.<br>(See Example below)';
	document.getElementById('imagePayment').innerHTML = '<img src=\"images/example_money_order.jpg\" width=\"307\" height=\"300\">';
  }
}

function interruptRegistration(pageLink) {

	var choice = confirm('\n       Your registration is not yet complete.\r\n\n   Are you sure you want to exit registration?\r\n\n \n');
	var alertMsg = '';
	
	if (choice){
	    alertMsg = '\n       Your registration has been cancelled.\r\n\n      Please register with us at another time.\r\n\n \n'; 
		alert(alertMsg);
		
		window.location = pageLink;
	}
	/*
	else{
		alertMsg = '\tPlease continue with your current registration.\r\n\r\n';
		alert(alertMsg);
	}
	*/
}