function cmdPaymentAnnual(){var b=this,a={};if($(b).attr("loggedin")=="false"){showMessage("You must be logged in to complete this purchase. Click <a href='/login?source=/managerpro'>HERE</a> to login.");return}if($(b).attr("subscribed")=="true"){showMessage("You are already subscribed to Manager PRO.");return}a.productid=$(b).attr("productid");a.promoid=$(".hfPromoId").val();a.country=$(".hfCountry").val();if(a.country=="NZ")a.price=$(b).first(".spanSeasonAmount").text;else a.price=$(b).first(".spanSeasonAmountGST").text;AjaxAction.prototype.perform({action:"payment/order",oncomplete:cmdPaymentAnnualComplete,values:a})}function cmdPaymentAnnualComplete(a){if(a.success())window.location.href=a.parameters().Items.redirect}function cmdApplyPromoCode(){var a={};a.promocode=$("#tbMPPromoCode").val();a.country=$(".hfCountry").val();a.producttype=10;AjaxAction.prototype.perform({action:"payment/promo",oncomplete:cmdApplyPromoCodeComplete,values:a})}function cmdApplyPromoCodeComplete(a){var d="#tbMPPromoCode",c=".hfPromoId";if(a.success()){var g=a.parameters().Items.productid.toUpperCase(),f=a.parameters().Items.promoamount,e=a.parameters().Items.promoamountgst;$(c).val(a.parameters().Items.promoid);var b=0;$(".trProduct").each(function(){var i="Remove from Purchase",h="#spanSeasonAmountGST",d="#spanSeasonAmount",c=".btnAddProduct",a=this;if($(a).find(c).first().attr("productid").toUpperCase()==g){$(a).find(d).first().text(f);$(a).find(h).first().text(e)}if($(".hfCountry").val()=="NZ"){if($(a).find(c).val()==i)b+=parseFloat($(a).find(h).first().text())}else if($(a).find(c).val()==i)b+=parseFloat($(a).find(d).first().text())});$(".spanAmountTotal").html(b.toFixed(2));$(".hfAmountTotal").val(b);$(d).css("border","green 4px solid")}else{$(".hfPromoAmountAviva").val("0");$(".hfPromoAmountSuper").val("0");$(c).val("");$(d).css("border","red 4px solid");if(a.parameters().Items.message=="expired")showMessage("The code you've entered was a limited offer that has expired and can't be used");else showMessage("The code you've entered is incorrect. Please check your code and try again.")}}function cmdShowPrices(){var a="0";$(".trProduct").each(function(){var d=".spanGST",c="#spanSeasonAmountGST",b="#spanSeasonAmount",a=this;if($(".hfCountry").val()=="NZ"){$(a).find(b).first().hide();$(a).find(c).first().show();$(a).first(d).show();$("#pGSTText").show()}else{$(a).find(c).first().hide();$(a).find(b).first().show();$(a).find(d).hide()}$(a).find(".btnPaymentAnnual").first().show()})}function BindPageEvents(){var b="pointer",a="cursor";$("#btnMPPromoCode").unbind().click(cmdApplyPromoCode).css(a,b);$(".btnPaymentTotal").unbind().click(cmdPaymentTotal).css(a,b);$(".btnAddProduct").unbind().click(cmdAddProduct).css(a,b);$(".btnNoLeagues").unbind().click(cmdNoLeagues).css(a,b);$(".btnNotLoggedIn").unbind().click(cmdNotLoggedIn).css(a,b);$.get("https://ipinfo.io?token=b72fc7fd43307e",function(a){$(".hfCountry").val(a.country);cmdShowPrices()},"jsonp")}$(document).ready(function(){BindPageEvents()});function cmdPaymentTotal(){var b=".btnAddProduct[value='Remove from Purchase']";if($(this).attr("loggedin")=="false"){showMessage("You must be logged in to complete this purchase. Click <a href='/login?source=/managerpro'>HERE</a> to login.");return}if($(this).attr("leagues")=="false"){showMessage("You currently have not joined any competitions that are eligible for Manager PRO. Click <a href='/dashboard'>HERE</a> to create your own league and invite friends or browse existing leagues to join.");return}if(!$(b).length>0){showMessage("Please click 'Add to Purchase' for one or more competitions.");return}var a={};a.productid=$(".hfProductId").val();a.promoid=$(".hfPromoId").val();a.price=$(".hfAmountTotal").val();a.ordertype="MultiProduct";a.country=$(".hfCountry").val();var c="";$(b).each(function(){var b="productid";c+=$(this).attr(b)+";";a.productid=$(this).attr(b)});a.products=c;AjaxAction.prototype.perform({action:"payment/order",oncomplete:cmdPaymentTotalComplete,values:a})}function cmdPaymentTotalComplete(a){if(a.success())window.location.href=a.parameters().Items.redirect}function cmdAddProduct(){var g=".btnPaymentTotal",f="Add to Purchase",e=".trProduct",d=".hfAmountTotal",b=this,h={},a=parseFloat($(d).val()),c=0;if($(".hfCountry").val()=="NZ")c+=parseFloat($(b).parents(e).find("#spanSeasonAmountGST").first().text());else c+=parseFloat($(b).parents(e).find("#spanSeasonAmount").first().text());if($(b).val()==f){$(b).val("Remove from Purchase");a=a+c;$(d).val(a);$(g).show()}else{$(b).val(f);a=a-c;$(d).val(a);$(".btnAddProduct[value='Remove from Purchase']").length==0&&$(g).hide()}$(".spanAmountTotal").html(a.toFixed(2))}function cmdNoLeagues(){window.location.href="/dashboard"}function cmdNotLoggedIn(){window.location.href="/login?source=leaguepro"}