var EventViewBootStrapper={guestDialog:null,linkEventDialog:null,gcalDialog:null,load:function(b,a){var c=b.lastIndexOf("/");b=b.slice(0,c+1);c=a.lastIndexOf("/");a=a.slice(0,c+1);ProgressBar.init("#statusSection");this.initGuestDialog(b);this.initLinkToDialog(b);this.initGCalDialog(a);$("#viewMap").click(function(h){WaitCursor.show(this);h.preventDefault();var d=$(h.target).attr("addr");var g=$(h.target).attr("lat");var f=$(h.target).attr("lng");GeoUserMapper.init(g,f,d);$("#basicModalContent").modal({position:["10%",],onOpen:GeoUserMapper.open,onClose:GeoUserMapper.close})})},initGuestDialog:function(a){GuestDialog.initialize(a);if(!this.guestDialog){this.guestDialog=new InplaceDialog(GuestDialog.getInplaceDialogOptions(),GuestDialog.addGuestValidate)}this.guestDialog.bindEvents()},initLinkToDialog:function(a){LinkToEventDialog.initialize(a);if(!this.linkEventDialog){this.linkEventDialog=new InplaceDialog(LinkToEventDialog.getInplaceDialogOptions(),LinkToEventDialog.selectLinkUrl)}this.linkEventDialog.bindEvents()},initGCalDialog:function(a){GoogleCalendarDialog.initialize(a);if(!this.gcalDialog){this.gcalDialog=new InplaceDialog(GoogleCalendarDialog.getInplaceDialogOptions(),null)}this.gcalDialog.bindEvents()}};var AccountInviteBootStrapper={accountInviteForm:null,load:function(b){var a=b.lastIndexOf("/");b=b.slice(0,a+1);ProgressBar.init("#statusSection");this.accountInviteForm=new AccountInviteForm(b);this.accountInviteForm.bindBehavior.apply(this.accountInviteForm)}};var AuthorizeUserBootStrapper={authorizeForm:null,load:function(b){var c=b.url.lastIndexOf("/");var a=b.url.slice(0,c+1);b.action=b.url.slice(c+1,b.url.length);ProgressBar.init("#statusSection");this.authorizeForm=new AuthorizeUserForm(a,b,b.focus);this.authorizeForm.bindBehavior.apply(this.authorizeForm)}};var ForgotPasswordBootStrapper={form:null,load:function(a){var c=a.url.lastIndexOf("/");var b=a.url.slice(0,c+1);a.action=a.url.slice(c+1,a.url.length);ProgressBar.init("#statusSection");this.form=new UserProfileRemoteForm(b,a,a.focus);this.form.bindBehavior.apply(this.form)}};var PollBootStrapper={pollVoteForm:null,load:function(a){var b=a.lastIndexOf("/");a=a.slice(0,b+1);ProgressBar.init("#statusSection");this.pollVoteForm=new PollVoteForm(a);this.pollVoteForm.bindBehavior.apply(this.pollVoteForm)}};var TeamInfoBootStrapper={createTeamForm:null,teamRenderer:null,teamInfoUrlBase:null,selectedTeamId:null,selectedEventId:null,createMode:null,lastSelectedRoster:null,load:function(c,a){var b=c.lastIndexOf("/");c=c.slice(0,b+1);ProgressBar.init("#statusSection");this.teamInfoUrlBase=c;this.createTeamForm=new TeamCreateForm(c);this.teamRenderer=new TeamDetailRenderer(a);this.createTeamForm.bindBehavior.apply(this.createTeamForm);this.bindAllActions();this.triggerRosterFetch(this.selectedTeamId,this.selectedEventId,this.createMode)},triggerRosterFetch:function(teamId,eventId,createMode){if(createMode){this.toggleCreateModeElements(0);ProgressBar.hide()}else{if(teamId==0){ProgressBar.hide();this.toggleCreateModeElements(2);return}var self=this;var teamDetailUrl=$.format("{0}teamDetail/",this.teamInfoUrlBase);var params={id:teamId,event:0};if(eventId!=0){params.event=eventId}$("#rosterFetchForm [name='selectedRoster']").attr("disabled","true");$.get(teamDetailUrl,params,function(data){self.toggleCreateModeElements(1);var jsonData=eval("("+data+")");if(jsonData.rmResponse.status==200){self.teamRenderer.renderAllTeamData(jsonData)}else{ProgressBar.hide();$("#generalTeamErrorMessage").html(jsonData.rmResponse.message).removeClass("hiddenItem").show()}})}},readyToFetchRoster:function(c,b,a){this.selectedTeamId=c;this.selectedEventId=b;this.createMode=a},bindAllActions:function(){var self=this;$("#createNewTeam").click(function(e){self.toggleCreateModeElements(0);$("input[@name='teamGender']:nth(0)").attr("checked","checked");$("input[@name='name']").focus()});$("#noRosterCreateNewTeam").click(function(e){self.toggleCreateModeElements(0);$("input[@name='teamGender']:nth(0)").attr("checked","checked");$("input[@name='name']").focus()});$(".showTeamDetailLink").click(function(e){var link=$(this);var teamId=$(link).attr("id");var postUrl=$.format("{0}teamDetail",self.teamInfoUrlBase);var params={id:teamId};ProgressBar.show();self.selectedTeamId=teamId;self.toggleCreateModeElements(1);self.teamRenderer.toggleRosterDropdown(false);$.get(postUrl,params,function(data){var jsonData=eval("("+data+")");self.teamRenderer.renderAllTeamData(jsonData)})});$("#rosterFetchForm [name='selectedRoster']").focus(function(){self.lastSelectedRoster=$(this).val()});$("#rosterFetchForm [name='selectedRoster']").change(function(e,ui){var changedRosterId=$(this).val();var viewRosterUrl=$.format("{0}viewRoster",self.teamInfoUrlBase);var params={selectedRoster:changedRosterId,team:self.selectedTeamId};ProgressBar.show();self.teamRenderer.toggleRosterDropdown(false);$.get(viewRosterUrl,params,function(data){var jsonData=eval("("+data+")");ProgressBar.hide();if(jsonData.rmResponse.status==200){self.teamRenderer.toggleRosterDropdown(true);self.teamRenderer.renderPlayerList(jsonData)}else{$("#rosterFetchForm [name='selectedRoster'] option[@selected='selected']").removeAttr("selected");var selectedItem=$.format("#rosterFetchForm [name='selectedRoster'] option[@value='{0}']",self.lastSelectedRoster);$(selectedItem).attr("selected","selected");self.teamRenderer.toggleRosterDropdown(true);$("#rosterChangeErrorMessage").html(jsonData.rmResponse.message).removeClass("hiddenItem").show()}})})},toggleCreateModeElements:function(a){if(a==0){$("#createNewTeamSection").removeClass("hiddenItem").show();$("#teamRosterInfoSection").addClass("hiddenItem").hide();$("#teamRosterDetailSection").addClass("hiddenItem").hide();$("#playerNoRosterSection").addClass("hiddenItem").hide()}else{if(a==1){$("#createNewTeamSection").addClass("hiddenItem").hide();$("#teamRosterInfoSection").removeClass("hiddenItem").show();$("#teamRosterDetailSection").removeClass("hiddenItem").show();$("#playerNoRosterSection").addClass("hiddenItem").hide();$("#guestTeamMessage").addClass("hiddenItem").hide();$("#gameRosterContent").removeClass("hiddenItem").show();$("#rosterChangeErrorMessage").addClass("hiddenItem").hide()}else{$("#createNewTeamSection").addClass("hiddenItem").hide();$("#teamRosterInfoSection").removeClass("hiddenItem").show();$("#teamRosterDetailSection").addClass("hiddenItem").hide();$("#playerNoRosterSection").removeClass("hiddenItem").show()}}$("#retiredTeamMessage").addClass("hiddenItem").hide()}};var UserAccountBootStrapper={profileUpdateForm:null,emailUpdateform:null,passwordChangeForm:null,calendarOptsForm:null,load:function(a){var c=a.url.lastIndexOf("/");var b=a.url.slice(0,c+1);a.urlBase=b;ProgressBar.init("#statusSection");this.profileUpdateForm=new UserProfileRemoteForm(b,a.profile,a.focus);this.profileUpdateForm.bindBehavior.apply(this.profileUpdateForm);this.emailUpdateform=new UserProfileRemoteForm(b,a.emailUpdate,null);this.emailUpdateform.bindBehavior.apply(this.emailUpdateform);this.passwordChangeForm=new UserProfileRemoteForm(b,a.passwordUpdate,null);this.passwordChangeForm.bindBehavior.apply(this.passwordChangeForm);if(a.calendarOpts.loggedInPlayerId&&a.calendarOpts.loggedInPlayerId==1000){this.calendarOptsForm=new CalendarOptionsForm(b,a.calendarOpts,null);this.calendarOptsForm.bindBehavior.apply(this.calendarOptsForm)}}};function InplaceDialog(a,b){this.openDialogId=a.openDialogId;this.closeDialogId=a.closeDialogId;this.updateSectionId=a.updateSectionId;this.actionUrl=a.actionUrl;this.validationStrategy=b}InplaceDialog.prototype.bindEvents=function(){var a=this;$(this.openDialogId).click(function(b){b.preventDefault();a.onLoad(b)});$(document).bind("bindValidationStrategy",function(){a.handleUpdate(a)})};InplaceDialog.prototype.onLoad=function(b){var a=this;ProgressBar.show();var c="id="+$(b.target).attr("params");$.get(this.actionUrl,c,function(d){ProgressBar.hide();$(a.updateSectionId).html(d);$(a.updateSectionId).slideDown("slow");a.handleUpdate(a)})};InplaceDialog.prototype.handleUpdate=function(a){a.handleClose(a);if(a.validationStrategy){a.validationStrategy.apply(a)}};InplaceDialog.prototype.handleClose=function(a){$(a.closeDialogId).click(function(b){b.preventDefault();a.onClose(b)})};InplaceDialog.prototype.onClose=function(){$(this.updateSectionId).fadeOut("slow")};var GuestDialog={addGuestUrl:null,saveGuestUrl:null,validateFormId:"#addGuestForm",openDialogId:"#addGuest",closeDialogId:"#closeGuestDialog",updateSectionId:"#inviteGuestContent",validateUpdateSectionId:"#eventDetailContent",errorHackId:"#inviteGuestContent",initialize:function(a){this.addGuestUrl=a+"addGuest";this.saveGuestUrl=a+"saveGuest"},getInplaceDialogOptions:function(){return{openDialogId:this.openDialogId,closeDialogId:this.closeDialogId,updateSectionId:this.updateSectionId,actionUrl:this.addGuestUrl}},addGuestValidate:function(){$(GuestDialog.validateFormId).validate({messages:{username:{required:"Enter guest email",minlength:"Guest email must be at least 2 characters",maxlength:"Guest email cannot exceed 1024 characters",time:"Enter a valid 12 hour format time"}},rules:{username:{required:true,rangelength:[6,1024]}},errorElement:"span",submitHandler:function(b){var a=$(b).serialize();ProgressBar.show();$.ajax({type:"POST",url:GuestDialog.saveGuestUrl,data:a,success:function(d){ProgressBar.hide();$(GuestDialog.validateUpdateSectionId).html(d);var c=$(GuestDialog.errorHackId);if(c.is(":visible")&&c.children().length>1){$(document).trigger("bindValidationStrategy")}}})}})}};var LinkToEventDialog={actionUrl:null,openDialogId:"#linkToEvent",closeDialogId:"#closeLinkToDialog",updateSectionId:"#eventLinkContent",initialize:function(a){this.actionUrl=a+"linktoEvent"},getInplaceDialogOptions:function(){return{openDialogId:this.openDialogId,closeDialogId:this.closeDialogId,updateSectionId:this.updateSectionId,actionUrl:this.actionUrl}},selectLinkUrl:function(){$("#linkToUrl").click(function(){$(this).select()})}};var GoogleCalendarDialog={actionUrl:null,openDialogId:"#addToGoogleCalendar",closeDialogId:"#closeGCalDialog",updateSectionId:"#googleCalendarContent",initialize:function(a){this.actionUrl=a+"addToGoogleCalendar"},getInplaceDialogOptions:function(){return{openDialogId:this.openDialogId,closeDialogId:this.closeDialogId,updateSectionId:this.updateSectionId,actionUrl:this.actionUrl}}};var WaitCursor={linkTarget:null,linkCursor:null,show:function(a){this.linkCursor=$(a).css("cursor");this.bodyCursor=$("body").css("cursor");this.linkTarget=a;$("body").css("cursor","wait");$(a).css({cursor:"wait"})},reset:function(){$("body").css("cursor",this.bodyCursor);$(this.linkTarget).css({cursor:this.linkCursor})}};var ProgressBar={progressId:null,init:function(a){this.progressId=a},show:function(){$(this.progressId).css("display","block")},hide:function(){$(this.progressId).css("display","none")},toggleSubmitButton:function(c,b,e){if(!e){e="saveProgress"}var d=$.format("#{0}",e);var a=$.format("#{0}",c);if(b){$(a).attr("disabled","disabled");$(d).css("display","inline").show()}else{$(d).css("display","none").hide();$(a).removeAttr("disabled")}},showErrorMessage:function(b,a){var c=$.format("#{0}",b);$(c).text(a).removeClass("hiddenItem").show()},hideErrorMessage:function(a){var b=$.format("#{0}",a);$(b).text("").addClass("hiddenItem").hide()}};var GeoUserMapper={map:null,geocoder:null,addrListItem:'<li><a href="#" id="{0},{1}" addr="{2}">{2}</a></li>',init:function(e,b,a){this.map=new GMap2(document.getElementById("map_canvas"),{size:new GSize(600,300)});this.map.setCenter(new GLatLng(34,0),1);this.geocoder=new GClientGeocoder();if(LatLngAdjuster.isValid(e,b)){var d=new Array(b,e);var c=this.createPlacemark(d,a);this.map.clearOverlays();this.renderMap(c)}else{}},unload:function(){GUnload()},createPlacemark:function(c,a){var b=new Object();b.address=a;b.Point=new Object();b.Point.coordinates=c;return b},toggleLoadProgress:function(a){if(a){$("#map_loading").removeClass("hiddenItem").fadeIn("slow");$("#map_canvas").hide()}else{$("#map_canvas").show();$("#map_loading").addClass("hiddenItem").fadeOut("slow")}},renderMap:function(b){GeoUserMapper.toggleLoadProgress(false);var d=new GLatLng(b.Point.coordinates[1],b.Point.coordinates[0]);var a=new GMarker(d);GeoUserMapper.map.setCenter(d,13);GeoUserMapper.map.setZoom(15);var c={incidents:true};trafficInfo=new GTrafficOverlay(c);GeoUserMapper.map.addOverlay(trafficInfo);GeoUserMapper.map.addOverlay(a);GeoUserMapper.map.addControl(new GLargeMapControl());GeoUserMapper.map.addControl(new GMenuMapTypeControl());GeoUserMapper.map.addControl(new GOverviewMapControl())},open:function(a){a.overlay.fadeIn(200,function(){a.container.fadeIn(400,function(){WaitCursor.reset();a.data.fadeIn(600)})})},close:function(a){a.data.fadeOut(200,function(){a.container.fadeOut(200,function(){a.overlay.fadeOut(200,function(){$.modal.close()})})})},error:function(a){alert(a.statusText)}};var LatLngAdjuster={latitude:"#latitude",longitude:"#longitude",reset:function(){$(this.latitude).val("-1.0");$(this.longitude).val("-1.0")},setCoords:function(b,a){$(this.latitude).val(b);$(this.longitude).val(a)},getLatitude:function(){return $(this.latitude).val()},getLongitude:function(){return $(this.longitude).val()},isValid:function(d,b){var c;var a;if(!d||!b){c=new String(this.getLatitude());a=new String(this.getLongitude())}else{c=new String(d);a=new String(b)}if((c.length>0&&c!="-1.0")&&(a.length>0&&a!="-1.0")){return true}}};function AccountInviteForm(a){this.urlBase=a;this.bound=false;this.formValidator=null}AccountInviteForm.prototype.resetForm=function(){this.formValidator.resetForm();$("#accountInviteForm :input.error").removeClass("error")};AccountInviteForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindFormValidation()}};AccountInviteForm.prototype.bindFormValidation=function(){var self=this;$("#accountInviteForm [name='inviteEmails']").focus();jQuery.validator.messages.required="";this.formValidator=$("#accountInviteForm").validate({debug:true,messages:{inviteNote:{max:1024,maxlength:"Invite note cannot exceed 1024 characters"},inviteEmails:{required:"Enter email address for invitee",minlength:"Enter a valid email address",maxlength:"Email list cannot exceed 2048 characters"}},rules:{inviteEmails:{required:true,rangelength:[6,2048]},inviteNote:{required:false,maxlength:1024}},errorElement:"span",submitHandler:function(form){ProgressBar.hideErrorMessage("accountInviteStatusSection");ProgressBar.hideErrorMessage("accountInviteErrorSection");ProgressBar.toggleSubmitButton("accountInviteBtn",true,"accountInviteSaveProgress");var url=self.urlBase+"saveInvite";var dataString=$(form).serialize();$("#inviteEmails").attr("disabled","disabled");$("#inviteNote").attr("disabled","disabled");$.ajax({type:"POST",url:url,data:dataString,success:function(data){ProgressBar.toggleSubmitButton("accountInviteBtn",false,"accountInviteSaveProgress");$("#inviteEmails").removeAttr("disabled");$("#inviteNote").removeAttr("disabled");var jsonData=eval("("+data+")");if(jsonData.rmResponse.status=="200"){ProgressBar.showErrorMessage("accountInviteStatusSection",jsonData.rmResponse.message);$("#accountInviteForm [name='inviteEmails']").val("").focus();$("#accountInviteForm [name='inviteNote']").val("")}else{$("#accountInviteForm [name='inviteEmails']").val(jsonData.inviteEmails).focus();$("#accountInviteForm [name='inviteNote']").val(jsonData.inviteNote);ProgressBar.showErrorMessage("accountInviteErrorSection",jsonData.rmResponse.message);if(jsonData.rmResponse.status=="202"){ProgressBar.showErrorMessage("accountInviteStatusSection",jsonData.rmResponse.infoMessage)}}}});return false}})};var PhoneNumberUtil={format:function(a){a=a.replace(/\s+/g,"");a=a.replace(/[()-]/g,"");var b="";a=a.split("");for(var c=0;c<a.length;c++){if(c==2||c==5){a[c]=a[c]+"-"}b=b+a[c]}return b},addValidation:function(){jQuery.validator.addMethod("phoneUS",function(a,b){a=a.replace(/\s+/g,"");return this.optional(b)||a.length>9&&a.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/)},"Please specify a valid phone number");$("#primaryPhone").blur(function(){var a=PhoneNumberUtil.format($(this).val());$(this).val(a)})}};function AuthorizeUserForm(c,b,a){this.formUrlBase=c;this.formActionName=b.action;this.formId=b.form;this.primaryFieldId="name";if(a){this.primaryFieldId=a}this.bound=false;this.formValidator=null;this.form=$.format("#{0}",this.formId)}AuthorizeUserForm.prototype.resetForm=function(){this.formValidator.resetForm();var a=$.format("#{0} :input.error",this.formId);$(a).removeClass("error")};AuthorizeUserForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindFormValidation()}};AuthorizeUserForm.prototype.bindFormValidation=function(){var a=this;if(a.primaryFieldId){var b=$.format("#{0} [name='{1}']",a.formId,a.primaryFieldId);$(b).focus()}jQuery.validator.messages.required="";PhoneNumberUtil.addValidation();this.formValidator=$(a.form).validate({debug:true,messages:{name:{min:4,max:128,required:"You must enter a name",maxlength:"Display name cannot exceed 128 characters"},password:{required:"Please provide a password",minlength:"Your password must be at least 6 characters long"},passwordConfirm:{required:"Please provide a password",minlength:"Your password must be at least 6 characters long",equalTo:"Password does not match"}},rules:{name:{required:true,rangelength:[4,128]},password:{required:true,rangelength:[6,20]},passwordConfirm:{required:true,rangelength:[6,20],equalTo:"#password"},primaryPhone:{required:false,phoneUS:true}},errorElement:"span",submitHandler:function(e){var d=$(e.primaryPhone).val();var c=PhoneNumberUtil.format(d);$(e.primaryPhone).val(c);e.action=$.format("{0}{1}",a.formUrlBase,a.formActionName);e.submit()}})};function CalendarOptionsForm(a,c,b){this.formUrlBase=a;this.formActionName=c.action;this.formId=c.form;this.primaryFieldId=b;this.updateSection=$.format("#{0}",c.updateSection);this.saveStatusSection=$($.format("#{0} #saveStatusSection",c.saveProgressId));this.submitButton=$.format("#{0}",c.submitBtnId);this.bound=false;this.formValidator=null;this.bindFieldName="username";this.form=$.format("#{0}",this.formId);this.allEventChangesItem="#allEventChangesItem";this.withEmailNoticeOnlyItem="#withEmailNoticeOnlyItem";this.calendarUrl=c.calendarUrl;this.inAuthVerifyMode=false;this.googAuthUpdateSection="#googAuthUpdateSection";this.googleProgressLoaderId="#googVerifyProgress";this.playerId=c.loggedInPlayerId}CalendarOptionsForm.prototype.resetForm=function(){this.formValidator.resetForm();var a=$.format("#{0} :input.error",this.formId);$(a).removeClass("error")};CalendarOptionsForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindDesktopClickEvents();this.bindGoogleClickEvents();this.bindFormValidation(this.primaryFieldId)}};CalendarOptionsForm.prototype.unbindBehavior=function(){this.bound=false;$("#desktopCalendar").unbind("click");$("googleCalendar").unbind("click")};CalendarOptionsForm.prototype.toggleDesktopControls=function(a){if(a){$(this.allEventChangesItem).removeAttr("disabled");$(this.withEmailNoticeOnlyItem).removeAttr("disabled")}else{$(this.allEventChangesItem).attr("disabled","true");$(this.withEmailNoticeOnlyItem).attr("disabled","true")}};CalendarOptionsForm.prototype.toggleGoogProgressLoader=function(a){if(a){$(this.googleProgressLoaderId).css("display","block")}else{$(this.googleProgressLoaderId).css("display","none")}};CalendarOptionsForm.prototype.toggleAuthUpdateSection=function(a){if(a){$(this.googAuthUpdateSection).css("display","block")}else{$(this.googAuthUpdateSection).css("display","none")}};CalendarOptionsForm.prototype.toggleCalUpdateButton=function(a){if(a){$("#updateCalendarOptionsBtn").removeAttr("disabled")}else{$("#updateCalendarOptionsBtn").attr("disabled","true")}};CalendarOptionsForm.prototype.toggleSaveProgress=function(a){if(a){$(this.saveStatusSection).css("display","inline")}else{$(this.saveStatusSection).css("display","none")}};CalendarOptionsForm.prototype.toggleSubmitButtom=function(a){if(a){$(this.submitButton).removeAttr("disabled")}else{$(this.submitButton).attr("disabled","true")}};CalendarOptionsForm.prototype.bindDesktopClickEvents=function(){var a=this;this.toggleDesktopControls($("#desktopCalendar").is(":checked"));$("#desktopCalendar").click(function(c){var b=$(this).attr("checked");if(b){a.toggleDesktopControls(true)}else{a.toggleDesktopControls(false)}})};CalendarOptionsForm.prototype.bindGoogleClickEvents=function(){var a=this;$("#googleCalendar").click(function(c){var b=$(this).attr("checked");if(b&&!a.inAuthVerifyMode){a.toggleCalUpdateButton(false);a.toggleGoogProgressLoader(true);a.inAuthVerifyMode=true;var d={pid:a.playerId};$.ajax({type:"GET",url:a.calendarUrl,data:d,success:function(e){a.inAuthVerifyMode=false;$("#googleCalendar").attr("checked","checked");a.toggleCalUpdateButton(true);$(a.googAuthUpdateSection).html(e);a.toggleAuthUpdateSection(true);a.toggleGoogProgressLoader(false)}})}else{if(!a.inAuthVerifyMode&&$(a.googAuthUpdateSection).is(":visible")){a.toggleCalUpdateButton(true);a.toggleAuthUpdateSection(false)}}})};CalendarOptionsForm.prototype.bindFormValidation=function(){var a=this;jQuery.validator.messages.required="";this.formValidator=$(a.form).validate({debug:false,messages:{},rules:{},errorElement:"span",submitHandler:function(b){var c=$.format("{0}{1}",a.formUrlBase,a.formActionName);var d=$(b).serialize();a.toggleSaveProgress(true);a.toggleSubmitButtom(false);$.post(c,d,function(e){a.unbindBehavior();$(a.updateSection).html(e);a.bindBehavior();a.toggleSaveProgress(false);a.toggleSubmitButtom(true)})}})};function UserProfileRemoteForm(a,c,b){this.formUrlBase=a;this.formActionName=c.action;this.formId=c.form;this.primaryFieldId=b;this.updateSection=$.format("#{0}",c.updateSection);this.saveStatusSection=$($.format("#{0} #saveStatusSection",c.saveProgressId));this.submitButton=$.format("#{0}",c.submitBtnId);this.bound=false;this.formValidator=null;this.bindFieldName="username";this.form=$.format("#{0}",this.formId)}UserProfileRemoteForm.prototype.resetForm=function(){this.formValidator.resetForm();var a=$.format("#{0} :input.error",this.formId);$(a).removeClass("error")};UserProfileRemoteForm.prototype.toggleSaveProgress=function(a){if(a){$(this.saveStatusSection).css("display","inline")}else{$(this.saveStatusSection).css("display","none")}};UserProfileRemoteForm.prototype.toggleSubmitButtom=function(a){if(a){$(this.submitButton).removeAttr("disabled")}else{$(this.submitButton).attr("disabled","true")}};UserProfileRemoteForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindFormValidation(this.primaryFieldId)}};UserProfileRemoteForm.prototype.unbindBehavior=function(){this.bound=false};UserProfileRemoteForm.prototype.bindFormValidation=function(){var a=this;if(a.primaryFieldId){var b=$.format("#{0} [name='{1}']",a.formId,a.primaryFieldId);$(b).focus()}jQuery.validator.messages.required="";PhoneNumberUtil.addValidation();this.formValidator=$(a.form).validate({debug:true,messages:{username:{required:"An email address is required"},name:{min:4,max:128,required:"You must enter a name",maxlength:"Display name cannot exceed 128 characters"},fullname:{min:4,max:128,required:"You must enter a name",maxlength:"Display name cannot exceed 128 characters"},password:{required:"Please provide a password",minlength:"Your password must be at least 6 characters long"},passwordConfirm:{required:"Please provide a password",minlength:"Your password must be at least 6 characters long",equalTo:"Password does not match"}},rules:{username:{required:true,email:true},name:{required:true,rangelength:[4,128]},fullname:{required:true,rangelength:[4,128]},password:{required:true,rangelength:[6,20]},passwordConfirm:{required:true,rangelength:[6,20],equalTo:"#password"},primaryPhone:{required:false,phoneUS:true}},errorElement:"span",submitHandler:function(e){var d=$(e.primaryPhone).val();var c=PhoneNumberUtil.format(d);$(e.primaryPhone).val(c);var f=$.format("{0}{1}",a.formUrlBase,a.formActionName);var g=$(e).serialize();a.toggleSaveProgress(true);a.toggleSubmitButtom(false);$.post(f,g,function(h){a.unbindBehavior();$(a.updateSection).html(h);a.bindBehavior();a.toggleSaveProgress(false);a.toggleSubmitButtom(true)})}})};function PollVoteForm(a){this.urlBase=a;this.bound=false;this.formValidator=null}PollVoteForm.prototype.resetForm=function(){this.formValidator.resetForm();$("#pollVoteForm :input.error").removeClass("error")};PollVoteForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindFormValidation()}};PollVoteForm.prototype.bindFormValidation=function(){var a=this;jQuery.validator.messages.required="";this.formValidator=$("#pollVoteForm").validate({submitHandler:function(e){ProgressBar.hideErrorMessage("pollVoteStatusSection");ProgressBar.hideErrorMessage("pollVoteErrorSection");var d=0;$("#pollVoteForm [name='pollAnswer']").each(function(){if(this.checked){d+=1;return false}});if(d<1){ProgressBar.showErrorMessage("pollVoteErrorSection","You need to submit an answer to record your vote for this poll.");return false}ProgressBar.toggleSubmitButton("pollVoteButton",true,"pollVoteSaveProgress");var b=a.urlBase+"vote";var c=$(e).serialize();ProgressBar.show();$.ajax({type:"POST",url:b,data:c,success:function(f){ProgressBar.hide();ProgressBar.toggleSubmitButton("pollVoteButton",false,"accountInviteSaveProgress");ProgressBar.showErrorMessage("pollVoteStatusSection","Your vote has been recorded.");$("#pollResultSection #poll-container").replaceWith(f)}});return false}})};function TeamCreateForm(a){this.urlBase=a;this.bound=false;this.formValidator=null}TeamCreateForm.prototype.resetForm=function(){this.formValidator.resetForm();$("#teamCreateForm :input.error").removeClass("error")};TeamCreateForm.prototype.bindBehavior=function(){if(!this.bound){this.bound=true;this.bindDropdowns();this.bindFormValidation()}};TeamCreateForm.prototype.bindDropdowns=function(){$("#teamCreateForm #state").change(function(a){$(a.target).blur();$(a.target).focus()});$("#teamCreateForm #sportType").change(function(a){var b=$(this).val();if(b==127){$("#teamCreateForm #sportTypeOtherSection").show()}else{if($("#teamCreateForm #sportTypeOtherSection").is(":visible")){$("#teamCreateForm #sportTypeOtherSection").hide()}}})};TeamCreateForm.prototype.bindFormValidation=function(){$("#teamCreateForm [name='name']").focus();$.validator.addMethod("stateProvince",function(a){return(a.length==2)});$("#teamCreateForm").validate({messages:{name:{required:"Enter team name",minlength:"Team name must be at least 2 characters"},city:{required:"Enter team's home city",minlength:"City must be at least 2 characters"},sportTypeOther:{required:"Sport name must be filled in",minlength:"Sport name must be at least 2 characters"},state:{stateProvince:"Select a valid State/Province"}},rules:{name:{required:true,minlength:2,maxlength:128},city:{required:true,minlength:2,maxlength:60},sportTypeOther:{required:function(a){return $("#teamCreateForm #sportType option:selected").val()==127}}},errorElement:"span",submitHandler:function(a){a.submit()}})};function TeamDetailRenderer(a){this.manageTeamUrl=a;this.mailToHref="mailto: {0}?subject={1}";this.playerListHtmlSnippet='<tbody><tr class="players"><td class="name"></td><td><a class="email url@href" href="#">Loading...</a></td><td class="phone"></td></tr></tbody>';this.captainListHtmlSnippet='<tbody><tr><td class="with50Percentage left"><span class="boldFontStyle name">Loading...</span><br><a class="email mailToUrl@href" href="#">Loading...</a><br><span class="phone"></span></td><td class="with50Percentage right"><span class="boldFontStyle name">Loading...</span><br><a class="email mailToUrl@href" href="#">Loading...</a><br><span class="phone"></span></td></tr></tbody>'}TeamDetailRenderer.prototype.toggleRosterDropdown=function(a){var b="#rosterFetchForm [name='selectedRoster']";if(a){$(b).removeAttr("disabled")}else{$(b).attr("disabled","true")}};TeamDetailRenderer.prototype.renderAllTeamData=function(a){this.renderTeamDetail(a);this.renderCaptainData(a);if(a.isGuestPlayer){$("#guestTeamMessage").removeClass("hiddenItem").show();$("#gameRosterContent").addClass("hiddenItem").hide()}else{this.renderRosterData(a);this.renderPlayerList(a)}ProgressBar.hide()};TeamDetailRenderer.prototype.renderTeamDetail=function(c){$("#teamInfo_SportGender").html($.format("{0} - {1}",c.sport,c.gender));$("#teamInfo_TeamLocation").html(c.teamLocation);if(c.canManageTeam){var a=$.format("{0}/{1}",this.manageTeamUrl,c.teamId);var b=$.format('{0} (<a href="{1}">Manage this Team</a>)',c.teamName,a);$("#teamInfo_TeamName").html(b);$("#retiredTeamMessage").html("This team has been retired and won't be listed among the teams you belong to. The team cannot be managed any further.")}else{$("#teamInfo_TeamName").html(c.teamName);$("#retiredTeamMessage").html("This team has been retired and won't be listed among the teams you belong to.")}if(!c.isActiveTeam){$("#retiredTeamMessage").removeClass("hiddenItem").show()}};TeamDetailRenderer.prototype.clearOldPlayerListHtml=function(){$("#gameRoster > tbody").replaceWith(this.playerListHtmlSnippet)};TeamDetailRenderer.prototype.clearOldCaptainListHtml=function(){$("#captainListing > tbody").replaceWith(this.captainListHtmlSnippet)};TeamDetailRenderer.prototype.renderCaptainData=function(b){var d=this;var a={captains:[]};var f=0;var e=new Object();this.clearOldCaptainListHtml();$("#teamInfo_CaptainMailTo").attr("href",$.format(this.mailToHref,b.captainEmails,encodeURI(b.teamName)));$.each(b.captains,function(h,g){a.captains[f]=e;g.url=$.format(d.mailToHref,g.email,b.teamName);if(h%2==0){e.left=g}else{e.right=g;f+=1;e=new Object()}});a.teamName=b.teamName;var c={"tbody tr":{"captain <- captains":{"td.left span.name":"#{captain.left.name}","td.left a.email":"#{captain.left.email}","td.left a.email@href":"mailto: #{captain.left.email} ?subject=#{teamName}","td.left span.phone":"#{captain.left.phone}","td.right span.name":"#{captain.right.name}","td.right a.email":"#{captain.right.email}","td.right a.email@href":"mailto: #{captain.right.email} ?subject=#{teamName}","td.right span.phone":"#{captain.right.phone}"}}};$("table.captainListing").render(a,c)};TeamDetailRenderer.prototype.renderRosterData=function(a){var b="#rosterFetchForm [name='selectedRoster']";$(b).removeOption(/./);jQuery.each(a.rosters,function(){var c=this;$(b).addOption(c.id,c.name,c.id==a.activeRosterId)});this.toggleRosterDropdown(true)};TeamDetailRenderer.prototype.renderPlayerList=function(a){var c=this;this.clearOldPlayerListHtml();$("#teamInfo_PlayerCount").html(a.players.length);var e="";jQuery.each(a.players,function(){var g=this;g.url=$.format(c.mailToHref,g.email,a.teamName);e=g.email+","+e});var f=e.length-1;var d=e.charAt(f);if(d==","){e=e.substring(0,f)}$("#teamInfo_PlayerMailTo").attr("href",$.format(this.mailToHref,e,encodeURI(a.teamName)));var b={"tbody tr":{"player<-players":{"@class+":function(g){var h=(g.pos%2==0)?"odd":"even";return" "+h+" "},"td.name":"#{player.name}","td > a.email":"#{player.email}","td > a.email@href":"mailto:#{player.email} ?subject=#{teamName}","td.phone":"#{player.phone}"}}};$("table.playerList").render(a,b)};