
function url(p_path){return p_path;}
function isNumberKey(evt){var charCode=(evt.which)?evt.which:31;if(charCode>31&&(charCode<48||charCode>57)&&charCode!=63272&&charCode!=63234&&charCode!=63235&&charCode!=63232&&charCode!=63234){return false;}
return true;}
var RegForm={startMonth:5,endMonth:4,divisionPrevious:[0,0,0,0,0],allowUpgrades:false,init:function(){for(var i=0;i<=4;i++){RegForm.updateDivision(i,true);}
$('.player-team').change(function(){var theId=$(this).attr('id').replace(/player-team-/,'');RegForm.updateFee(theId);});$('.player-year').change(function(){var theId=$(this).attr('id').replace(/player-year-/,'');RegForm.updateDivision(theId,false);});$('.player-month').change(function(){var theId=$(this).attr('id').replace(/player-month-/,'');RegForm.updateDivision(theId,false);});$('.player-day').keypress(function(e){return isNumberKey(e);});$('[name=payment-type]').change(function(){if($(this).val()==4){$('button[name=register]').html('Register <span class="amp">&amp;</span> Pay');}else{$('button[name=register]').html('Register <span class="amp">&amp;</span> Print');}});},updateFee:function(rowId){var theValue=$('#player-team-'+rowId).val();if(theValue!='0'&&theValue!=null){$('#fee-'+rowId).html('$'+prices[theValue]);}else{$('#fee-'+rowId).html('');}
RegForm.updateTotal();},updateTotal:function(){var theTotal=0;$('.price').each(function(){var thePrice=parseInt($(this).html().replace(/\$/,''));if(thePrice>0){theTotal=theTotal+thePrice;}});$('#total strong').html('$'+theTotal);},updateDivision:function(rowId,init){var theMonth=parseInt($('#player-month-'+rowId).val());var theYear=parseInt($('#player-year-'+rowId).val());var theDivision=0;$('#player-team-'+rowId).attr('disabled',false);var theDate=new Date();theDate.setFullYear(theYear);theDate.setMonth(theMonth);var totalYears=years.length;for(var i=0;i<totalYears;i++){var dateStart=new Date();dateStart.setFullYear(years[i][1]);dateStart.setMonth(RegForm.startMonth,1);var endDate=new Date();endDate.setFullYear(years[i][2]);endDate.setMonth(RegForm.endMonth,30);if(theDate>=dateStart&&theDate<=endDate){theDivision=years[i][0];break;}}
$('#player-team-'+rowId+' option').each(function(){$(this).attr('disabled',true);});$('#opt-challenger-'+rowId).attr('disabled',false);$('#player-team-'+rowId+' option[value="'+theDivision+'"]').attr('disabled',false);if(RegForm.allowUpgrades){if(theDivision==18){$('#opt-rookie-'+rowId).attr('disabled',false);}else if(theDivision==19){$('#opt-minor-'+rowId).attr('disabled',false);}}
$('#player-month-'+rowId+' option').attr('disabled',false);if(theYear==$('#player-year-'+rowId+' option:eq(1)').val()){for(var i=1;i<=4;i++){$('#player-month-'+rowId+' option:eq('+i+')').attr('disabled',true);}}else if(theYear==$('#player-year-'+rowId+' option:last').val()){for(var i=13;i>=5;i--){$('#player-month-'+rowId+' option:eq('+i+')').attr('disabled',true);}}
if(init){if($('#player-team-'+rowId).val()!=25){if(RegForm.allowUpgrades){if(theDivision==18&&$('#player-team-'+rowId).val()==19){$('#player-team-'+rowId).val(19);}else if(theDivision==19&&$('#player-team-'+rowId).val()==20){$('#player-team-'+rowId).val(20);}else{$('#player-team-'+rowId).val(theDivision);}}else{$('#player-team-'+rowId).val(theDivision);}}}else{if(prices[theDivision]!=null){if(theDivision!=RegForm.divisionPrevious[rowId]){$('#player-team-'+rowId).val(theDivision);RegForm.divisionPrevious[rowId]=theDivision;}}else{$('#player-team-'+rowId).val(0);}}
RegForm.updateFee(rowId);}}
if(document.getElementById&&jQuery){$('#age-boundaries').remove();$(document).ready(function(){RegForm.init();});}
