;(function($,_,undefined){"use strict";ips.controller.register('forms.front.submission.form',{initialize:function(){this.on('click','[data-action="changeLUG"]',this.changeLUG);this.on('click','[data-action="changeAddress"]',this.changeAddress);this.on('click','[data-action="revertAddress"]',this.revertAddress);this.on('change','#elSelect_form_club_id',this.changeClub);this.on('submit',this.submitForm);this.setup();this.changeClub();},setup:function(){this._modifiedAddress=false;this._noAddress=false;this._noPhone=false;this._noEmail=false;this._noName=false;if(this.scope.find('[data-role="existingShippingDetails"]').length){if(this.scope.find('[data-role="noShippingAddress"]').length){this._noAddress=true;}
if(this.scope.find('[data-role="noShippingPhone"]').length){this._noPhone=true;}
if(this.scope.find('[data-role="noShippingEmail"]').length){this._noEmail=true;}
if(this.scope.find('[data-role="noShippingName"]').length){this._noName=true;}}},submitForm:function(e){if(!(this.scope.find('[data-role="shippingAddress"]').length||this.scope.find('input[type="hidden"][name="custom_shipping_address"]').length)){return;}
var usingCustomShipping=this.scope.find('input[type="hidden"][name="custom_shipping_address"]').length;var addressFirstLine=this.scope.find('input[name="shipping_address[address][]"]');var email=this.scope.find('input[name="shipping_email"]');var phone=this.scope.find('input[name="shipping_phone"]');var name=this.scope.find('input[name="shipping_name"]');if(usingCustomShipping&&$.trim(addressFirstLine.val())==''){ips.ui.alert.show({type:'alert',message:ips.getString('addressErrorNoText')});e.preventDefault();return false;}else if(!usingCustomShipping&&this._noAddress){ips.ui.alert.show({type:'alert',message:ips.getString('addressErrorNoClub')});e.preventDefault();return false;}else if((usingCustomShipping&&$.trim(phone.val())=='')||(!usingCustomShipping&&this._noPhone)){ips.ui.alert.show({type:'alert',message:ips.getString('addressErrorNoPhone')});e.preventDefault();return false;}else if((usingCustomShipping&&$.trim(email.val())=='')||(!usingCustomShipping&&this._noEmail)){ips.ui.alert.show({type:'alert',message:ips.getString('addressErrorNoEmail')});e.preventDefault();return false;}else if((usingCustomShipping&&$.trim(name.val())=='')||(!usingCustomShipping&&this._noName)){ips.ui.alert.show({type:'alert',message:ips.getString('addressErrorNoName')});e.preventDefault();return false;}},changeLUG:function(e){e.preventDefault();this.scope.find('[data-role="clubName"], [data-action="changeLUG"]').hide();this.scope.find('[data-role="chooseClub"]').slideDown();},changeAddress:function(e){e.preventDefault();this.scope.find('[data-role="existingShippingDetails"], [data-action="changeAddress"]').hide();this.scope.find('[data-role="changeShippingAddress"]').slideDown();this.scope.prepend("<input type='hidden' name='custom_shipping_address' value='1' />");},revertAddress:function(e){e.preventDefault();var self=this;this.scope.find('[data-role="changeShippingAddress"]').slideUp(function(){self.scope.find('[data-role="existingShippingDetails"], [data-action="changeAddress"]').show();})
this.scope.find('input[type="hidden"][name="custom_shipping_address"]').remove();},changeClub:function(e){var shippingDetails=this.scope.find('[data-role="existingShippingDetails"]');var shippingAddress=this.scope.find('[data-role="shippingAddress"]');var shippingEmail=this.scope.find('[data-role="shippingEmail"]');var shippingPhone=this.scope.find('[data-role="shippingPhone"]');var shippingName=this.scope.find('[data-role="shippingName"]');var id=(this.scope.find('#elSelect_form_club_id').val()?this.scope.find('#elSelect_form_club_id').val():this.scope.find('[name="form_club_id"]').val());if(typeof id=='undefined'){return;}
var self=this;shippingAddress.html("<span class='ipsType_light'>Loading...</span>");shippingPhone.html("<span class='ipsType_light'>Loading...</span>");shippingEmail.html("<span class='ipsType_light'>Loading...</span>");shippingName.html("<span class='ipsType_light'>Loading...</span>");ips.getAjax()(ips.getSetting('baseURL')+'index.php?app=forms&module=forms&controller=forms&do=getClubLocation&id='+id,{type:'post'}).done(function(response){var addressPieces=[];if(_.isArray(response.address.addressLines)&&response.address.addressLines.length){for(var i=0;i<response.address.addressLines.length;i++){if(response.address.addressLines[i]!==null){addressPieces.push(response.address.addressLines[i]);}}}
if(response.address.city){addressPieces.push(response.address.city);}
if(response.address.region){addressPieces.push(response.address.region);}
if(response.address.country){addressPieces.push(response.address.country);}
if(response.address.postalCode){addressPieces.push(response.address.postalCode);}
if(addressPieces.length){self._noAddress=false;shippingAddress.html(addressPieces.join('<br>'));}else{self._noAddress=true;shippingAddress.html("<span class='ipsType_light'>No address specified</span>");}
if(response.phone){shippingPhone.text(response.phone);self._noPhone=false;}else{shippingPhone.html("<span class='ipsType_light'>No phone number specified</span>");self._noPhone=true;}
if(response.email){shippingEmail.text(response.email);self._noEmail=false;}else{shippingEmail.html("<span class='ipsType_light'>No email address specified</span>");self._noEmail=true;}
if(response.name){shippingName.text(response.name);self._noName=false;}else{shippingName.html("<span class='ipsType_light'>No recipient name specified</span>");self._noName=true;}}).fail(function(){self._noAddress=true;shippingDetails.html("<span class='ipsType_light'>Couldn't load an address</span>");});}});}(jQuery,_));;
;(function($,_,undefined){"use strict";ips.controller.register('forms.front.submission.slider',{initialize:function(){this.on('input','[data-role="slider"]',this.changeSlider);this.setup();},setup:function(){this.changeSlider();var max=parseInt(this.scope.find('[data-role="slider"]').attr('max'));this.scope.find('[data-role="answerMax"]').text(max);},changeSlider:function(){var val=this.scope.find('[data-role="slider"]').val();this.scope.find('[data-role="answerValue"]').text(val);}});}(jQuery,_));;