function crop(){jcrop_api&&jcrop_api.destroy();$("#cropImgBox").Jcrop({setSelect:[0,0,200,150],onChange:showPreview,onSelect:showPreview},function(){jcrop_api=this;bounds=jcrop_api.getBounds();boundx=bounds[0];boundy=bounds[1]})}function showPreview(n){if($("#x1").val(n.x),$("#y1").val(n.y),$("#w").val(n.w),$("#h").val(n.h),parseInt(n.w)>0){var t=100/n.w,i=100/n.h;$("#preview").css({width:Math.round(t*boundx)+"px",height:Math.round(i*boundy)+"px",marginLeft:"-"+Math.round(t*n.x)+"px",marginTop:"-"+Math.round(i*n.y)+"px"})}}function SelectLicenseGridItem(n,t,i){var f=$("#"+n),e=f.data("kendoGrid"),o=e.dataSource,r=o.get(i),u=$.grep(t,function(n){return n==i});u&&u.length==1?$("[data-uid="+r.uid+"]").addClass("k-state-selected"):$("[data-uid="+r.uid+"]").removeClass("k-state-selected")}function RemoveLicenseGridItem(n,t){$.each(t,function(t,i){var u=$("#"+n),f=u.data("kendoGrid"),r=f.dataSource,e=r.get(i);r.remove(e)})}var jcrop_api,bounds,boundx,boundy,advanceCode,dontConsiderThisTrigger,showreset,userLicarr,busLicarr;gr2_TransactionHistory={init:function(){},actions:function(){$(document).off("click","#btnFilter").on("click","#btnFilter",function(){var n=$("#ToDate").val(),t=$("#FromDate").val(),i;n!=null&&n!=undefined&&n!=""&&n!=NaN&&t!=null&&t!=undefined&&t!=""&&t!=NaN&&(t=t.replace(/-/g,"/"),n=n.replace(/-/g,"/"),i=gr2_TransactionHistory.GetDateComparisionVal(t,n,$("#FromDate").attr("id")),i&&$("#history-grid").data("kendoGrid").dataSource.read())});$(document).off("click",".rowclick").on("click",".rowclick",function(){var n=$(this).attr("data-id"),t;n!=null&&n!=""&&n!=undefined&&(t=window.open("/ManageMyAccount/PrintInvoice/"+n,"_blank"),popupBlockerChecker.check(t,""))})},getParameter:function(){return{fromDate:$("#FromDate").val(),toDate:$("#ToDate").val()}},Print:function(){var n=$("#FromDate").val(),t=$("#ToDate").val(),i=window.open("/ManageMyAccount/PrintTransactionHistory/?startdate="+n+"&enddate="+t,"_blank");popupBlockerChecker.check(i,"")},GetDateComparisionVal:function(n,t,i){var r=!0,u;return $("#Msgbox").html("").removeClass("alert alert-danger"),u=compareDates(n,"dd/MM/yyyy",t,"dd/MM/yyyy"),u==-1?(r=!1,$("#Msgbox").html("Please enter a valid date Format(dd/MM/yyyy).").addClass("alert alert-danger"),$("#"+i).focus()):u==1?(r=!1,$("#Msgbox").html("Start date cannot be greater than end date").addClass("alert alert-danger"),$("#"+i).focus()):$("#Msgbox").html(""),r}};gr2_PaymentHistory={init:function(){},actions:function(){$(document).off("click",".print-invoice").on("click",".print-invoice",function(){var n=window.open("/ManageMyAccount/PrintInvoice/"+$(this).attr("data-id")+"?type="+$(this).attr("data-type"),"_blank");popupBlockerChecker.check(n,"")});$(document).off("click","#btnFilter").on("click","#btnFilter",function(){var n=$("#ToDate").val(),t=$("#FromDate").val(),i;n!=null&&n!=undefined&&n!=""&&n!=NaN&&t!=null&&t!=undefined&&t!=""&&t!=NaN&&(t=t.replace(/-/g,"/"),n=n.replace(/-/g,"/"),i=gr2_PaymentHistory.GetDateComparisionVal(t,n,$("#FromDate").attr("id")),i&&$("#purchases-grid").data("kendoGrid").dataSource.read())})},getParameter:function(){return{fromDate:$("#FromDate").val(),toDate:$("#ToDate").val()}},GetDateComparisionVal:function(n,t,i){var r=!0,u;return $("#Msgbox").html("").removeClass("alert alert-danger"),u=compareDates(n,"dd/MM/yyyy",t,"dd/MM/yyyy"),u==-1?(r=!1,$("#Msgbox").html("Please enter a valid date Format(dd/MM/yyyy).").addClass("alert alert-danger"),$("#"+i).focus()):u==1?(r=!1,$("#Msgbox").html("Start date cannot be greater than end date").addClass("alert alert-danger"),$("#"+i).focus()):$("#Msgbox").html(""),r}};gr2_MarketingContest={init:function(){},actions:function(){$(".btnContestHis").off("click").on("click",function(){pageReload("/ManageMyAccount/ContestHistory")});$(".btnTicketsEarned").off("click").on("click",function(){var n=$("#ContestIDEnc").val();pageReload("/ManageMyAccount/TicketsEarned/"+n)});$(".btnInvitedFriends").off("click").on("click",function(){var n=$("#ContestIDEnc").val();pageReload("/ManageMyAccount/ContestInvitedFriends/"+n)});$(".btnJoinContast").off("click").on("click",function(){var n=$(this).attr("data-id"),t=$("#RefererUsername").val(),i=$("#RefererName").val(),r="You are entering the giveaway as "+i+"("+t+")";$(document).openConfirmationModal({modalContent:r,submitContent:"Confirm"});$("#confirm-modal").off("click").on("click",function(){$(document).closeModal();$.post("/ManageMyAccount/JoinContest",{contestID:n},function(n){n.IsSuccess?($("#DivEventSummary").html(n.EventSummary),pageReload("/ManageMyAccount/MarketingContest"),$(document).closeModal()):($("#DivEventSummary").html(n.EventSummary),$(document).closeModal())})})});$("#btnEmailShare").off("click").on("click",function(){var n=$(this).attr("data-id");$.post("/ManageMyAccount/EmailShare",{contestKey:n},function(n){n.IsSuccess==!0?($("#EmailShareModel").html(""),$("#EmailShareModel").html(n.Result),$("#EmailShareModel").modal("show")):GR_Notification.showDangerFixed(n.Result)})})},popup:function(){$(".contest_email_cont").show();$(".email_preview_cont").hide();var n=$("#ContestEmail-form").kendoValidator({rules:{RefereeEmail:function(n){return n.is("[name=RefereeEmail]")?$("#RefereeEmail").val()==null||$("#RefereeEmail").val()==""?!1:!0:!0},RefereeEmailValid:function(n){return n.is("[name=RefereeEmail]")?$("#RefereeEmail").val()==null||$("#RefereeEmail").val()==""||isValidEmailAddress($("#RefereeEmail").val())?!0:!1:!0},RefereeName:function(n){return n.is("[name=RefereeName]")?$("#RefereeName").val()==null||$("#RefereeName").val()==""?!1:!0:!0}},messages:{RefereeEmail:"Email address is required",RefereeName:"Name is required",RefereeEmailValid:"Enter valid email address"},validateOnBlur:!0}).data("kendoValidator");$(document).off("click","#previewContestMail").on("click","#previewContestMail",function(){if(n.validate()){$("#PreviewSubject").text("");$("#PreviewContent").html("");$("#PreviewReceiverid").html("");var t=$("#ContestEmail-form").serialize();$("#ContestEmailShareErrors").html("");$(".contest_email_cont").hide();$(".email_preview_cont").show();$(".email_preview_cont").addClass("wrap_loader");$(".email_preview_footer").hide();$.post("/ManageMyAccount/EmailPreviewPost/",t,function(n){$("#ContestEmailShareErrors").html(n.EventSummary);n.IsSuccess&&(console.log(n.Result),$("#PreviewSubject").text(n.Result.Subject),$("#PreviewContent").html(n.Result.Content),$("#PreviewReceiverid").html(n.Result.ReceiverEmail),$("#PreviewReceiverName").html(n.Result.ReceiverName),$(".email_preview_cont").removeClass("wrap_loader"),$(".email_preview_footer").show())})}});$(document).off("click",".Backtomail").on("click",".Backtomail",function(){$(".contest_email_cont").addClass("animate_from_left");$(".contest_email_cont").show();$(".email_preview_cont").hide()});$(document).off("click",".sendContestRefMail").on("click",".sendContestRefMail",function(){if(n.validate()){$(".sendContestRefMail").button("loading");var t=$("#ContestEmail-form").serialize();$("#ContestEmailShareErrors").html("");$.post("/ManageMyAccount/EmailSharePost/",t,function(n){$(".sendContestRefMail").button("reset");$("#ContestEmailShareErrors").html(n.EventSummary);n.IsSuccess&&($("#EmailShareModel").modal("hide"),pageReload("/ManageMyAccount/MarketingContest"))})}else $("input.k-invalid:first").focus();return!1})}};gr2_ContestHistory={init:function(){},actions:function(){$(".ContestBack").off("click").on("click",function(){pageReload("/ManageMyAccount/MarketingContest")});$(".openEarnedTickets").off("click").on("click",function(){var n=$(this).attr("data-id");pageReload("/ManageMyAccount/TicketsEarned/?id="+n+"&From=ConHis")});$(".openEmailSharings").off("click").on("click",function(){var n=$(this).attr("data-id");pageReload("/ManageMyAccount/ContestInvitedFriends/?id="+n+"&From=ConHis")})}};gr2_TicketsEarned={init:function(){var n=$("#TotalTicketsCount").val();$(".IsTicketGrid").hide();$(".showAsList").hide();$(".IsTicketList").show();$(".showAsGrid").show()},actions:function(){$(".ContestBack").off("click").on("click",function(){$("#NavFrom").val()=="ConHis"?pageReload("/ManageMyAccount/ContestHistory"):$("#NavFrom").val()=="InvFrds"?pageReload("/ManageMyAccount/ContestInvitedFriends"):pageReload("/ManageMyAccount/MarketingContest")});$(".showAsGrid").off("click").on("click",function(){$(".IsTicketGrid").show();$(".showAsList").show();$(".IsTicketList").hide();$(".showAsGrid").hide()});$(".showAsList").off("click").on("click",function(){$(".IsTicketGrid").hide();$(".showAsList").hide();$(".IsTicketList").show();$(".showAsGrid").show()})}};gr2_ContestInvitedFriends={init:function(){},actions:function(){$(".ContestBack").off("click").on("click",function(){$("#NavFrom").val()=="ConHis"?pageReload("/ManageMyAccount/ContestHistory"):pageReload("/ManageMyAccount/MarketingContest")})}};gv2_MyProfile={init:function(){$(function(){var n=$("#FrmMyProfile");kendo.init(n);n.kendoValidator({rules:{PhoneorMobile:function(n){return n.is("[name=Phone]")||n.is("[name=MobilePhone]")?($("#Phone").val()==null||$("#Phone").val()=="")&&($("#MobilePhone").val()==null||$("#MobilePhone").val()=="")?$("#SessionUserRole").val()!="CORPORATEADMIN"&&$("#SessionUserRole").val()!="CORPORATEMEMBER"&&$("#SessionUserRole").val()!="BUSINESSMEMBER"&&$("#SessionUserRole").val()!="ACCOUNTANTMEMBER"?!1:!0:!0:!0},Phone:function(n){if(n.is("[name=Phone]")&&$("#SessionUserRole").val()!="CORPORATEADMIN"&&$("#SessionUserRole").val()!="CORPORATEMEMBER"&&$("#SessionUserRole").val()!="BUSINESSMEMBER"&&$("#SessionUserRole").val()!="ACCOUNTANTMEMBER"){var t=$("#Phone").val().replace(/\_/g,"");return t.length>0&&!(t.length>7&&t.length<=12)?!1:!0}return!0},MobilePhone:function(n){if(n.is("[name=MobilePhone]")&&$("#SessionUserRole").val()!="CORPORATEADMIN"&&$("#SessionUserRole").val()!="CORPORATEMEMBER"&&$("#SessionUserRole").val()!="BUSINESSMEMBER"&&$("#SessionUserRole").val()!="ACCOUNTANTMEMBER"){var t=$("#MobilePhone").val().replace(/\_/g,"");return t.length>0&&!(t.length>7&&t.length<=12)?!1:!0}return!0},EmailValidation:function(n){var t,r,i;return n.is("[name=Email]")?(t=n.val(),t!=""?(r="/AccountSettings/ValidateEmail/",i=!0,$.ajax({url:r,mode:"abort",dataType:"json",type:n.attr("data-val-remote-type"),data:{emailVal:t},async:!1,success:function(n){n;i=n}}),i):!0):!0},ICBValidation:function(n){var r,i;if(n.is("[name=MembershipTypeId]")){if(($("#MembersTypeDesc").val()=="ICB"||$("#MembersTypeDesc").val()=="AAT")&&$("#MembershipTypeId").val()!=0){var u=n.val(),t=u.replace(/_/g,""),f=$("#FirstName").val(),e=$("#LastName").val(),o=$("#MembersTypeDesc").val();return t=t.replace(/[_\s\n\r]+/g,""),t!=""&&t!=null&&t!=0?(r="/AccountSettings/CheckmemberType/",i=!0,$.ajax({url:r,mode:"abort",dataType:"json",type:n.attr("data-val-remote-type"),data:{firstName:f,lastName:e,MemberTypeId:t,memberTypeCode:o},async:!1,success:function(n){return i=n.IsSuccess,n.IsSuccess?!0:!1}}),i):!0}return!0}return!0}},messages:{EmailValidation:"Enter valid email address",ICBValidation:"Enter valid membership number",Phone:"Please specify a valid phone number",MobilePhone:"Please specify a valid mobile phone"},validateOnBlur:!0})});$("#FrmMyProfile").submit(function(n){var t,i;n.preventDefault();t=$("#FrmMyProfile").data("kendoValidator");$("#divErrorMessage").html("");t.validate()?($("#SaveMyProfile").button("loading"),i=$("#FrmMyProfile").serialize(),$.post("/AccountSettings/UpdateMyProfile/",i,function(n){$("#SaveMyProfile").button("reset");var t=$("#MembersTypeDesc").val(),i=$("#MembershipTypeCodeHidden").val();n.IsSuccess&&t!=i?($("#myProfileErrors").html(n.EventSummary),location.reload()):$("#myProfileErrors").html(n.EventSummary)})):gv2_MyProfile.CheckValidation()})},phoneMobileValidation:function(){if($("#Phone").val()!=undefined&&$("#MobilePhone").val()!=undefined){var n=$("#Phone").val().replace(/\_/g,""),t=$("#MobilePhone").val().replace(/\_/g,""),i=!0;return n.length>0&&!(n.length>7&&n.length<=12)?($("#TelephoneNumber_span").html("Please specify a valid phone number").addClass("text-warning bg-warning warningProfilemsg"),i=!1):$("#TelephoneNumber_span").html("").removeClass("text-warning bg-warning warningProfilemsg"),t.length>0&&!(t.length>7&&t.length<=12)?($("#MobileNumber_span").html("Please specify a valid mobile number").addClass("text-warning bg-warning warningProfilemsg"),i=!1):$("#MobileNumber_span").html("").removeClass("text-warning bg-warning warningProfilemsg"),i}return!0},CheckValidation:function(){var i=$("#Address_Line1").val(),r=$("#Address_City").val(),u=$("#Address_Region").val(),f=$("#Address_Postcode").val().replace("/_/g",""),e=$("#Address_Country").val(),n,t;return i==""||i==null||i==undefined||r==""||r==null||r==undefined||u==""||u==null||u==undefined||f==""||f==null||f==undefined||e==""||e==null||e==undefined?($("#ProfcontactsdetailsTab").trigger("click"),$("input.k-invalid:first").focus(),!1):(n=$("#Phone").val().replace("/_/g",""),t=$("#MobilePhone").val().replace("/_/g",""),(n==""||n==null||n==undefined)&&(t==""||t==null||t==undefined))?($("#ProfcontactsdetailsTab").trigger("click"),$("input.k-invalid:first").focus(),!1):!1},actions:function(){gr2_KendoAddressAutoComplete.CityAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.RegionAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.PostCodeAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.countryAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");$(document).off("change","#MembersTypeDesc").on("change","#MembersTypeDesc",function(){var n=$("#MembersTypeDesc").val();n=="ICB"||n=="AAT"?($("#GetMemberTypeNumber").show(),$("#MembershipTypeId").val("")):($("#GetMemberTypeNumber").hide(),$("#MembershipTypeId").val(0),$("#MembershipTypeId").attr("Readonly",!1))});$(".changepwddialog").off("click").on("click",function(){var n=$("#encrypbuscode").val();$.post("/AccountSettings/ChangePasswordView?encrypbuscode= "+n,function(n){n.IsSuccess==!0?($("#changepaswduser").html(""),$("#changepaswduser").html(n.Result),$("#changepaswduser").modal("show")):GR_Notification.showDangerFixed(n.Result)})});$("#changeusrnmdialog").off("click").on("click",function(){var n=$("#encrypbuscode").val();$.post("/AccountSettings/ChangeUserNameView?encrypbuscode= "+n,function(n){n.IsSuccess==!0?($("#MediumSizeModel").html(""),$("#MediumSizeModel").html(n.Result),$("#MediumSizeModel").modal("show")):GR_Notification.showDangerFixed(n.Result)})});$("#setAliasdialog").off("click").on("click",function(){var n=$("#encrypbuscode").val();$.post("/AccountSettings/SetAliasUserNameView?encrypbuscode= "+n,function(n){n.IsSuccess==!0?($("#MediumSizeModel").html(""),$("#MediumSizeModel").html(n.Result),$("#MediumSizeModel").modal("show")):GR_Notification.showDangerFixed(n.Result)})});$(".UploadProfileimg").off("click").on("click",function(){var n=$("#encrypbuscode").val();$.post("/AccountSettings/ProfileImageEditor?encrypbuscode= "+n,function(n){n.IsSuccess==!0?($("#profileimageeditor").html(""),$("#profileimageeditor").html(n.Result),$("#profileimageeditor").modal("show")):GR_Notification.showDangerFixed(n.Result)})});$("#removeProfileImage").off("click").on("click",function(n){n.preventDefault();$(document).openConfirmationModal({modalContent:"Are you sure to remove the profile image?",submitContent:"Confirm"});$("#confirm-modal").off("click").on("click",function(){var n=new Date;$.getJSON("/AccountSettings/RemoveProfileImage/?id="+n.getMilliseconds(),{userComment:$("#feedback").val()},function(t){t.IsSuccess?($("#img_profileImage")[0]!=undefined&&($("#img_profileImage")[0].src="/Account/GetProfileImage?a="+n.getMilliseconds()),$("#headerProfileImage")[0]!=undefined&&($("#headerProfileImage")[0].src="/Account/GetProfileImage?a="+n.getMilliseconds()),$("#myaccountprofileimage")[0]!=undefined&&($("#myaccountprofileimage")[0].src="/Account/GetProfileImage?a="+n.getMilliseconds()),$("#ResetprofileImage")[0]!=undefined&&($("#ResetprofileImage")[0].src="/Account/GetProfileImage?a="+n.getMilliseconds()),$("#newProfileImageOption").show(),$("#editProfileImageOption").hide(),$("#myProfileErrors").html(t.EventSummary)):$("#myProfileErrors").html(t.EventSummary)});$(document).closeModal()})});$("#closeuserprofileEdit").off("click").on("click",function(){pageload("/Home/Welcome")})}};gv2_SetAlias={init:function(){$("#Password").val("");$("#NewUsername").val("");$(".restrictSpace").bind("input",function(){for(var t="",i=this.value,n=0;n<i.length;n++)/[A-Za-z0-9]/.test(i.charAt(n))&&(t=t.concat(i.charAt(n)));this.value=t});$("#aliasusernameform").bootstrapValidator({fields:{Password:{validators:{notEmpty:{message:"The Password is required"}}},AliasName:{trigger:"blur",validators:{notEmpty:{message:"The Username is required"},stringLength:{max:150,message:"Alias name must be less than 150 characters"}}}},submitHandler:function(n,t,i){$("#aliasusernameform").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/SetAliasUserName",beforeSubmit:function(){$(i).button("loading")},success:function(n){$(i).button("reset");n.IsSuccess?($("#MediumSizeModel").modal("hide"),pageReload("/AccountSettings/MyProfile"),$("#myProfileErrors").html(n.EventSummary)):$("#divErrorMsgSetAliasUserName").html(n.EventSummary)},error:function(n,t,r){console.log(n);console.log(t);console.log(r);$(i).button("reset");GR_Notification.showDangerFixed(r)}})}})},actions:function(){}};advanceCode="";gr2_OurServices={init:function(){var n=$("#selectedPlankey").val(),t=n.split();$("#HasAdvanceSubscription").val()=="True"&&(advanceCode="R");gr2_OurServices.updateCartTotal()},actions:function(){$(".servicecontainer").off("click",".img_service").on("click",".img_service",function(){var t,n;if($(this).html()=="Add"||$(this).attr("data-actiontype")=="switchtoperannum"){if(t=$("#selectedPlankey").val(),n="",$(this).attr("data-servicetype")=="addons"||$(this).attr("data-servicetype")=="offerplan")n=$(this).attr("data-servicecode"),$(this).html("Remove");else{if($(this).attr("data-actiontype")=="switchtoperannum")$(".PLCON_"+$(this).attr("data-servicecode")).addClass("hide"),$(".PFCON_"+$(this).attr("data-servicecode")).removeClass("hide"),$(this).html("Switch back"),$("#switch_"+$(this).attr("data-servicecode")).attr("data-actiontype","switchback").html("Switch back"),$("#actions_"+$(this).attr("data-servicecode")).addClass("hide"),$("#Check_"+$(this).attr("data-servicecode")).prop("checked",!1),$("#edit_"+$(this).attr("data-servicecode")).addClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).removeClass("hide");else{if($(this).attr("data-ispurchased")=="true"&&($("#Check_"+$(this).attr("data-servicecode")).prop("checked",!0),$(".PFCON_"+$(this).attr("data-servicecode")).addClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).addClass("hide")),$("#Check_"+$(this).attr("data-servicecode")).is(":checked"))if($("#Qty_"+$(this).attr("data-servicecode")).val()!="")$("#edit_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#PLDET_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#QTYDET_"+$(this).attr("data-servicecode")).html($("#Qty_"+$(this).attr("data-servicecode")).val());else{GR_Notification.showDangerFadeout("Quantity is required");$(this).attr("data-ispurchased")=="true"&&($("#Check_"+$(this).attr("data-servicecode")).prop("checked",!1),$(".PFCON_"+$(this).attr("data-servicecode")).removeClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).addClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).removeClass("hide"));return}$(this).attr("data-plantype").toLowerCase()=="both"||$(this).attr("data-plantype").toLowerCase()=="perform"?($(this).html("Remove"),$(this).removeClass("hide")):$(this).addClass("hide")}n=gr2_OurServices.getServiceCode($(this).attr("data-servicecode"))}$("#selectedPlankey").val(t+n+"|");$(this).parents(".ticketcontainer").addClass("selected_item");$(this).parents(".ticketcontainer").find(".ribbon-inner").html("Selected");$("#chk_"+$(this).attr("data-servicecode")).addClass("hide");$(".PLCOUNT_"+$(this).attr("data-servicecode")).addClass("hide")}else $("#PLDET_"+$(this).attr("data-servicecode")).addClass("hide"),t=$("#selectedPlankey").val(),n="",$(this).attr("data-servicetype")=="addons"||$(this).attr("data-servicetype")=="offerplan"?(n=$(this).attr("data-servicecode"),$(this).html("Add")):$(this).attr("data-actiontype")=="switchback"?($("#Check_"+$(this).attr("data-servicecode")).prop("checked",!1),n=gr2_OurServices.getServiceCode($(this).attr("data-servicecode")),$("#actions_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#actions_"+$(this).attr("data-servicecode")).html("Add"),$(this).attr("data-actiontype","switchtoperannum").html("Switch to per Annum"),$(".PFCON_"+$(this).attr("data-servicecode")).addClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).removeClass("hide")):$(this).attr("data-actiontype")=="edit"?($("#edit_"+$(this).attr("data-servicecode")).addClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).attr("data-actiontype","switchtoperannum").html("Switch to per Annum"),$("#actions_"+$(this).attr("data-servicecode")).html("Add").removeClass("hide"),$(".PFCON_"+$(this).attr("data-servicecode")).addClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).removeClass("hide"),n=gr2_OurServices.getServiceCode($(this).attr("data-servicecode"))):($(this).html("Add"),n=gr2_OurServices.getServiceCode($(this).attr("data-servicecode")),$(this).attr("data-ispurchased")=="true"?($(".PFCON_"+$(this).attr("data-servicecode")).addClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).removeClass("hide")):($(".PFCON_"+$(this).attr("data-servicecode")).removeClass("hide"),$(".PLCON_"+$(this).attr("data-servicecode")).addClass("hide")),$("#Check_"+$(this).attr("data-servicecode")).prop("checked",!1),$("#edit_"+$(this).attr("data-servicecode")).addClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).removeClass("hide"),$("#switch_"+$(this).attr("data-servicecode")).attr("data-actiontype","switchtoperannum").html("Switch to per Annum")),t=t.replace(n+"|",""),$("#Check_"+$(this).attr("data-servicecode")).is(":checked")||$(this).attr("data-ispurchased")=="true"?$(".PLCOUNT_"+$(this).attr("data-servicecode")).removeClass("hide"):$(".PLCOUNT_"+$(this).attr("data-servicecode")).addClass("hide"),$("#selectedPlankey").val(t),$(this).parents(".ticketcontainer").removeClass("selected_item"),$(this).attr("data-ispurchased")=="true"?($(this).parents(".ticketcontainer").find(".ribbon-inner").html("Purchased"),$(this).parents(".ticketcontainer").addClass("purchased")):$(this).parents(".ticketcontainer").find(".ribbon-inner").html(""),$("#chk_"+$(this).attr("data-servicecode")).removeClass("hide");gr2_OurServices.updateCartTotal()});$(".ann_cls_btn").off("click").on("click",function(){$.post("/Subscription/RemoveAnnualKeys",function(n){n.IsSuccess&&($("#selectedPlankey").val(n.Message),gr2_OurServices.updateCartTotal(),pageReload("/Subscription/OurServices"))})});$(".mon_cls_btn").off("click").on("click",function(){$.post("/Subscription/RemoveMonthlyKeys",function(n){n.IsSuccess&&($("#selectedPlankey").val(n.Message),gr2_OurServices.updateCartTotal(),pageReload("/Subscription/OurServices"))})});$(".servicecontainer").off("click","#btnApplyBalanceCredit").on("click","#btnApplyBalanceCredit",function(){var n;$(this).attr("data-value")=="1"?($(this).attr("data-value","0"),$(this).html("Apply"),n=$("#selectedPlankey").val(),n=n.replace("APPLYCR_0|","").replace("APPLYCR_1|",""),n+="APPLYCR_0|",$("#selectedPlankey").val(n)):($(this).attr("data-value","1"),$(this).html("Applied"),n=$("#selectedPlankey").val(),n=n.replace("APPLYCR_0|","").replace("APPLYCR_1|",""),n+="APPLYCR_1|",$("#selectedPlankey").val(n));gr2_OurServices.updateNetCredit();gr2_OurServices.updateCartTotal()});$(".servicecontainer").off("click","#addCredits").on("click","#addCredits",function(){var i=$("#selectedPlankey").val(),n=i.split("|"),t;for($("[data-role=numerictextbox]").each(function(){var t=this,r,i;if($(t).hasClass("PLCount")){for(r=!1,i=0;i<n.length;i++)n[i].match("PL_"+$(t).attr("data-servicecode"))&&(n[i]="PL_"+$(t).attr("data-servicecode")+"_"+$(t).val(),r=!0);r||n.push("PL_"+$(t).attr("data-servicecode")+"_"+$(t).val())}}),i="",t=0;t<n.length;t++)n[t]!=""&&(i+=n[t]+"|");gr2_OurServices.updateNetCredit();$("#selectedPlankey").val(i);gr2_OurServices.updateCartTotal()})},perLodgmentChange:function(){var n=0;$("[data-role=numerictextbox]").each(function(){var element=this;$(element).hasClass("PLCount")&&(n+=$(element).val()*eval($(element).attr("data-amount")))});$("#requiredCredits").html(n);gr2_OurServices.updateNetCredit()},userlicenseChange:function(){var i=$("#selectedPlankey").val(),n=i.split("|"),r=0,t;for($("[data-role=numerictextbox]").each(function(){var t=this,u,i;if($(t).hasClass("ULCount")||$(t).hasClass("RULCount")){for($(t).val()!=""&&(r=$(t).val()),u=!1,i=0;i<n.length;i++)n[i].match(advanceCode+"UL_"+$(t).attr("data-servicecode"))&&(n[i]=advanceCode+"UL_"+$(t).attr("data-servicecode")+"_"+r,u=!0);u||n.push(advanceCode+"UL_"+$(t).attr("data-servicecode")+"_"+r)}}),this.value()==0||this.value()==""||this.value()==null?this.element.closest(".ticketcontainer").removeClass("selected_item"):this.element.closest(".ticketcontainer").addClass("selected_item"),i="",t=0;t<n.length;t++)n[t]!=""&&(i+=n[t]+"|");$("#selectedPlankey").val(i);gr2_OurServices.updateCartTotal()},BusinesslicenseChange:function(){var i=$("#selectedPlankey").val(),n=i.split("|"),r=0,t;for($("[data-role=numerictextbox]").each(function(){var t=this,u,i;if($(t).hasClass("BLCount")||$(t).hasClass("RBLCount")){for($(t).val()!=""&&(r=$(t).val()),u=!1,i=0;i<n.length;i++)n[i].match(advanceCode+"BL_"+$(t).attr("data-servicecode"))&&(n[i]=advanceCode+"BL_"+$(t).attr("data-servicecode")+"_"+r,u=!0);u||n.push(advanceCode+"BL_"+$(t).attr("data-servicecode")+"_"+r)}}),this.value()==0||this.value()==""||this.value()==null?this.element.closest(".ticketcontainer").removeClass("selected_item"):this.element.closest(".ticketcontainer").addClass("selected_item"),i="",t=0;t<n.length;t++)n[t]!=""&&(i+=n[t]+"|");$("#selectedPlankey").val(i);gr2_OurServices.updateCartTotal()},IAMServiceChange:function(){var t=$("#selectedPlankey").val(),n=t.split("|"),r=0,i;for($("[data-role=numerictextbox]").each(function(){var t=this,u,i,f;if($(t).hasClass("AFCount")||$(t).hasClass("RAFCount")){for($(t).val()!=""&&(r=$(t).val()),u=!1,i=0;i<n.length;i++)n[i].match(advanceCode+"AF_"+$(t).attr("data-servicecode"))&&(f=n[i].split("_"),n[i]=f.length>3?advanceCode+"AF_"+$(t).attr("data-servicecode")+"_"+r+"_"+f[3]:advanceCode+"AF_"+$(t).attr("data-servicecode")+"_"+r+"_0",u=!0);u||n.push(advanceCode+"AF_"+$(t).attr("data-servicecode")+"_"+r+"_0")}}),this.value()==0||this.value()==""||this.value()==null?this.element.closest(".ticketcontainer").removeClass("selected_item"):this.element.closest(".ticketcontainer").addClass("selected_item"),t="",i=0;i<n.length;i++)n[i]!=""&&(t+=n[i]+"|");console.log(t);$("#selectedPlankey").val(t);gr2_OurServices.updateCartTotal()},updateNetCredit:function(){var netCr=$("#requiredCredits").html();$("#applyBalanceCredit").val()=="1"&&(netCr=eval($("#availableCredits").html())>netCr?0:netCr-eval($("#applyBalanceCredit").val()));$("#netCredits").html(netCr)},updateCartTotal:function(){$.getJSON("/Subscription/GetCartTotal/",{key:$("#selectedPlankey").val()},function(n){var t="";n.length>0?($("#price_cart_btn").attr("style",""),$(".annual_price_cart").addClass("hide"),$(".monthly_price_cart").addClass("hide"),n[0].Freqency=="YEARLY"?(t=n[0].ServiceCount,$(".annual_price_cart").removeClass("hide"),$("#ann_form_count").html(n[0].ServiceCount),$("#ann_form_amount").html(n[0].TotalAmount)):n[0].Freqency=="MONTHLY"&&(t=n[0].ServiceCount,$(".monthly_price_cart").removeClass("hide"),$("#mon_form_count").html(n[0].ServiceCount),$("#mon_form_amount").html(n[0].TotalAmount)),n[1]!=null&&($(".hr_line_pricart").removeClass("hide"),n[1].Freqency=="YEARLY"?(t=t+n[1].ServiceCount,$(".annual_price_cart").removeClass("hide"),$("#ann_form_count").html(n[1].ServiceCount),$("#ann_form_amount").html(n[1].TotalAmount)):n[1].Freqency=="MONTHLY"&&(t=t+n[1].ServiceCount,$(".monthly_price_cart").removeClass("hide"),$("#mon_form_count").html(n[1].ServiceCount),$("#mon_form_amount").html(n[1].TotalAmount))),$("#cartTotal").html(t.toString())):$("#price_cart_btn").attr("style","display: none !important;")})},getServiceCode:function(n){return $("#Check_"+n).is(":checked")?"PL_"+n+"_"+$("#Qty_"+n).val():"PF_"+n},updateItemTotal:function(){var n=$("#UnitPricePerUse_"+this.element.attr("data-servicecode")).val(),t=this.value(),i=t*n;$(".PLTOT_"+this.element.attr("data-servicecode")).html(i.toFixed(2))},onUserLicenseCountChange:function(){},onSubsTypeChange:function(n){$("#Check_"+n).is(":checked")?($(".PLCON_"+n).removeClass("hide"),$(".PFCON_"+n).addClass("hide"),$(".PLCOUNT_"+n).removeClass("hide"),$("#purchased_actns_"+n).removeClass("hide")):($(".PFCON_"+n).removeClass("hide"),$(".PLCON_"+n).addClass("hide"),$(".PLCOUNT_"+n).addClass("hide"),$("#purchased_actns_"+n).addClass("hide"))}};gv2_ChangePwd={init:function(){$("#NewPassword").val("");$("#ConfirmPassword").val("");$("#NewPassword").pwstrength();$("#changepasswordform").bootstrapValidator({fields:{Password:{validators:{notEmpty:{message:"Current Password is required"}}},NewPassword:{validators:{notEmpty:{message:"New Password is required"},regexp:{regexp:/^(?=.{8,16}$)(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=).*/,message:"Password policy did not match!"}}},ConfirmPassword:{validators:{notEmpty:{message:"Confirmation Password is required"},identical:{field:"NewPassword",message:"New Password and Confirmation Password are not same"}}}},submitHandler:function(n,t,i){$("#changepasswordform").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/ChangePassword",beforeSubmit:function(){$(i).button("loading")},success:function(n){$(i).button("reset");n.IsSuccess?($("#changepaswduser").modal("hide"),$("#DivEventSummary").html(n.EventSummary),window.location.href="/Account/LogOff?msg="+n.EventSummary):$("#divEventMessage_ChangePassword").html(n.EventSummary)},error:function(n,t,r){$(i).button("reset");GR_Notification.showDangerFixed(r)}})}})},actions:function(){$(document).on("focus","#NewPassword",function(){$(".content-linkpops").show()});$(document).on("blur","#NewPassword",function(){$(".content-linkpops").hide()});$(window).resize(function(){$(window).width()<=990&&($(".popupstrength").removeClass("right"),$(".popupstrength").addClass("bottom"))})}};gv2_ChangeUsrName={init:function(){$("#Password").val("");$("#NewUsername").val("");$("#changeusernameform").bootstrapValidator({fields:{Password:{validators:{notEmpty:{message:"Password is required"}}},NewUsername:{trigger:"blur",validators:{notEmpty:{message:"Username is required"},emailAddress:{message:"Please enter valid email-id"},stringLength:{max:150,message:"Username must be less than 150 characters"}}}},submitHandler:function(n,t,i){$("#changeusernameform").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/ChangeUserName",beforeSubmit:function(){$(i).button("loading")},success:function(n){$(i).button("reset");n.IsSuccess?window.location.href="/Account/LogOff?msg="+n.EventSummary:$("#divEventMessage_ChangeUserName").html(n.EventSummary)},error:function(n,t,r){console.log(n);console.log(t);console.log(r);$(i).button("reset");GR_Notification.showDangerFixed(r)}})}})},actions:function(){}};MB_Update={init:function(){$(".orgnameField").bind("input",function(){for(var t="",i=this.value,n=0;n<i.length;n++)/[A-Za-z ! @ # $ % & ( ) _ " ' : ; . 0-9 -]/.test(i.charAt(n))&&(t=t.concat(i.charAt(n)));this.value=t});$(".nameField").bind("input",function(){for(var t="",i=this.value,n=0;n<i.length;n++)/[A-Za-z ' -]/.test(i.charAt(n))&&(t=t.concat(i.charAt(n)));this.value=t})},actions:function(){$(".changeabn").off("click").on("click",function(){$("#abn-change").removeClass("hide");$("#NewABN").val("");$("input[name=OverwriteForms][value='False']").prop("checked",!0);$("#abnerror").html("").removeClass("text-danger")});$(".editable-cancel, #LookupABN").off("click").on("click",function(){$("#abn-change").addClass("hide")});$("#saveNewMainBusinessAbn").on("click",function(n){var t,i;return(n.preventDefault(),t=$("#SavedABN").val(),t=t.replace(/[_\s\n\r]+/g,""),i=$("#NewABN").val(),i=i.replace(/[_\s\n\r]+/g,""),$("#NewABN").val()=="")?($("#abnerror").html("Please enter new ABN").addClass("text-danger"),!1):($("#abnerror").html("").removeClass("text-danger"),$("#NewABN").val().replace(/[_\s\n\r]+/g,"")!=$("#SavedABN").val().replace(/[_\s\n\r]+/g,"")?($("#saveNewMainBusinessAbn").button("loading"),$.post("/AccountSettings/UpdateAbnumber/",{abn:$("#NewABN").val(),encryptOrgBranchId:$("#EncryptMainBusinessId").val(),isFormdraft:!0},function(n){$("#saveNewMainBusinessAbn").button("reset");$("#DivEventSummary").html(n.EventSummary);n.IsSuccess&&($("#abn-change").addClass("hide"),pageReload("/AccountSettings/MainBusinessSettings"))})):$("#abnerror").html("ABN remains same").addClass("text-danger"),!1)})},BankAccountGridItemRemove:function(n){return function(t){t.preventDefault();var i=$(t.target).closest("tr"),r=this.dataItem(i);$(document).openDeleteModal({modalContent:"Are you sure to delete the item?"});$(".confirm-delete").off("click").on("click",function(){$("#"+n).data("kendoGrid").dataSource.remove(r);$("#delete-confirmation-modal").modal("hide");MB_Update.UpdateRemoveBtn(n)})}},UpdateRemoveBtn:function(n){$("#"+n).data("kendoGrid").dataSource._total==1?$(".btnRemoveBankRow").addClass("hide"):$(".btnRemoveBankRow").removeClass("hide")},UpdateMB_Details:function(n){$(document).openModal({modalID:"myMediumModal",modalrequestType:"POST",modalBodyID:"myMedium-modal-body-content",modalUrl:"/AccountSettings/UpdateMainBusinessDetails",modalRequestData:{encryptOrgBranchId:n},modalTitle:"Business Details",modalTitleID:"myMedium-modal-label"})},UpdateMB_EngagementSetting:function(){$(document).openModal({modalID:"myMediumModal",modalrequestType:"POST",modalBodyID:"myMedium-modal-body-content",modalUrl:"/AccountSettings/EngagementSettings",modalRequestData:{},modalTitle:"Advisor's Profile Setting",modalTitleID:"myMedium-modal-label"})},UpdateMB_ContactDetails:function(n){$(document).openModal({modalID:"myMediumModal",modalrequestType:"POST",modalBodyID:"myMedium-modal-body-content",modalUrl:"/AccountSettings/UpdateMainContactDetails",modalRequestData:{encryptOrgBranchId:n},modalTitle:"Contact Details",modalTitleID:"myMedium-modal-label"})},UpdateMB_AddressDetails:function(n){$(document).openModal({modalID:"myMediumModal",modalrequestType:"POST",modalBodyID:"myMedium-modal-body-content",modalUrl:"/AccountSettings/UpdateMainAddressDetails",modalRequestData:{encryptOrgBranchId:n},modalTitle:"More Settings",modalTitleID:"myMedium-modal-label"})},UpdateMB_BankDetails:function(n){$(document).openModal({modalID:"myLargeModal",modalrequestType:"POST",modalBodyID:"myLarge-modal-body-content",modalUrl:"/AccountSettings/UpdateMainBankAccountDetails",modalRequestData:{encryptOrgBranchId:n},modalTitle:"Bank Account Details",modalTitleID:"myLarge-modal-label"})},ShowAccountNo:function(n){$(".maskedAccountNo_"+n).addClass("hide");$(".unmaskedAccountNo_"+n).removeClass("hide")},HideAccountNo:function(n){$(".unmaskedAccountNo_"+n).addClass("hide");$(".maskedAccountNo_"+n).removeClass("hide")},ShowBSBNo:function(n){$(".maskedBSBNo_"+n).addClass("hide");$(".unmaskedBSBNo_"+n).removeClass("hide")},HideBSBNo:function(n){$(".unmaskedBSBNo_"+n).addClass("hide");$(".maskedBSBNo_"+n).removeClass("hide")}};dontConsiderThisTrigger=!1;gr2_Payment={init:function(){$("#PromotionCodeDetails").hide();$("#epromocode").click(function(){$(this).is(":checked")?$("#PromotionCodeDetails").show():$("#PromotionCodeDetails").hide()});$(document).off("submit","#formPromotioncode").on("submit","#formPromotioncode",function(n){n.preventDefault();gr2_Payment.fnGRPromotionDetails()});$(".edditaddress").click(function(){$(".deladdedit").show();$(".deladd").hide();$(".edditaddress").hide()});var n=$("#GrandFatherOfferPlan").data("kendoWindow");n!=undefined&&n.minimize()},actions:function(){$("#addmoreservices").off("click").on("click",function(){var n=$("#ServiceKeys").val(),t=$("#ReturnPageUrl").val();$(document).openModal({modalID:"myLargeModal",modalrequestType:"POST",modalBodyID:"myLarge-modal-body-content",modalUrl:"/Account/GetMoreServices",modalRequestData:{key:n,returnUrl:t,isRenewal:!1,tenantId:0},modalTitle:"Add More Services",modalTitleID:"myLarge-modal-label"})});$("#CCDetails_CardHolderName").on("blur",function(){var n=$("input[name=IsAgreedToSaveCard]:checked").val();n&&$("#CCDetails_CardName").val()==""&&$("#CCDetails_CardName").val($("#CCDetails_CardHolderName").val())});$("#IsAgreedToSaveCard").off("click").on("click",function(){var n=$("input[name=IsAgreedToSaveCard]:checked").val();n?($("#CCDetailsCardName").removeClass("hide"),$("#CCDetails_CardName").val()==""&&$("#CCDetails_CardName").val($("#CCDetails_CardHolderName").val())):$("#CCDetailsCardName").addClass("hide")});$(".btnCreditCalc").off("click").on("click",function(){$(document).openModal({modalID:"myLargeModal",modalrequestType:"POST",modalBodyID:"myLarge-modal-body-content",modalUrl:"/Subscription/GetCreditCalculator",modalRequestData:{},modalTitle:"Credit Calculator",modalTitleID:"myLarge-modal-label"})});$(document).off("click","#updatebillingdetails").on("click","#updatebillingdetails",function(){$("#billingToname").html($("#BillingToName").val());$.ajax({url:"/Subscription/GetAddressHtml",type:"POST",data:{address:$("#BillingToAddress").val()},success:function(n){$("#billingToaddress").html(n)},error:function(){}});$(".deladdcancel").click()});$(".deladdcancel").click(function(){$(".deladdedit").hide();$(".deladd").show();$(".edditaddress").show()});$(document).off("click","#cancelPromotion").on("click","#cancelPromotion",function(){$("#msg").removeClass("alert alert-danger alert-success").html("");$("#PromotionCodeCtrl").val("");$("#PromotionCode").val("");$("#PromotionID").val("");$("#epromocode").removeAttr("checked","checked");$("#PromotionCodeDetails").hide();$("#DiscountPercentage").val("");$("#DiscountAmount").val("");$("#ActualDiscountAmount").val("");gr2_Payment.CalculateAmt()});$(".CreditAmt").on("blur",function(){gr2_Payment.CreditAmountChecking()});$(".spanErr").on("focus",function(){gr2_Payment.clearSpanerror($(this).attr("id"))});$("#PromotionCode").on("focus",function(){$("#msg").html("").removeClass("alert alert-danger alert-success")});$(".CreditAmt").on("blur",function(){gr2_Payment.CalculateAmt()});$(".qty_edit").on("change",function(){var t=$(this).parents("tr").find(".upr").html(),i=$(this).val(),n=i*t;$(this).parents("tr").find(".rowTotal").html(n.toFixed(2));$(this).parents("tr").find(".addItem").html(n.toFixed(2));gr2_Payment.CalculateAmt()});$("#confirm-modal").off("click").on("click",function(){$(document).closeModal();$("#PromotionCode").val("");$("#PromotionID").val("");$("#HasPromotionCode").removeAttr("checked","checked");$("#PromotionCodeDetails").addClass("hide");$("#DiscountPercentage").val("");$("#DiscountAmount").val("");$("#ActualDiscountAmount").val("");gr2_Payment.CalculateAmt()});$(document).off("click","#btnProcessPayment").on("click","#btnProcessPayment",function(n){n.preventDefault();gr2_Payment.onFinishCallback()});$(document).off("change","#ApplyBalanceCredit").on("change","#ApplyBalanceCredit",function(){gr2_Payment.CalculateAmt()});gr2_Payment.CalculateAmt();$(".pro_icon").off("click").on("click",function(){$(".bef_pro").show();$(".aft_pro").hide()});$(document).on("change","input[type='radio'][name='IsMonthlyPayment']",function(){gr2_Payment.fnMonthlyPaymentClicked()});$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?($("#monthlyPaymentDiv").show(),$("#yearlyPaymentDiv").hide()):($("#monthlyPaymentDiv").hide(),$("#yearlyPaymentDiv").show())},fnCheckFieldHasValue:function(n){return n.val()==null||n.val()==""||n.val()==undefined||n.val()==NaN?!1:!0},CreditAmountChecking:function(){var n=$(".CreditAmt").attr("id"),t=$(".CreditAmtField").attr("id"),i;if($("#credit_span").html("").removeClass("text-danger"),i=$("#creditMinVal").val(),gr2_Payment.fnCheckFieldHasValue($("#creditMinVal"))&&gr2_Payment.fnCheckFieldHasValue($("#"+n))==!1&&gr2_Payment.fnCheckFieldHasValue($("#"+t))==!1)return $("#credit_span").html("Credit must be entered").addClass("text-warning bg-warning"),!1;if(gr2_Payment.fnCheckFieldHasValue($("#"+n))&&parseInt($("#creditMinVal").val())>parseInt($("#"+n).val())){if(gr2_Payment.fnCheckFieldHasValue($("#"+t))==!1||parseInt($("#creditMinVal").val())>parseInt($("#"+t).val()))return $("#credit_span").html("Minimum credit should be "+i).addClass("text-warning bg-warning"),!1}else gr2_Payment.CalculateAmt()},isCreditCard:function(n){if(n.length>19)return!1;for(sum=0,mul=1,l=n.length,i=0;i<l;i++)digit=n.substring(l-i-1,l-i),tproduct=parseInt(digit,10)*mul,sum+=tproduct>=10?tproduct%10+1:tproduct,mul==1?mul++:mul--;return sum%10==0?!0:!1},clearSpanerror:function(n){$("#"+n+"_span").html("").removeClass("text-danger")},CalculateAmt:function(n){var h,f,r,t,w,v,tt,o,y,c,k,e,u,d,it,p,i,g,rt,ut,ft;if(!dontConsiderThisTrigger){var l=0,s=0;if($("#creditAmtCalc").val()!=undefined&&$("#creditAmtCalc").val()!=null&&(l=gr2_Payment.fnCheckFieldHasValue($(".CreditAmt"))?$(".CreditAmt").val():0,$("#AddCrdSubTotalAmount").html(parseFloat(l).toFixed(2))),$("#CreditAmount").val(0),$("#creditamt").addClass("hide"),dontConsiderThisTrigger=!0,h=$("#PaymentSummaryGrid").getKendoGrid(),h!=null&&h!=undefined&&h!="")for(f=h.dataSource.data(),r=0;r<f.length;r++)f[r].UnitPrice=f[r].ServiceCode=="CREDITS"?f[r].UnitPrice:$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?parseFloat(f[r].MonthlyPrice)*12:parseFloat(f[r].AnnualPrice),f[r].ItemTotal=parseFloat(f[r].UnitPrice)*parseFloat(f[r].Qty),s=s+parseFloat(f[r].ItemTotal);if(dontConsiderThisTrigger=!1,parseFloat(l)>0&&(s+=parseFloat(l)),$("#SubTotalAmount").html(s.toFixed(2)),t=parseFloat(s),$("#TotalAmount_span").html("$"+t.toFixed(2)),$("#TotalAmount").val(t.toFixed(2)),w=gr2_Payment.fnCheckFieldHasValue($("#GrandFatherDiscountPercent"))?parseFloat($("#GrandFatherDiscountPercent").val()).toFixed(2):0,w>0){var nt=0,a=$("#PaymentSummaryGrid").data("kendoGrid").dataSource.data(),b=0;a!=null&&a!=""&&a!=undefined&&$.each(a,function(n,t){(t.ServiceCode=="SAVVY"||t.ServiceCode=="ONDEMAND"||t.ServiceCode=="SAVVYTA"||t.ServiceCode=="GRUL")&&($("#SessionUserType").val()=="Business"&&t.ServiceCode=="ONDEMAND"&&($("#IsGrandFather").val()==""||$("#IsGrandFather").val()==null)?b=t.UnitPrice:$("#SessionUserType").val()=="Business"&&t.ServiceCode=="ONDEMAND"&&$("#IsGrandFather").val()=="True"&&$("#HasGrandFatherSubs").val()=="False"?b=t.UnitPrice:nt+=t.Qty*t.UnitPrice)});v=parseFloat(parseFloat(nt)*parseFloat(w)/100)+parseFloat(b);$("#GFDiscountAmount_span").html("$"+v.toFixed(2));$("#GrandFatherDiscountAmount").val(v.toFixed(2));t=parseFloat(t-v).toFixed(2)}tt=$("#UnUsedAmount").val();t=parseFloat(t-tt).toFixed(2);o=0;($("#IsReferralDiscount").val()=="True"||$("#IsReferralDiscount").val()=="true"||$("#IsReferralDiscount").val()==!0)&&(y=gr2_Payment.fnCheckFieldHasValue($("#ReferralPercentage"))?$("#ReferralPercentage").val():0,y!=0&&(o=parseFloat(parseFloat(t)*parseFloat(y)/100),o=o.toFixed(2),$("#RefDisPercent_span").html(y),$("#RefDiscountAmount_span").html("$"+o),$("#ReferralDiscount").val(o),t=parseFloat(t-o).toFixed(2)));c=gr2_Payment.fnCheckFieldHasValue($("#DiscountPercentage"))?$("#DiscountPercentage").val():0;k=gr2_Payment.fnCheckFieldHasValue($("#ActualDiscountAmount"))?$("#ActualDiscountAmount").val():0;$("#DisPercent_span").html(c);e=0;e=c!=0?parseFloat(parseFloat(t)*parseFloat(c)/100):0;k!=0&&c==0&&(e=parseFloat(k).toFixed(2),$("#DisPercent_span").text(""));u=0;t>=0?parseFloat(t)>=parseFloat(e)?($("#DiscountAmount_span").html("$"+parseFloat(e).toFixed(2)),$("#DiscountAmount").val(parseFloat(e).toFixed(2)),u=parseFloat(parseFloat(t)-parseFloat(e)),$("#creditamt").addClass("hide")):($("#DiscountAmount").val(t),$("#DiscountAmount_span").html("$"+parseFloat(t).toFixed(2)),u=0):(parseFloat(e)>0&&($("#DiscountAmount").val(""),$("#DiscountAmount_span").html("$"+parseFloat(0).toFixed(2))),u=parseFloat(t),$("#CreditAmount").val((t*-1).toFixed(2)),$("#creditamtctrl").html("$"+(t*-1).toFixed(2)),$("#creditamt").removeClass("hide"));u=u>0?u:0;d=u-parseFloat(parseFloat(u)*100/110);$("#GrossAmount_span").html("");$("#GrossAmount_span").html("$"+d.toFixed(2));$("#Gst").val(d.toFixed(2));$("#NetTotal_span").html("$"+u.toFixed(2));$("#AmountDue").val(u.toFixed(2));it=$("#ApplyBalanceCredit").is(":checked");p=gr2_Payment.fnCheckFieldHasValue($("#AvailableCredits"))?$("#AvailableCredits").val():0;$("#yearlyDue_span").html(u.toFixed(2));i=parseFloat($("#AmountDue").val());g=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True";g&&(i=parseFloat($("#FirstMonthDue").val()));p>0&&it==!0?($("#applyCreditsDiv").show(),rt=parseFloat(i),i=parseFloat(i)-parseFloat(p),i<0?$("#BalanceCredits_span").html(rt.toFixed(2)):$("#BalanceCredits_span").html(parseFloat(p).toFixed(2)),i=i>0?i:0,$("#netPayable_span").html(i.toFixed(2))):($("#applyCreditsDiv").hide(),$("#netPayable_span").html(i.toFixed(2)));ut=$("#PaymentMethod").val();ut=="CreditCard"&&i>0&&i<50?$(".surcharges_div").show():$(".surcharges_div").hide();i>0||g?$("#Payment_Method").removeClass("hide"):$("#Payment_Method").addClass("hide");ft=$("#PaymentTab").val();ft!="CREDITCARD"&&($("#CCDetails_CCType").val(""),$("#CCDetails_CCNo").val(""),$("#CCDetails_CCExpMonth").val(""),$("#CCDetails_CCExpYear").val(""),$("#CCDetails_CCCVM").val(""),$("#CCDetails_CCHolder").val(""));gr2_Payment.GridSelectedKeyUpdate();n||(dontConsiderThisTrigger=!0,gr2_Payment.fnMonthlyPaymentClicked(),dontConsiderThisTrigger=!1)}},fnGRPromotionDetails:function(){var n,t,i;$("#msg").html("").removeClass("alert alert-danger alert-success");$("#PromotionCode").val($("#PromotionCodeCtrl").val());gr2_Payment.fnCheckFieldHasValue($("#PromotionCode"))!=!0?$("#msg").addClass("alert alert-danger").html("Please enter Promotional Code"):(n="",$(".stpId").each(function(){n+=$(this).html()+","}),t="",$(".pricingConfigId").each(function(){t+=$(this).html()+","}),i=$("#MembershipTypeCode").val(),$.getJSON("/Account/GetPromotionDiscount/?Id="+$("#PromotionCode").val()+"&subscriptionTypePricingIds="+n+"&pricingConfigIds="+t+"&membershipTypeCode="+i+"&Pageid="+new Date,function(n){if(n.IsSuccess){$(".bef_pro").hide();$(".aft_pro").show();$(".pro_txt").html($("#PromotionCodeCtrl").val());$("#PromotionValidText").html("");GR_Notification.showSuccessFadeout("Promotional code has been applied");var t=n.Result.split(","),r=parseFloat(t[0]),i=parseFloat(t[2]),u=t[1];$("#PromotionID").val(u);$("#DiscountPercentage").val(r);$("#DiscountAmount").val(i);$("#ActualDiscountAmount").val(i);gr2_Payment.CalculateAmt()}else $("#PromotionValidText").html(n.Message).addClass("text-danger")}))},onFinishCallback:function(){var n=$("#PaymentTab").val(),u,t,f,r,s,h,c,l;if(n=="SAVEDCARD"?(u=$("input[name=CCDetailsCardID]:checked").val(),$("#CCDetails_CardID").val(u)):$("#CCDetails_CardID").val(""),t=parseFloat($("#netPayable_span").html()),$("#msg").html("").removeClass("alert alert-danger alert-success"),f=$("#formPayment").kendoValidator({rules:{BillingToName:function(n){if(n.is("[name=BillingToName]")){var t=$("#BillingToName").val();return t==""||t==null?!1:!0}return!0},"CCDetails.CardID":function(i){if(i.is("[name=CCDetails.CardID]")){if(t>0&&n=="SAVEDCARD"){var r=$("#CCDetails_CardID").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardType":function(i){if(i.is("[name=CCDetails.CardType]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardType").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardNumber":function(i){if(i.is("[name=CCDetails.CardNumber]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardNumber").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardHolderName":function(i){if(i.is("[name=CCDetails.CardHolderName]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardHolderName").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.ValidCardNumber":function(i){if(i.is("[name=CCDetails.CardNumber]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardNumber").val();return r!=""&&r!=null?!0:!0}return!0}return!0},"CCDetails.ExpiryMonth":function(i){if(i.is("[name=CCDetails.ExpiryMonth]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_ExpiryMonth").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.ExpiryYear":function(i){if(i.is("[name=CCDetails.ExpiryYear]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_ExpiryYear").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.SecurityCode":function(i){if(i.is("[name=CCDetails.SecurityCode]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_SecurityCode").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.termsaccept":function(i){if(i.is("[name=termsaccept]")){if(t>0&&n=="CREDITCARD"){var r=$("input[name=termsaccept]:checked").val();return r?!0:!1}return!0}return!0},"CCDetails.CardName":function(i){if(i.is("[name=CCDetails.CardName]")){if(t>0&&n=="CREDITCARD"){var u=$("input[name=IsAgreedToSaveCard]:checked").val(),r=$("#CCDetails_CardName").val();return u&&(r==""||r==null)?!1:!0}return!0}return!0},"PayByInvoice.termsaccept":function(i){if(i.is("[name=invoicetermsaccept]")){if(t>0&&n=="PAYBYINVOICE"){var r=$("input[name=invoicetermsaccept]:checked").val();return r?!0:!1}return!0}return!0}},messages:{BillingToName:"Billingto name is required.","CCDetails.CardID":"Select any one of saved cards","CCDetails.CardType":"Card type is required","CCDetails.CardNumber":"Card number is required","CCDetails.ValidCardNumber":"Enter valid card number","CCDetails.CardHolderName":"Card holder name is required","CCDetails.ExpiryMonth":"Expiry month is required","CCDetails.ExpiryYear":"Expiry year is required","CCDetails.SecurityCode":"Security code is required","CCDetails.termsaccept":"Accept terms and conditions","CCDetails.CardName":"Card display name is required","PayByInvoice.termsaccept":"Accept terms and conditions"},validateOnBlur:!0}).data("kendoValidator"),f.validate()){var i=$("#SelectedPackages").val(),e=!1,o=!1;i!=null&&i!=undefined&&i!=""&&i!=NaN?(r=$("#PaymentSummaryGrid").data("kendoGrid").dataSource.data(),s=$.grep(r,function(n){return n.ServiceCode=="SAVVY"||n.ServiceCode=="SAVVYTA"}),s.length!=0&&(o=!0),h=JSON.stringify(r),$("#PaymentSummaryGridData").val(h),$("#AddCreditsGridData").val("")):(c=$("#AddCreditsGrid").data("kendoGrid").dataSource.data(),l=JSON.stringify(c),$("#AddCreditsGridData").val(l),$("#PaymentSummaryGridData").val(""),e=!0);$(document).openPaymentProcessingModal({modalContent:""});$("#btnProcessPayment").button("loading");$.ajax({url:"/Subscription/PaymentPost/",type:"POST",data:$("#formPayment").serialize(),success:function(n){var f,u,t,r,s,h;if($(document).closeModal(),n.IsSuccess){if(f=$("#GrandFatherOfferPlan").data("kendoWindow"),f==undefined||e||f.close(),u="False",t=$("#selectedPlankey").val().split("|"),t!=null&&t.length>0)for(r=0;r<t.length;r++)t[r].indexOf("AF_IAM")!=-1&&(s=t[r].split("_"),s.length>3&&(h=s[3],parseInt(h)>0&&(u="True")));$("#IAMRedirect").val()=="True"&&(u="True");$("#agreeRedundantPayment").val(!1);i!=null&&i!=undefined&&i!=""&&i!=NaN?($("#selectedPlankey").val(""),gr2_OurServices.updateCartTotal(),o&&$("#TopupCredit").remove(),pageload("/Subscription/PaymentConfirmation/?id="+n.Result+"&key="+$("#selectedPlankey").val()+"&FromIAM="+u)):pageload("/ManageMyAccount/MyPurchase/")}else $("#btnProcessPayment").button("reset"),$("#CCDetails_OrderNumber").val(n.Result),$("#PaymentOrderNum").html(n.Result),$("#agreeRedundantPayment").val(!0),n.Message.startsWith("/ManageMyAccount/")?pageload(n.Message):GR_Notification.showDangerFixed(n.Message)},error:function(){$(document).closeModal();GR_Notification.showDangerFixed("An error occurred, please try again later")}})}else return!1},QtyChange:function(){var f=this.element.closest("tr").find(".upr").html(),t=this.value(),i,n,u;(t==null||t=="")&&(t=0);i=t*f;this.element.closest("tr").find(".rowTotal").html(i.toFixed(2));this.element.closest("tr").find(".addItem").html(i.toFixed(2));var r=this.element.closest("tr").find(".servUniCode").html(),e=this.element.closest("tr"),o=$("#PaymentSummaryGrid").data("kendoGrid").dataItem(e);o.Qty=t;n=$("#ServiceKeys").val();u=n.split("|");$.each(u,function(i,u){if(u!=""&&u!=undefined)if(u.indexOf("UL_GRUL_")!=-1&&r.indexOf("UL_GRUL")!=-1)n=n.replace(u,"UL_GRUL_"+t);else if(u.indexOf("BL_GRBL_")!=-1&&r.indexOf("BL_GRBL")!=-1)n=n.replace(u,"BL_GRBL_"+t);else if(u.indexOf("AF_IAM")!=-1&&r.indexOf("AF_IAM")!=-1){var f=u,e=f.split("_");f=f.replace(e[2],t);n=n.replace(u,f)}});$("#ServiceKeys").val(n);gr2_Payment.CalculateAmt()},RemoveItem:function(){},GridDataBound:function(n){for(var u,f=n.sender.tbody.children(),r=0;r<f.length;r++){var i=$(f[r]),t=n.sender.dataItem(i),e=t.Qty*t.UnitPrice;$(i).find(".rowTotal").html(e.toFixed(2));$(i).find(".addItem").html(e.toFixed(2));(t.ServiceCode.indexOf("CREDIT")!=-1||t.ServiceUniqueCode=="PK_SAVVY"||t.ServiceUniqueCode=="PK_ONDEMAND"||t.ServiceUniqueCode=="PK_SAVVYTA")&&$(i).find(".k-grid-Delete").hide();u=$("#IsMonthlyDuePayment").val();(u=="True"||u=="true")&&$(i).find(".k-grid-Delete").hide()}(this.dataSource.totalPages()==1||this.dataSource.totalPages()==0)&&this.pager.element.hide();$(".templateCell").each(function(){eval($(this).children("script").last().html())});gr2_Payment.CalculateAmt()},onAddCreditDataBound:function(){(this.dataSource.totalPages()==1||this.dataSource.totalPages()==0)&&this.pager.element.hide();$(".templateCell").each(function(){eval($(this).children("script").last().html())});gr2_Payment.CalculateAmt()},UnitPriceChange:function(){var n=this.value(),t,i;(n==null||n=="")&&(n=0);t=this.element.closest("tr");i=$("#AddCreditsGrid").data("kendoGrid").dataItem(t);i.UnitPrice=n;$(".CreditAmt").val(n);gr2_Payment.CalculateAmt()},CreditPriceChange:function(){var n=this.value(),u,i,f,r,t,e;(n==null||n=="")&&(n=0);u=1;i=u*n;this.element.closest("tr").find(".rowTotal").html(i.toFixed(2));this.element.closest("tr").find(".addItem").html(i.toFixed(2));f=this.element.closest("tr");r=$("#PaymentSummaryGrid").data("kendoGrid").dataItem(f);r.Qty=1;r.UnitPrice=n;$(".CreditAmt").val(n);t=$("#ServiceKeys").val();e=t.split("|");$.each(e,function(i,r){r!=""&&r!=undefined&&(r.indexOf("CREDIT_")!=-1||r.indexOf("CREDITS_")!=-1)&&(t=t.replace(r,"CREDIT_"+n))});$("#ServiceKeys").val(t);gr2_Payment.CalculateAmt()},GridSelectedKeyUpdate:function(){},onDelete:function(){return function(n){n.preventDefault();var t=$(n.target).closest("tr"),i=this.dataItem(t);$(document).openDeleteModal({modalContent:"Are you sure to delete the item?"});$(".confirm-delete").off("click").on("click",function(){var t="",r,n;$("#PaymentSummaryGrid").data("kendoGrid").dataSource.remove(i);r=$("#PaymentSummaryGrid").getKendoGrid().dataSource.data();n="";$.each(r,function(i,r){r.ServiceUniqueCode.indexOf("PL_")!=-1||r.ServiceUniqueCode.indexOf("UL_")!=-1||r.ServiceUniqueCode.indexOf("BL_")!=-1?n=r.ServiceUniqueCode+"_"+r.Qty:r.ServiceUniqueCode.indexOf("CREDIT_")!=-1||r.ServiceUniqueCode.indexOf("CREDITS_")!=-1?n="CREDIT_"+r.UnitPrice:r.ServiceUniqueCode.indexOf("AF_IAM")!=-1?(r.OrgBranchID==null&&(r.OrgBranchID=0),n=r.ServiceUniqueCode+"_"+r.Qty+"_"+r.OrgBranchID,$("label[for='IsMonthlyPayment_True']").hasClass("hide")||$("label[for='IsMonthlyPayment_True']").addClass("hide")):(n=r.ServiceUniqueCode,r.ServiceUniqueCode.indexOf("AF_IAM")!=-1||$("label[for='IsMonthlyPayment_True']").hasClass("hide")&&$("label[for='IsMonthlyPayment_True']").removeClass("hide"));t+=n+"|"});$("#selectedPlankey").val()!=""&&$("#selectedPlankey").val()!=null&&$("#selectedPlankey").val()!=undefined&&$("#selectedPlankey").val(t);$("#ServiceKeys").val(t);gr2_OurServices.updateCartTotal();$("#PaymentSummaryGrid").data("kendoGrid")!=undefined&&$("#PaymentSummaryGrid").data("kendoGrid").dataSource.data().length==0&&(window.location.href.indexOf("frequency=YEARLY")!=-1?pageReload("/Subscription/Payment?frequency=YEARLY"):pageload("/Subscription/Payment"));$("#addmoreservices").html()!=undefined&&$("#addmoreservices").removeClass("hide");$(document).closeModal()})}},fnMonthlyPaymentClicked:function(){var i,n,t,r;if(gr2_Payment.fnShowHideMonthlyPayment()){for(i=$("#PaymentSummaryGrid").getKendoGrid(),n=i.dataSource.data(),t=0;t<n.length;t++)n[t].UnitPrice=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?parseFloat(n[t].MonthlyPrice)*12:parseFloat(n[t].AnnualPrice),n[t].ItemTotal=parseFloat(n[t].UnitPrice)*parseFloat(n[t].Qty);i.dataSource.data(n);$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?($("#monthlyPaymentDiv").show(),$("#yearlyPaymentDiv").hide(),r=$("#IsMonthlyDuePayment").val(),$("#creditcard").click(),$("#creditcard").attr("readonly",!0),$("#paybyinvoice").attr("readonly",!0),$("#IsAgreedToSaveCard").is(":checked")==!1&&$("#IsAgreedToSaveCard").click(),$("#saveCCCtrl").hide(),$("#savedCCLabel").show(),r!="True"&&r!="true"&&$.post("/Account/GetMonthlyPaymentSummary",{netAmount:$("#AmountDue").val(),pkgEndDate:$("#PackageEndDate").val()},function(n){n.IsSuccess?($("#monthlyPaymentSummary").html(n.Result),$("#FirstMonthDue").val($("#_FirstMonthDue").val()),gr2_Payment.CalculateAmt(!0)):$("#ErrorMsg").html(n.EventSummary)})):($("#yearlyPaymentDiv").show(),$("#monthlyPaymentDiv").hide(),$("#monthlyPaymentSummary").html(""),$("#creditcard").attr("readonly",!1),$("#paybyinvoice").attr("readonly",!1),$("#saveCCCtrl").show(),$("#savedCCLabel").hide())}},fnShowHideMonthlyPayment:function(){var n=$("#IsMonthlyPaymentAvailable").val(),i=$("#IsMonthlyDuePayment").val()=="True"||$("#IsMonthlyDuePayment").val()=="true",r=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True",t=$("#IsUpgrade").val(),u=$("#AmountDue").val();return(n=="true"||n=="True")&&(t=="true"||t=="True")&&u>20?($("#paymentFrequencyDiv").show(),!0):i||r?($("#monthlyPaymentDiv").show(),$("#yearlyPaymentDiv").hide(),$("#paymentFrequencyDiv").hide(),!0):($("#paymentFrequencyDiv").hide(),$("#monthlyPaymentDiv").hide(),$("#yearlyPaymentDiv").show(),$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"&&$("#IsMonthlyPayment_False").click(),!1)}};gr2_Renewal={init:function(){$("#PromotionCodeDetails").hide();$("#epromocode").click(function(){$(this).is(":checked")?$("#PromotionCodeDetails").show():$("#PromotionCodeDetails").hide()});$(document).off("submit","#formPromotioncode").on("submit","#formPromotioncode",function(n){n.preventDefault();gr2_Renewal.fnGRPromotionDetails()});$(".edditaddress").click(function(){$(".deladdedit").show();$(".deladd").hide();$(".edditaddress").hide()});var n=$("#GrandFatherOfferPlan").data("kendoWindow");n!=undefined&&n.minimize()},actions:function(){$(document).off("click","[name='CCDetailsCardID']").on("click","[name='CCDetailsCardID']",function(){var n=$(this).attr("data-cardindex"),r=$(this).val(),u=$(this),t=$("#SavedCards_"+n+"__IsDefault").val()=="True",i=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True";if(i&&!t){$(document).openConfirmationModal({modalContent:"Do you want to set selected card as default for recurring payments?",submitContent:"Confirm"});$("#confirm-modal").off("click").on("click",function(){$("input:radio[name='CCDetailsCardID']").each(function(){var n=$(this).attr("data-cardindex");$("#SavedCards_"+n+"__IsDefault").val("False");$("#DefaultCard_"+n).addClass("hide")});$("#SavedCards_"+n+"__IsDefault").val("True");$("#DefaultCard_"+n).removeClass("hide");$(document).closeModal()})}});$("#CCDetails_CardHolderName").on("blur",function(){var n=$("input[name=IsAgreedToSaveCard]:checked").val();n&&$("#CCDetails_CardName").val()==""&&$("#CCDetails_CardName").val($("#CCDetails_CardHolderName").val())});$("#IsAgreedToSaveCard").off("click").on("click",function(){var n=$("input[name=IsAgreedToSaveCard]:checked").val();n?($("#CCDetailsCardName").removeClass("hide"),$("#CCDetails_CardName").val()==""&&$("#CCDetails_CardName").val($("#CCDetails_CardHolderName").val())):$("#CCDetailsCardName").addClass("hide")});$(".btnCreditCalc").off("click").on("click",function(){$(document).openModal({modalID:"myLargeModal",modalrequestType:"POST",modalBodyID:"myLarge-modal-body-content",modalUrl:"/Subscription/GetCreditCalculator",modalRequestData:{},modalTitle:"Credit Calculator",modalTitleID:"myLarge-modal-label"})});$(document).off("click","#updatebillingdetails").on("click","#updatebillingdetails",function(){$("#billingToname").html($("#BillingToName").val());$.ajax({url:"/Subscription/GetAddressHtml",type:"POST",data:{address:$("#BillingToAddress").val()},success:function(n){$("#billingToaddress").html(n)},error:function(){}});$(".deladdcancel").click()});$(".deladdcancel").click(function(){$(".deladdedit").hide();$(".deladd").show();$(".edditaddress").show()});$(document).off("click","#cancelPromotion").on("click","#cancelPromotion",function(){$("#msg").removeClass("alert alert-danger alert-success").html("");$("#PromotionCodeCtrl").val("");$("#PromotionCode").val("");$("#PromotionID").val("");$("#epromocode").removeAttr("checked","checked");$("#PromotionCodeDetails").hide();$("#DiscountPercentage").val("");$("#DiscountAmount").val("");$("#ActualDiscountAmount").val("");gr2_Renewal.CalculateAmt()});$(".CreditAmt").on("blur",function(){gr2_Renewal.CreditAmountChecking()});$(".spanErr").on("focus",function(){gr2_Renewal.clearSpanerror($(this).attr("id"))});$("#PromotionCode").on("focus",function(){$("#msg").html("").removeClass("alert alert-danger alert-success")});$(".CreditAmt").on("blur",function(){gr2_Renewal.CalculateAmt()});$(".qty_edit").on("change",function(){var t=$(this).parents("tr").find(".upr").html(),i=$(this).val(),n=i*t;$(this).parents("tr").find(".rowTotal").html(n.toFixed(2));$(this).parents("tr").find(".addItem").html(n.toFixed(2));gr2_Renewal.CalculateAmt()});$("#confirm-modal").off("click").on("click",function(){$(document).closeModal();$("#PromotionCode").val("");$("#PromotionID").val("");$("#HasPromotionCode").removeAttr("checked","checked");$("#PromotionCodeDetails").addClass("hide");$("#DiscountPercentage").val("");$("#DiscountAmount").val("");$("#ActualDiscountAmount").val("");gr2_Renewal.CalculateAmt()});$(document).off("click","#btnProcessRenewalPayment").on("click","#btnProcessRenewalPayment",function(n){n.preventDefault();gr2_Renewal.onFinishCallback()});$(document).off("change","#ApplyBalanceCredit").on("change","#ApplyBalanceCredit",function(){gr2_Renewal.CalculateAmt()});gr2_Renewal.CalculateAmt();$(".pro_icon").off("click").on("click",function(){$(".bef_pro").show();$(".aft_pro").hide()});$(document).on("change","input[type='radio'][name='IsMonthlyPayment']",function(){gr2_Renewal.fnMonthlyPaymentClicked()});$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?($("#monthlyPaymentDiv").show(),$("#yearlyPaymentDiv").hide()):($("#monthlyPaymentDiv").hide(),$("#yearlyPaymentDiv").show())},fnCheckFieldHasValue:function(n){return n.val()==null||n.val()==""||n.val()==undefined||n.val()==NaN?!1:!0},CreditAmountChecking:function(){var n=$(".CreditAmt").attr("id"),t=$(".CreditAmtField").attr("id"),i;if($("#credit_span").html("").removeClass("text-danger"),i=$("#creditMinVal").val(),gr2_Renewal.fnCheckFieldHasValue($("#creditMinVal"))&&gr2_Renewal.fnCheckFieldHasValue($("#"+n))==!1&&gr2_Renewal.fnCheckFieldHasValue($("#"+t))==!1)return $("#credit_span").html("Credit must be entered").addClass("text-warning bg-warning"),!1;if(gr2_Renewal.fnCheckFieldHasValue($("#"+n))&&parseInt($("#creditMinVal").val())>parseInt($("#"+n).val())){if(gr2_Renewal.fnCheckFieldHasValue($("#"+t))==!1||parseInt($("#creditMinVal").val())>parseInt($("#"+t).val()))return $("#credit_span").html("Minimum credit should be "+i).addClass("text-warning bg-warning"),!1}else gr2_Renewal.CalculateAmt()},isCreditCard:function(n){if(n.length>19)return!1;for(sum=0,mul=1,l=n.length,i=0;i<l;i++)digit=n.substring(l-i-1,l-i),tproduct=parseInt(digit,10)*mul,sum+=tproduct>=10?tproduct%10+1:tproduct,mul==1?mul++:mul--;return sum%10==0?!0:!1},clearSpanerror:function(n){$("#"+n+"_span").html("").removeClass("text-danger")},CalculateAmt:function(n){var w,f,r,t,l,a,b,h,k,o,v,e,u,y,d,c,i,p,g,nt,tt;if(!dontConsiderThisTrigger){var s=0;for(dontConsiderThisTrigger=!0,w=$("#RenewalSummaryGrid").getKendoGrid(),f=w.dataSource.data(),r=0;r<f.length;r++)f[r].UnitPrice=f[r].ServiceCode=="CREDITS"?f[r].UnitPrice:$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?parseFloat(f[r].MonthlyPrice)*12:parseFloat(f[r].AnnualPrice),f[r].ItemTotal=parseFloat(f[r].UnitPrice)*parseFloat(f[r].Qty),s=s+parseFloat(f[r].ItemTotal);dontConsiderThisTrigger=!1;$("#SubTotalAmount").html(s.toFixed(2));t=parseFloat(0)+parseFloat(s);$("#TotalAmount_span").html("$"+t.toFixed(2));$("#TotalAmount").val(t.toFixed(2));l=gr2_Renewal.fnCheckFieldHasValue($("#GrandFatherDiscountPercent"))?parseFloat($("#GrandFatherDiscountPercent").val()).toFixed(2):0;l>0&&(a=0,b=$("#RenewalSummaryGrid").data("kendoGrid").dataSource.data(),$.each(b,function(n,t){(t.ServiceCode=="SAVVY"||t.ServiceCode=="SAVVYTA"||t.ServiceCode=="ONDEMAND"||t.ServiceCode=="GRUL")&&(a+=t.Qty*t.UnitPrice)}),h=parseFloat(parseFloat(a)*parseFloat(l)/100),$("#GFDiscountAmount_span").html("$"+h.toFixed(2)),$("#GrandFatherDiscountAmount").val(h.toFixed(2)),t=parseFloat(t-h).toFixed(2));k=$("#UnUsedAmount").val();t=parseFloat(t-k).toFixed(2);o=gr2_Renewal.fnCheckFieldHasValue($("#DiscountPercentage"))?$("#DiscountPercentage").val():0;v=gr2_Renewal.fnCheckFieldHasValue($("#ActualDiscountAmount"))?$("#ActualDiscountAmount").val():0;$("#DisPercent_span").html("");$("#DisPercent_span").html(o);e=o!=0?parseFloat(parseFloat(t)*parseFloat(o)/100):0;v!=0&&o==0&&(e=parseFloat(v).toFixed(2),$("#DisPercent_span").text(""));u=0;t>=0?parseFloat(t)>=parseFloat(e)?($("#DiscountAmount_span").html("$"+parseFloat(e).toFixed(2)),$("#DiscountAmount").val(parseFloat(e).toFixed(2)),u=parseFloat(parseFloat(t)-parseFloat(e)),$("#creditamt").addClass("hide")):($("#DiscountAmount").val(t),$("#DiscountAmount_span").html("$"+parseFloat(t).toFixed(2)),u=0):(parseFloat(e)>0&&($("#DiscountAmount").val(""),$("#DiscountAmount_span").html("$"+parseFloat(0).toFixed(2))),GR_Notification.showInfoFixed("Balance unused amount will be added as credit"),u=parseFloat(t),$("#CreditAmount").val((t*-1).toFixed(2)),$("#creditamtctrl").html("$"+(t*-1).toFixed(2)),$("#creditamt").removeClass("hide"));u=u>0?u:0;y=u-parseFloat(parseFloat(u)*100/110);$("#GrossAmount_span").html("");$("#GrossAmount_span").html("$"+y.toFixed(2));$("#Gst").val(y.toFixed(2));$("#NetTotal_span").html("$"+u.toFixed(2));$("#AmountDue").val(u.toFixed(2));d=$("#ApplyBalanceCredit").is(":checked");c=gr2_Renewal.fnCheckFieldHasValue($("#AvailableCredits"))?$("#AvailableCredits").val():0;$("#yearlyDue_span").html(u.toFixed(2));i=parseFloat($("#AmountDue").val());p=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True";p&&(i=parseFloat($("#FirstMonthDue").val()));c>0&&d==!0?($("#applyCreditsDiv").show(),g=parseFloat(i),i=parseFloat(i)-parseFloat(c),i<0?$("#BalanceCredits_span").html(g.toFixed(2)):$("#BalanceCredits_span").html(parseFloat(c).toFixed(2)),i=i>0?i:0,$("#netPayable_span").html(i.toFixed(2))):($("#applyCreditsDiv").hide(),$("#netPayable_span").html(i.toFixed(2)));nt=$("#PaymentMethod").val();nt=="CreditCard"&&i>0&&i<50?$(".surcharges_div").show():$(".surcharges_div").hide();i>0||p?$("#Payment_Method").removeClass("hide"):$("#Payment_Method").addClass("hide");tt=$("#PaymentTab").val();tt!="CREDITCARD"&&($("#CCDetails_CCType").val(""),$("#CCDetails_CCNo").val(""),$("#CCDetails_CCExpMonth").val(""),$("#CCDetails_CCExpYear").val(""),$("#CCDetails_CCCVM").val(""),$("#CCDetails_CCHolder").val(""));gr2_Renewal.GridSelectedKeyUpdate();n||(dontConsiderThisTrigger=!0,gr2_Renewal.fnMonthlyPaymentClicked(),dontConsiderThisTrigger=!1)}},fnGRPromotionDetails:function(){var n,t,i;$("#msg").html("").removeClass("alert alert-danger alert-success");$("#PromotionCode").val($("#PromotionCodeCtrl").val());gr2_Renewal.fnCheckFieldHasValue($("#PromotionCode"))!=!0?$("#msg").addClass("alert alert-danger").html("Please enter Promotional Code"):(n="",$(".stpId").each(function(){n+=$(this).html()+","}),t="",$(".pricingConfigId").each(function(){t+=$(this).html()+","}),i=$("#MembershipTypeCode").val(),$.getJSON("/Account/GetPromotionDiscount/?Id="+$("#PromotionCode").val()+"&subscriptionTypePricingIds="+n+"&pricingConfigIds="+t+"&membershipTypeCode="+i+"&Pageid="+new Date,function(n){if(n.IsSuccess){$(".bef_pro").hide();$(".aft_pro").show();$(".pro_txt").html($("#PromotionCodeCtrl").val());$("#PromotionValidText").html("");GR_Notification.showSuccessFadeout("Promotional code has been applied");var t=n.Result.split(","),r=parseFloat(t[0]),i=parseFloat(t[2]),u=t[1];$("#PromotionID").val(u);$("#DiscountPercentage").val(r);$("#DiscountAmount").val(i);$("#ActualDiscountAmount").val(i);gr2_Renewal.CalculateAmt()}else $("#PromotionValidText").html(n.Message).addClass("text-danger")}))},onFinishCallback:function(){var n=$("#PaymentTab").val(),i,t,r,e;if(n=="SAVEDCARD"?(i=$("input[name=CCDetailsCardID]:checked").val(),$("#CCDetails_CardID").val(i)):$("#CCDetails_CardID").val(""),t=parseFloat($("#netPayable_span").html()),$("#msg").html("").removeClass("alert alert-danger alert-success"),r=$("#formPaymentRenewal").kendoValidator({rules:{BillingToName:function(n){if(n.is("[name=BillingToName]")){var t=$("#BillingToName").val();return t==""||t==null?!1:!0}return!0},"CCDetails.CardID":function(i){if(i.is("[name=CCDetails.CardID]")){if(t>0&&n=="SAVEDCARD"){var r=$("#CCDetails_CardID").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardType":function(i){if(i.is("[name=CCDetails.CardType]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardType").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardNumber":function(i){if(i.is("[name=CCDetails.CardNumber]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardNumber").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.CardHolderName":function(i){if(i.is("[name=CCDetails.CardHolderName]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardHolderName").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.ValidCardNumber":function(i){if(i.is("[name=CCDetails.CardNumber]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_CardNumber").val();return r!=""&&r!=null?!0:!0}return!0}return!0},"CCDetails.ExpiryMonth":function(i){if(i.is("[name=CCDetails.ExpiryMonth]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_ExpiryMonth").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.ExpiryYear":function(i){if(i.is("[name=CCDetails.ExpiryYear]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_ExpiryYear").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.SecurityCode":function(i){if(i.is("[name=CCDetails.SecurityCode]")){if(t>0&&n=="CREDITCARD"){var r=$("#CCDetails_SecurityCode").val();return r==""||r==null?!1:!0}return!0}return!0},"CCDetails.termsaccept":function(i){if(i.is("[name=termsaccept]")){if(t>0&&n=="CREDITCARD"){var r=$("input[name=termsaccept]:checked").val();return r?!0:!1}return!0}return!0},"CCDetails.CardName":function(i){if(i.is("[name=CCDetails.CardName]")){if(t>0&&n=="CREDITCARD"){var u=$("input[name=IsAgreedToSaveCard]:checked").val(),r=$("#CCDetails_CardName").val();return u&&(r==""||r==null)?!1:!0}return!0}return!0},"PayByInvoice.termsaccept":function(i){if(i.is("[name=invoicetermsaccept]")){if(t>0&&n=="PAYBYINVOICE"){var r=$("input[name=invoicetermsaccept]:checked").val();return r?!0:!1}return!0}return!0}},messages:{BillingToName:"Billingto name is required.","CCDetails.CardID":"Select any one of saved cards","CCDetails.CardType":"Card type is required","CCDetails.CardNumber":"Card number is required","CCDetails.ValidCardNumber":"Enter valid card number","CCDetails.CardHolderName":"Card holder name is required","CCDetails.ExpiryMonth":"Expiry month is required","CCDetails.ExpiryYear":"Expiry year is required","CCDetails.SecurityCode":"Security code is required","CCDetails.termsaccept":"Accept terms and conditions","CCDetails.CardName":"Card display name is required","PayByInvoice.termsaccept":"Accept terms and conditions"},validateOnBlur:!0}).data("kendoValidator"),r.validate()){var o=!1,u=!1,f=$("#RenewalSummaryGrid").data("kendoGrid").dataSource.data(),s=$.grep(f,function(n){return n.ServiceCode=="SAVVY"||n.ServiceCode=="SAVVYTA"});s.length!=0&&(u=!0);e=JSON.stringify(f);$("#RenewalSummaryGridData").val(e);$(document).openPaymentProcessingModal({modalContent:""});$("#btnProcessRenewalPayment").button("loading");$.ajax({url:"/Subscription/PaymentRenewalPost/",type:"POST",data:$("#formPaymentRenewal").serialize(),success:function(n){var r,f,t,i,e,s;if($(document).closeModal(),n.IsSuccess){if(r=$("#GrandFatherOfferPlan").data("kendoWindow"),r==undefined||o||r.close(),f="False",t=$("#selectedPlankey").val().split("|"),t!=null&&t.length>0)for(i=0;i<t.length;i++)t[i].indexOf("AF_IAM")!=-1&&(e=t[i].split("_"),e.length>3&&(s=e[3],parseInt(s)>0&&(f="True")));$("#agreeRedundantPayment").val(!1);gr2_OurServices.updateCartTotal();$("#selectedPlankey").val("");u&&$("#TopupCredit").remove();pageload("/Subscription/PaymentConfirmation/?id="+n.Result+"&key="+$("#selectedPlankey").val()+"&FromIAM="+f+"&IsRenewal=True")}else $("#btnProcessRenewalPayment").button("reset"),$("#CCDetails_OrderNumber").val(n.Result),$("#PaymentOrderNum").html(n.Result),$("#agreeRedundantPayment").val(!0),GR_Notification.showDangerFixed(n.Message)},error:function(){$(document).closeModal();GR_Notification.showDangerFixed("An error occurred, please try again later")}})}else return!1},QtyChange:function(){var f=this.element.closest("tr").find(".upr").html(),t=this.value(),r=t*f,n,u;this.element.closest("tr").find(".rowTotal").html(r.toFixed(2));this.element.closest("tr").find(".addItem").html(r.toFixed(2));var i=this.element.closest("tr").find(".servUniCode").html(),e=this.element.closest("tr"),o=$("#RenewalSummaryGrid").data("kendoGrid").dataItem(e);o.Qty=t;n=$("#ServiceKeys").val();u=n.split("|");$.each(u,function(r,u){if(u!=""&&u!=undefined)if(u.indexOf("UL_GRUL_")!=-1&&i.indexOf("UL_GRUL")!=-1)n=n.replace(u,"UL_GRUL_"+t);else if(u.indexOf("BL_GRBL_")!=-1&&i.indexOf("BL_GRBL")!=-1)n=n.replace(u,"BL_GRBL_"+t);else if(u.indexOf("AF_IAM")!=-1&&i.indexOf("AF_IAM")!=-1){var f=u,e=f.split("_");f=f.replace(e[2],t);n=n.replace(u,f)}});$("#ServiceKeys").val(n);gr2_Renewal.CalculateAmt()},RemoveItem:function(){},GridDataBound:function(n){for(var u=n.sender.tbody.children(),f=[],r=0;r<u.length;r++){var i=$(u[r]),t=n.sender.dataItem(i),e=t.Qty*t.UnitPrice;$(i).find(".rowTotal").html(e.toFixed(2));$(i).find(".addItem").html(e.toFixed(2));(t.ServiceUniqueCode=="PK_SAVVY"||t.ServiceUniqueCode=="PK_SAVVYTA"||t.ServiceUniqueCode=="PK_ONDEMAND"||t.ServiceCode.indexOf("CREDIT")!=-1)&&$(i).find(".k-grid-Delete").hide();f.push(t.ServiceUniqueCode)}$(".cls_Service").removeClass("hide");$.each(f,function(n,t){t.indexOf("RUL_GRUL")!=-1?($("#RUL_Service").addClass("hide"),$("#RUL_GRUL_1").attr("checked",!1)):t.indexOf("RBL_GRBL")!=-1?($("#RBL_Service").addClass("hide"),$("#RBL_GRBL_1").attr("checked",!1)):t.indexOf("RAF_IAMCOMPLETE")!=-1?($("#RAF_IAMService").addClass("hide"),$("#RAF_IAMCOMPLETE_1").attr("checked",!1)):t.indexOf("RAF_")!=-1&&($("#RAF_Service").addClass("hide"),$("#"+t).attr("checked",!1))});gr2_Renewal.checkMoreServices();(this.dataSource.totalPages()==1||this.dataSource.totalPages()==0)&&this.pager.element.hide();$(".templateCell").each(function(){eval($(this).children("script").last().html())});gr2_Renewal.CalculateAmt()},checkMoreServices:function(){$(".nomoreServ").addClass("hide");($("#RUL_Service").val()==undefined||$("#RUL_Service").hasClass("hide"))&&($("#RBL_Service").val()==undefined||$("#RBL_Service").hasClass("hide"))&&($("#RAF_IAMService").val()==undefined||$("#RAF_IAMService").hasClass("hide"))&&($("#RAF_Service").val()==undefined||$("#RAF_Service").hasClass("hide"))&&$("#switchPack").val()==undefined&&$(".nomoreServ").removeClass("hide")},onAddCreditDataBound:function(){(this.dataSource.totalPages()==1||this.dataSource.totalPages()==0)&&this.pager.element.hide();$(".templateCell").each(function(){eval($(this).children("script").last().html())});gr2_Renewal.CalculateAmt()},UnitPriceChange:function(){var n=this.value(),t=this.element.closest("tr"),i=$("#AddCreditsGrid").data("kendoGrid").dataItem(t);i.UnitPrice=n;$(".CreditAmt").val(n);gr2_Renewal.CalculateAmt()},CreditPriceChange:function(){var t=this.value(),r=1*t,u,i,n,f;this.element.closest("tr").find(".rowTotal").html(r.toFixed(2));this.element.closest("tr").find(".addItem").html(r.toFixed(2));u=this.element.closest("tr");i=$("#RenewalSummaryGrid").data("kendoGrid").dataItem(u);i.Qty=1;i.UnitPrice=t;n=$("#ServiceKeys").val();f=n.split("|");$.each(f,function(i,r){r!=""&&r!=undefined&&(r.indexOf("CREDIT_")!=-1||r.indexOf("CREDITS_")!=-1)&&(n=n.replace(r,"CREDIT_"+t))});$("#ServiceKeys").val(n);gr2_Renewal.CalculateAmt()},GridSelectedKeyUpdate:function(){},onDelete:function(){return function(n){n.preventDefault();var i=$(n.target).closest("tr"),t=this.dataItem(i);$(document).openDeleteModal({modalContent:"Are you sure to delete the item?"});$(".confirm-delete").off("click").on("click",function(){var i="",r,n;$("#RenewalSummaryGrid").data("kendoGrid").dataSource.remove(t);r=$("#RenewalSummaryGrid").getKendoGrid().dataSource.data();n="";$.each(r,function(t,r){r.ServiceUniqueCode.indexOf("PL_")!=-1||r.ServiceUniqueCode.indexOf("UL_")!=-1||r.ServiceUniqueCode.indexOf("BL_")!=-1?n=r.ServiceUniqueCode+"_"+r.Qty:r.ServiceUniqueCode.indexOf("CREDIT_")!=-1||r.ServiceUniqueCode.indexOf("CREDITS_")!=-1?n="CREDIT_"+r.UnitPrice:r.ServiceUniqueCode.indexOf("AF_IAM")!=-1?(r.OrgBranchID==null&&(r.OrgBranchID=0),n=r.ServiceUniqueCode+"_"+r.Qty+"_"+r.OrgBranchID):n=r.ServiceUniqueCode;i+=n+"|"});$("#ServiceKeys").val(i);t.ServiceUniqueCode.indexOf("RUL_GRUL")!=-1?$("#RUL_GRUL_1").attr("checked",!1):t.ServiceUniqueCode.indexOf("RBL_GRBL")!=-1?$("#RBL_GRBL_1").attr("checked",!1):t.ServiceUniqueCode.indexOf("RAF_IAMCOMPLETE")!=-1?$("#RAF_IAMCOMPLETE_1").attr("checked",!1):t.ServiceUniqueCode.indexOf("RAF_")!=-1&&$("#"+t.ServiceUniqueCode).attr("checked",!1);$("#RenewalSummaryGrid").data("kendoGrid")!=undefined&&$("#RenewalSummaryGrid").data("kendoGrid").dataSource.data().length==0&&(window.location.href.indexOf("frequency=YEARLY")!=-1?pageReload("/Subscription/Payment?frequency=YEARLY"):pageload("/Subscription/Payment"));$("#addmoreservices").html()!=undefined&&$("#addmoreservices").removeClass("hide");$(document).closeModal()})}},fnMonthlyPaymentClicked:function(){var i,n,t,u;if(gr2_Renewal.fnShowHideMonthlyPayment()){for(i=$("#RenewalSummaryGrid").getKendoGrid(),n=i.dataSource.data(),t=0;t<n.length;t++)n[t].UnitPrice=$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"?parseFloat(n[t].MonthlyPrice)*12:parseFloat(n[t].AnnualPrice),n[t].ItemTotal=parseFloat(n[t].UnitPrice)*parseFloat(n[t].Qty);if(i.dataSource.data(n),$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"){$("#monthlyPaymentDiv").show();$("#yearlyPaymentDiv").hide();$("input:radio[name='CCDetailsCardID']").each(function(){$(this).prop("checked",!1)});$("#creditcard").click();$("#creditcard").attr("readonly",!0);$("#paybyinvoice").attr("readonly",!0);$("#IsAgreedToSaveCard").is(":checked")==!1&&$("#IsAgreedToSaveCard").click();$("#saveCCCtrl").hide();$("#savedCCLabel").show();var f=!1,r=$("#RenewalSummaryGrid").data("kendoGrid").dataSource.data(),e=$.grep(r,function(n){return n.ServiceCode=="SAVVY"||n.ServiceCode=="SAVVYTA"});e.length!=0&&(f=!0);u=JSON.stringify(r);$("#RenewalSummaryGridData").val(u);$.ajax({url:"/Account/GetMonthlyPaymetSummaryRenewal/",type:"POST",data:$("#formPaymentRenewal").serialize(),success:function(n){n.IsSuccess?($("#monthlyPaymentSummary").html(n.Result),$("#FirstMonthDue").val($("#_FirstMonthDue").val()),gr2_Renewal.CalculateAmt(!0)):$("#ErrorMsg").html(n.EventSummary)},error:function(){GR_Notification.showDangerFixed("An error occurred, please try again later")}})}else $("#yearlyPaymentDiv").show(),$("#monthlyPaymentDiv").hide(),$("#monthlyPaymentSummary").html(""),$("#creditcard").attr("readonly",!1),$("#paybyinvoice").attr("readonly",!1),$("#saveCCCtrl").show(),$("#savedCCLabel").hide()}},fnShowHideMonthlyPayment:function(){var n=$("#IsMonthlyPaymentAvailable").val(),t=$("#AmountDue").val();return(n=="true"||n=="True")&&t>20?($("#paymentFrequencyDiv").show(),!0):($("#paymentFrequencyDiv").hide(),$("#monthlyPaymentDiv").hide(),$("#yearlyPaymentDiv").show(),$("input[type='radio'][name='IsMonthlyPayment']:checked").val()=="True"&&$("#IsMonthlyPayment_False").click(),!1)}};IP_Update={init:function(){IP_Update.ShowHideIPGridContainer()},actions:function(){$("#EnableIPAuthentication").click(function(){IP_Update.ShowHideIPGridContainer()});$("#addIPAddressgrid").off("click","#UpdateIPAuthenticationDet").on("click","#UpdateIPAuthenticationDet",function(){var n,t;$("#UpdateIPAuthenticationDet").button("loading");$("#IPAuthErr").html("");n=$("#IPDetails").data("kendoGrid").dataSource.data();$("#IPAddressGridData").val(JSON.stringify(n));t=$("#addIPAddressgrid").serialize();$.post("/AccountSettings/SaveIPAuthenticationDetails",t,function(n){$("#UpdateIPAuthenticationDet").button("reset");n.IsSuccess?$("#DivEventSummary").html(n.EventSummary):$("#IPAuthErr").html(n.EventSummary)})});$("#closeipsettings").off("click").on("click",function(){pageload("/Home/Welcome")})},IPDetailsGridItemRemove:function(n){return function(t){t.preventDefault();var i=$(t.target).closest("tr"),r=this.dataItem(i);$(document).openDeleteModal({modalContent:"Are you sure to delete the item?"});$(".confirm-delete").off("click").on("click",function(){$("#"+n).data("kendoGrid").dataSource.remove(r);$("#delete-confirmation-modal").modal("hide");IP_Update.UpdateRemoveBtn(n)})}},UpdateRemoveBtn:function(n){$("#"+n).data("kendoGrid").dataSource._total==1?$(".btnRemoveBankRow").addClass("hide"):$(".btnRemoveBankRow").removeClass("hide")},ShowHideIPGridContainer:function(){$("#EnableIPAuthentication").is(":checked")?$("#IPGridContainer").show():$("#IPGridContainer").hide()}};gv2_UsersView={init:function(){$("#UserListgrid").off("click",".EditUserProfile").on("click",".EditUserProfile",function(){var n=$(this).attr("data-id");$.post("/AccountSettings/EditUserSettings/"+n,function(n){n.IsSuccess&&(window.location.href=n.Result)})})},actions:function(){$(".UsersListGrid").on("click",".triggershoot",function(){var n=$(this).parent("tr").find("td:first").html();gv2_UsersView.ShowPreview(n)})},onDataBound:function(){SaveGridState("UserListgrid")},ShowPreview:function(n){var t={id:n};$("#UserRole").val()=="Client"||$("#UserRole").val()=="Corporate"?panelload("/AccountSettings/MyUsers/"+n,"/AccountSettings/EmailProfile",t):panelload("/AccountSettings/MyUsers/"+n,"/AccountSettings/EmailProfile",t)}};gv2_EmailLog={init:function(){$("#EmailLogListgridFilter").keyup(function(n){n.which==13&&$("#EmailLogListgrid").data("kendoGrid").dataSource.read()});$("#EmailLogListgrid").off("click",".EditUserProfile").on("click",".EditUserProfile",function(){var n=$(this).attr("data-id");$.post("/AccountSettings/EditUserSettings/"+n,function(n){n.IsSuccess&&window.open(n.Result,"_blank")})})},actions:function(){$(".EmailLogListGrid").on("click",".triggershoot",function(){var n=$(this).parent("tr").find("td:first").html();gv2_EmailLog.ShowPreview(n)})},onDataBound:function(){SaveGridState("EmailLogListgrid")},ShowPreview:function(n){var t={id:n};panelload("/AccountSettings/Emaillog/"+n,"/AccountSettings/EmailProfile",t)},HideFilterMenu:function(n){var r=n.container.find("select:eq(0)").data("kendoDropDownList"),t,i;setTimeout(function(){r.wrapper.hide()});n.field==="SentOn"&&(t=n.container.find("select:eq(1)").data("kendoDropDownList"),i=n.container.find("select:eq(2)").data("kendoDropDownList"),setTimeout(function(){t.wrapper.hide();i.wrapper.hide()}))}};gr2_UserLicenceListPartial={init:function(){$("#UserLicenceCountTotalDisplay").html($("#UserLicenceCountTotal").val());$("#AllocatedUserLicenceCountTotalDisplay").html($("#AllocatedUserLicenceCountTotal").val());$("#AvailableUserLicenceCountTotalDisplay").html($("#AvailableUserLicenceCountTotal").val())},actions:function(){$("#UserLicenceListView").off("click",".RemoveUser").on("click",".RemoveUser",function(){var n,i,t;$("#selectedUserlicenseId").val(0);$("#selectedMembershipId").val(0);$("#custom-removeRole").removeClass("hide");n=$(this).attr("data-fname")+" "+$(this).attr("data-lname");i=$(this).attr("data-id");$(".UserLicenceName").html("Do you want to remove licence for "+n);t=$(this).attr("data-memid");$("#selectedMembershipId").val(t)});$("#UserLicenceListView").off("click",".AssignUser").on("click",".AssignUser",function(){$("#selectedUserlicenseId").val(0);$("#selectedMembershipId").val(0);$("#custom-removeRole").addClass("hide");var n=$(this).attr("data-id");n>0?($("#selectedUserlicenseId").val(n),$.post("/ManageMyAccount/AssignLicenceView",function(n){n.IsSuccess==!0?($("#changeallocateduser").html(""),$("#changeallocateduser").html(n.Message),$("#changeallocateduser").modal("show")):GR_Notification.showDangerFadeout(n.Message)})):GR_Notification.showDangerFixed("An error occured. Please try later")});$("#UserLicenceListView").off("click","#cancel-memberRole").on("click","#cancel-memberRole",function(){$("#custom-removeRole").addClass("hide")});$("#UserLicenceListView").off("click","#save-memberRole").on("click","#save-memberRole",function(){var t=$("#selectedUserlicenseId").val(),n=$("#selectedMembershipId").val();n>0?$.post("/ManageMyAccount/UpdateUserLicense",{memberId:n,LicenseId:t},function(n){n.IsSuccess?($("#UserLicenceListView").html(n.Result),$("#custom-removeRole").addClass("hide"),$("#custom-memberRole").addClass("hide"),$("#divErrormsgUserLicenceListPartial").html(n.EventSummary),$("#changeallocateduser").modal("hide"),$(".modal-backdrop").addClass("hide")):($("#UserLicenceListView").html(n.Result),$("#divErrormsgUserLicenceListPartial").html(n.EventSummary))}):GR_Notification.showDangerFixed("An error occured. Please try later")})},assign:function(){$("#saveUserLicenceform").off("click").on("click",function(){var n=$("#selectedUserlicenseId").val(),t=$("#Unallocatedmemid").val();t>0&&n>0?$.post("/ManageMyAccount/UpdateUserLicense",{memberId:t,LicenseId:n},function(n){n.IsSuccess?($("#UserLicenceListView").html(n.Result),$("#custom-removeRole").addClass("hide"),$("#custom-memberRole").addClass("hide"),$("#changeallocateduser").modal("hide"),$(".modal-backdrop").addClass("hide"),$("#divErrormsgUserLicenceListPartial").html(n.EventSummary)):($("#UserLicenceListView").html(n.Result),$("#divErrormsgUserLicenceListPartial").html(n.EventSummary))}):GR_Notification.showDangerFixed("An error occured. Please try later")})}};gr2_BusinessLicense={init:function(){$("#BusinessLicenceCountTotalDisplay").html($("#BusinessLicenceCountTotal").val());$("#AllocatedBusinessLicenceCountTotalDisplay").html($("#AllocatedBusinessLicenceCountTotal").val());$("#AvailableBusinessLicenceCountTotalDisplay").html($("#AvailableBusinessLicenceCountTotal").val())},actions:function(){$("#BusinessLicenceListView").off("click",".AssignOrgBr").on("click",".AssignOrgBr",function(){$("#selectedBusinesslicenseId").val("");$("#selectedOrgId").val(0);$("#custom-removeRole").addClass("hide");var n=$(this).attr("data-id");n!=""?($("#selectedBusinesslicenseId").val(n),$.post("/ManageMyAccount/AssignBusinessLicenceView",function(n){n.IsSuccess==!0?($("#ChangeAllocatedBusiness").html(""),$("#ChangeAllocatedBusiness").html(n.Message),$("#ChangeAllocatedBusiness").modal("show")):GR_Notification.showDangerFadeout(n.Message)})):GR_Notification.showDangerFixed("An error occured. Please try later")})},assign:function(){$("#saveBusienssLicenceform").off("click").on("click",function(){var t=$("#selectedBusinesslicenseId").val(),n=$("#UnallocatedOrgBranchId").val();n!=""?$.post("/ManageMyAccount/UpdateBusinessLicense",{organisationId:n,businessLicenseId:t},function(n){n.IsSuccess?($("#BusinessLicenceListView").html(n.Result),$("#ChangeAllocatedBusiness").modal("hide"),$(".modal-backdrop").addClass("hide")):$("#BusinessLicenceListView").html(n.Result);$("#divAssignErrormsg").html(n.EventSummary)}):GR_Notification.showDangerFixed("Please select organisation")})}};gr2_IAMServices={init:function(){var n=$("#selectedPlankey").val(),t=$("#OrgBranchID").val();n.indexOf("AF_IAMADV")>=0&&($("#sales .img_service").addClass("hide"),$("#purchase .img_service").addClass("hide"),$("#payroll .img_service").addClass("hide"),$("#sales .img_service").html("Add"),$("#purchase .img_service").html("Add"),$("#payroll .img_service").html("Add"),$("#sales").removeClass("selected_item"),$("#purchase").removeClass("selected_item"),$("#payroll").removeClass("selected_item"));gr2_IAMServices.updateCartTotal()},actions:function(){$(".servicecontainer").off("click",".img_service").on("click",".img_service",function(){var n,r,i,t;$(this).html()=="Add"?(r=$("#selectedPlankey").val(),i="",$(this).attr("data-servicetype")=="addons"&&(i=$(this).attr("data-servicecode"),$(this).html("Remove")),t=$("#OrgBranchID").val(),$("#selectedPlankey").val(r+i+"_1_"+t+"|"),$(this).parents(".ticketcontainer").addClass("selected_item"),$(this).parents(".ticketcontainer").find(".ribbon-inner").html("Selected"),i=="AF_IAMADV"?(n=$("#selectedPlankey").val(),n=n.replace("AF_IAMSALES_1_"+t+"|",""),n=n.replace("AF_IAMPURCHASE_1_"+t+"|",""),n=n.replace("AF_IAMPAYROLL_1_"+t+"|",""),$("#selectedPlankey").val(n),$("#sales .img_service").addClass("hide"),$("#purchase .img_service").addClass("hide"),$("#payroll .img_service").addClass("hide"),$("#sales .img_service").html("Add"),$("#purchase .img_service").html("Add"),$("#payroll .img_service").html("Add"),$("#sales").removeClass("selected_item"),$("#purchase").removeClass("selected_item"),$("#payroll").removeClass("selected_item")):($("#sales .img_service").removeClass("hide"),$("#purchase .img_service").removeClass("hide"),$("#payroll .img_service").removeClass("hide"),n=$("#selectedPlankey").val(),n.indexOf("AF_IAMSALES_1_"+t)!=-1&&n.indexOf("AF_IAMPURCHASE_1_"+t)!=-1&&n.indexOf("AF_IAMPAYROLL_1_"+t)!=-1&&($("#sales .img_service").addClass("hide"),$("#purchase .img_service").addClass("hide"),$("#payroll .img_service").addClass("hide"),n=n.replace("AF_IAMSALES_1_"+t+"|",""),n=n.replace("AF_IAMPURCHASE_1_"+t+"|",""),n=n.replace("AF_IAMPAYROLL_1_"+t+"|",""),n=n+"AF_IAMADV_1_"+t+"|",$("#selectedPlankey").val(n),$("#advanced").addClass("selected_item"),$("#advanced .img_service").html("Remove"),$("#advanced").find(".ribbon-inner").html("Selected"),$("#sales").removeClass("selected_item"),$("#purchase").removeClass("selected_item"),$("#payroll").removeClass("selected_item"),$("#sales").find(".ribbon-inner").html(""),$("#purchase").find(".ribbon-inner").html(""),$("#payroll").find(".ribbon-inner").html(""),$("#sales .img_service").html("Add"),$("#purchase .img_service").html("Add"),$("#payroll .img_service").html("Add")))):(r=$("#selectedPlankey").val(),i="",$(this).attr("data-servicetype")=="addons"&&(i=$(this).attr("data-servicecode"),$(this).html("Add")),i=="AF_IAMADV"&&($("#sales .img_service").removeClass("hide"),$("#purchase .img_service").removeClass("hide"),$("#payroll .img_service").removeClass("hide")),t=$("#OrgBranchID").val(),r=r.replace(i+"_1_"+t+"|",""),$("#Check_"+$(this).attr("data-servicecode")).is(":checked")||$(this).attr("data-ispurchased")=="true"?$(".PLCOUNT_"+$(this).attr("data-servicecode")).removeClass("hide"):$(".PLCOUNT_"+$(this).attr("data-servicecode")).addClass("hide"),$("#selectedPlankey").val(r),$(this).parents(".ticketcontainer").removeClass("selected_item"),$(this).attr("data-ispurchased")=="true"?($(this).parents(".ticketcontainer").find(".ribbon-inner").html("Purchased"),$(this).parents(".ticketcontainer").addClass("purchased")):$(this).parents(".ticketcontainer").find(".ribbon-inner").html(""),$("#chk_"+$(this).attr("data-servicecode")).removeClass("hide"));gr2_IAMServices.updateCartTotal()});$("#AssignPackage").off("click").on("click",function(){$("#ExistingPackagemsg").html("").removeClass("text-danger");var t=$("#OrgBranchID").val(),n=$("#package").val();if(n==""||n==null||n==undefined){$("#ExistingPackagemsg").html("Please select the package").addClass("text-danger");return}$.post("/Subscription/AssignIAMService",{orgBranchID:t,planPackageID:n},function(n){if(n.IsSuccess){var t=$("#iamreturnUrl").val();window.location.href=t}})});$("#LetClientPay").off("click").on("click",function(){var n=$("#iamreturnUrl").val();window.location.href=n});$(".ann_cls_btn").off("click").on("click",function(){$.post("/Subscription/RemoveAnnualKeys",function(n){if(n.IsSuccess){$("#selectedPlankey").val(n.Message);gr2_IAMServices.updateCartTotal();var t=$("#HiddenOrgBranchId").val();t!=""&&t!=undefined&&t!=null?pageReload("/Subscription/IAMServices/"+t):pageReload("/Subscription/OurServices")}})});$(".mon_cls_btn").off("click").on("click",function(){$.post("/Subscription/RemoveMonthlyKeys",function(n){if(n.IsSuccess){$("#selectedPlankey").val(n.Message);gr2_IAMServices.updateCartTotal();var t=$("#HiddenOrgBranchId").val();t!=""&&t!=undefined&&t!=null?pageReload("/Subscription/IAMServices/"+t):pageReload("/Subscription/OurServices")}})});$("#package").off("change").on("change",function(){$("#ExistingPackagemsg").html("").removeClass("text-danger")})},updateCartTotal:function(){$.getJSON("/Subscription/GetCartTotal/",{key:$("#selectedPlankey").val()},function(n){var t="";n.length>0?($("#price_cart_btn").attr("style",""),$(".annual_price_cart").addClass("hide"),$(".monthly_price_cart").addClass("hide"),n[0].Freqency=="YEARLY"?(t=n[0].ServiceCount,$(".annual_price_cart").removeClass("hide"),$("#ann_form_count").html(n[0].ServiceCount),$("#ann_form_amount").html(n[0].TotalAmount)):n[0].Freqency=="MONTHLY"&&(t=n[0].ServiceCount,$(".monthly_price_cart").removeClass("hide"),$("#mon_form_count").html(n[0].ServiceCount),$("#mon_form_amount").html(n[0].TotalAmount)),n[1]!=null&&($(".hr_line_pricart").removeClass("hide"),n[1].Freqency=="YEARLY"?(t=t+n[1].ServiceCount,$(".annual_price_cart").removeClass("hide"),$("#ann_form_count").html(n[1].ServiceCount),$("#ann_form_amount").html(n[1].TotalAmount)):n[1].Freqency=="MONTHLY"&&(t=t+n[1].ServiceCount,$(".monthly_price_cart").removeClass("hide"),$("#mon_form_count").html(n[1].ServiceCount),$("#mon_form_amount").html(n[1].TotalAmount))),$("#cartTotal").html(t.toString())):$("#price_cart_btn").attr("style","display: none !important;")})},getServiceCode:function(n){return $("#Check_"+n).is(":checked")?"PL_"+n+"_"+$("#Qty_"+n).val():"PF_"+n},updateItemTotal:function(){var n=$("#UnitPricePerUse_"+this.element.attr("data-servicecode")).val(),t=this.value(),i=t*n;$(".PLTOT_"+this.element.attr("data-servicecode")).html(i.toFixed(2))},onUserLicenseCountChange:function(){},onSubsTypeChange:function(n){$("#Check_"+n).is(":checked")?($(".PLCON_"+n).removeClass("hide"),$(".PFCON_"+n).addClass("hide"),$(".PLCOUNT_"+n).removeClass("hide"),$("#purchased_actns_"+n).removeClass("hide")):($(".PFCON_"+n).removeClass("hide"),$(".PLCON_"+n).addClass("hide"),$(".PLCOUNT_"+n).addClass("hide"),$("#purchased_actns_"+n).addClass("hide"))}};creditCalc={init:function(){},actions:function(){$("#creditcalcPost").off("click").on("click",function(){var n=$("#CreditCalculatorTotal").html();$(".CreditAmt").val(Math.ceil(n));$(".CreditAmt").blur();$(document).closeModal()})},FormQtyChange:function(){var t=this,i=0,n=t.value(),e=t.element.closest("tr"),r=$("#CreditCalculatorGrid").data("kendoGrid").dataItem(e),u,f;(n==null||n==""||n==undefined)&&(n=0);u=r.ReportTypID;f=$("#entityUserTyp").val();$.ajaxSetup({async:!1});$.post("/Account/GetReportTypeCredits/",{userTyp:f,reportTypeId:u,quantity:n,agency:r.AgencyName},function(n){n.IsSuccess&&(i=parseFloat(n.Result))});$.ajaxSetup({async:!0});t.element.closest("tr").find(".rowQtyTotal").html(i.toFixed(2));t.element.closest("tr").find(".addQtyItem").html(i.toFixed(2));r.Qty=n;creditCalc.showAddCredit()},GridCalcDataBound:function(){$(".templateCell").each(function(){eval($(this).children("script").last().html())});creditCalc.showAddCredit()},showAddCredit:function(){var n=0;$(".addQtyItem").each(function(){n=n+parseFloat($(this).html()!=null&&$(this).html()!=""?$(this).html():"0")});$("#CreditCalculatorTotal").html(n.toFixed(2));n>0?$("#creditcalcPost").removeClass("hide"):$("#creditcalcPost").addClass("hide")}};Business_LogoImageEditor={init:function(){function e(){n&&n.destroy();$("#cropBox").Jcrop({setSelect:[0,0,200,150],onChange:f,onSelect:f},function(){n=this;t=n.getBounds();r=t[0];u=t[1]})}function f(n){if($("#x11").val(n.x),$("#y11").val(n.y),$("#w1").val(n.w),$("#h1").val(n.h),parseInt(n.w)>0){var t=100/n.w,i=100/n.h;$("#previewLogo").css({width:Math.round(t*r)+"px",height:Math.round(i*u)+"px",marginLeft:"-"+Math.round(t*n.x)+"px",marginTop:"-"+Math.round(i*n.y)+"px"})}}var i=$("#OrgBranchID").val(),n,t,r,u;$("#imageUploadSrc").bootstrapValidator({fields:{},submitHandler:function(n,t,r){$("#imageUploadSrc").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/UploadLogoImageFile?encrypbuscode="+i,beforeSubmit:function(){$("#divLogoUploadImgError").hide();$("#divImgloading").show();$(r).button("Uploading")},success:function(n){if(n.isUploaded){$(r).button("reset");$("#divLogoUploadImgError").hide();$("#divImgloading").hide();$("#divLogoImgcrop").show();$("#divLogoImgUpload").hide();$("#divLogoCropImgFooter").show();$("#modalLogoCropImgHeader").show();$("#modalLogoUploadImgHeader").hide();var t=n.src;$("#cropBox").attr("src",t);$("#cropBox").width(n.width).height(n.height);$("#previewLogo").attr("src",t);$("#imageurl").val($("#cropBox").attr("src"));$("#ContentType").val(n.ContentType);e()}else GR_Notification.showDangerFixed(n.message)},error:function(n,t,i){$(r).button("reset");GR_Notification.showDangerFixed(i)}})}});$("#imageCropImgSource").bootstrapValidator({fields:{},submitHandler:function(n,t,r){var u=$("#EncryptedOrgBranchIDLogo").val();$("#imageCropImgSource").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/CropLogoImage?encrypbuscode="+i,beforeSubmit:function(){$(r).button("loading")},success:function(n){if($(r).button("reset"),n.IsSuccess){var t=new Date;$("#img_companylogo")[0].src="/Account/GetCompanyLogo?EncryptedOrgBranchId= "+u+"&a="+t.getMilliseconds();$("#editLogoImageOption").show();$(document).closeModal()}else $("#DivEventSummary").html(n.EventSummary)},error:function(n,t,i){$(r).button("reset");GR_Notification.showDangerFixed(i)}})}});$(document).ready(function(){$("#divLogoUploadImgError").hide();$("#divLogoImgcrop").hide();$("#divLogoImgUpload").show();$("#divLogoCropImgFooter").hide();$("#modalLogoUploadImgHeader").show();$("#modalLogoCropImgHeader").hide();$("#divLogoUpdateImgStatus").hide()})},actions:function(){$("#file").off("change").on("change",function(){$("#divLogoUploadImgError").hide();$("#divImgloading").hide();var u=$(this).val(),n=u.split(".");if(n=n.reverse(),$.inArray(n[0].toLowerCase(),["gif","png","jpeg","jpg"])>-1){var r=this.files[0].size,t=r;for(i=0;t>900;)t/=1024,i++;r<=1048576?$("#btnlogoloading").click():($("#btnlogoloading").hide(),$("#divLogoUploadImgError").show(),GR_Notification.showDangerFixed("File size exceeds("+Math.round(t*100)/100+" "+["Bytes","KB","MB","GB"][i]+"). Please upload the files less than 1MB."))}else $("#btnlogoloading").hide(),$("#divLogoUploadImgError").show(),GR_Notification.showDangerFixed("Invalid File Format ! Please upload files only of '.jpeg','.jpg', '.png', '.gif' formats.")});$("#btnBackUpload").off("click").on("click",function(){$("#divLogoImgcrop").hide();$("#divLogoImgUpload").show();$("#modalLogoCropImgHeader").hide();$("#modalLogoUploadImgHeader").show();$("#divLogoUpdateImgStatus").hide()})},settingactions:function(){$(document).off("click",".UploadLogoimg").on("click",".UploadLogoimg",function(){var n=$(this).attr("data-url");$.post(n,function(n){n.IsSuccess==!0?($("#profileimageeditor").html(""),$("#profileimageeditor").html(n.Message),$("#profileimageeditor").modal("show")):GR_Notification.showDangerFixed(n.Message)})});$("#removeLogoImage").off("click").on("click",function(n){n.preventDefault();var r=new Date,t=$(this).attr("data-url"),i=$(this).attr("data-defaulturl");$(document).openDeleteModal({modalContent:"Are you sure want to remove the logo?"});$(".confirm-delete").off("click").on("click",function(){$.post(t,function(n){$(document).closeModal();n.IsSuccess==!0?($("#img_companylogo")[0]!=undefined&&($("#img_companylogo")[0].src=i),$("#newLogoImageOption").show(),$("#editLogoImageOption").hide(),GR_Notification.showSuccessFadeout(n.Message)):GR_Notification.showDangerFixed(n.Message)})})})}};Business_CorporateLogoImageEditor={init:function(){function f(){n&&n.destroy();$("#cropBox").Jcrop({setSelect:[0,0,200,150],onChange:u,onSelect:u},function(){n=this;t=n.getBounds();i=t[0];r=t[1]})}function u(n){if($("#x11").val(n.x),$("#y11").val(n.y),$("#w1").val(n.w),$("#h1").val(n.h),parseInt(n.w)>0){var t=100/n.w,u=100/n.h;$("#previewLogo").css({width:Math.round(t*i)+"px",height:Math.round(u*r)+"px",marginLeft:"-"+Math.round(t*n.x)+"px",marginTop:"-"+Math.round(u*n.y)+"px"})}}$("#CorporateimageUploadSrc").bootstrapValidator({fields:{},submitHandler:function(n,t,i){$("#CorporateimageUploadSrc").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/UploadLogoImageFile",beforeSubmit:function(){$("#divLogoUploadImgError").hide();$("#divImgloading").show();$(i).button("Uploading")},success:function(n){if(n.isUploaded){$(i).button("reset");$("#divLogoUploadImgError").hide();$("#divImgloading").hide();$("#divLogoImgcrop").show();$("#divLogoImgUpload").hide();$("#divLogoCropImgFooter").show();$("#modalLogoCropImgHeader").show();$("#modalLogoUploadImgHeader").hide();var t=n.src;$("#cropBox").attr("src",t);$("#cropBox").width(n.width).height(n.height);$("#previewLogo").attr("src",t);$("#imageurl").val($("#cropBox").attr("src"));$("#ContentType").val(n.ContentType);f()}else GR_Notification.showDangerFixed(n.message)},error:function(n,t,r){$(i).button("reset");GR_Notification.showDangerFixed(r)}})}});$("#CorporateimageCropImgSource").bootstrapValidator({fields:{},submitHandler:function(n,t,i){$("#CorporateimageCropImgSource").ajaxSubmit({type:"POST",dataType:"json",url:"/AccountSettings/CropCorporateLogoImage",beforeSubmit:function(){$(i).button("loading")},success:function(n){if($(i).button("reset"),n.IsSuccess){var r=new Date,t="/Account/GetCorporateLogo?a="+r.getMilliseconds();$("#img_companylogo")[0].src=t;$("#logoCorporateLayout")[0].src=t;$("#editLogoImageOption").show();$("#newLogoImageOption").hide();$(document).closeModal();$("#CorpoateSettingsEventMsg").html(n.EventSummary)}else $("#CorporateLogImgEvent").html(n.EventSummary)},error:function(n,t,r){$(i).button("reset");GR_Notification.showDangerFixed(r)}})}});$(document).ready(function(){$("#divLogoUploadImgError").hide();$("#divLogoImgcrop").hide();$("#divLogoImgUpload").show();$("#divLogoCropImgFooter").hide();$("#modalLogoUploadImgHeader").show();$("#modalLogoCropImgHeader").hide();$("#divLogoUpdateImgStatus").hide()});var n,t,i,r},actions:function(){$("#file").off("change").on("change",function(){$("#divLogoUploadImgError").hide();$("#divImgloading").hide();var u=$(this).val(),n=u.split(".");if(n=n.reverse(),$.inArray(n[0].toLowerCase(),["gif","png","jpeg","jpg"])>-1){var r=this.files[0].size,t=r;for(i=0;t>900;)t/=1024,i++;r<=1048576?$("#btnlogoloading").click():($("#btnlogoloading").hide(),$("#divLogoUploadImgError").show(),GR_Notification.showDangerFixed("File size exceeds("+Math.round(t*100)/100+" "+["Bytes","KB","MB","GB"][i]+"). Please upload the files less than 1MB."))}else $("#btnlogoloading").hide(),$("#divLogoUploadImgError").show(),GR_Notification.showDangerFixed("Invalid File Format ! Please upload files only of '.jpeg','.jpg', '.png', '.gif' formats.")});$("#btnBackUpload").off("click").on("click",function(){$("#divLogoImgcrop").hide();$("#divLogoImgUpload").show();$("#modalLogoCropImgHeader").hide();$("#modalLogoUploadImgHeader").show();$("#divLogoUpdateImgStatus").hide()})},settingactions:function(){$(document).off("click",".UploadLogoimg").on("click",".UploadLogoimg",function(){var n=$(this).attr("data-url");$.post(n,function(n){n.IsSuccess==!0?($("#profileimageeditor").html(""),$("#profileimageeditor").html(n.Result),$("#profileimageeditor").modal("show")):GR_Notification.showDangerFixed(n.Result)})});$("#removeLogoImage").off("click").on("click",function(n){n.preventDefault();var r=new Date,i=$(this).attr("data-url"),t=$(this).attr("data-defaulturl");$(document).openDeleteModal({modalContent:"Are you sure want to remove the logo?"});$(".confirm-delete").off("click").on("click",function(){$.post(i,function(n){$(document).closeModal();n.IsSuccess==!0?($("#img_companylogo")[0]!=undefined&&($("#img_companylogo")[0].src=t,$("#logoCorporateLayout")[0].src=t),$("#newLogoImageOption").show(),$("#editLogoImageOption").hide(),$("#CorpoateSettingsEventMsg").html(n.EventSummary)):$("#CorporateLogImgEvent").html(n.EventSummary)})})})}};gv2_CorporateSettings={init:function(){$(function(){var n=$("#FrmCorporateSettings");kendo.init(n);n.kendoValidator({rules:{PhoneorMobile:function(n){return n.is("[name=Phone]")||n.is("[name=MobilePhone]")?($("#Phone").val()==null||$("#Phone").val()=="")&&($("#MobilePhone").val()==null||$("#MobilePhone").val()=="")?!1:(gv2_CorporateSettings.phoneMobileValidation(),!0):!0},EmailValidation:function(n){var t,r,i;return n.is("[name=Email]")?(t=n.val(),t!=""?(r="/AccountSettings/ValidateEmail/",i=!0,$.ajax({url:r,mode:"abort",dataType:"json",type:n.attr("data-val-remote-type"),data:{emailVal:t},async:!1,success:function(n){n;i=n}}),i):!0):!0}},messages:{EmailValidation:"Enter valid email address"},validateOnBlur:!0})});$("#FrmCorporateSettings").submit(function(n){var t,i;n.preventDefault();t=$("#FrmCorporateSettings").data("kendoValidator");t.validate()&&gv2_CorporateSettings.phoneMobileValidation()?($("#SaveCorporateSettings").button("loading"),i=$("#FrmCorporateSettings").serialize(),$.post("/AccountSettings/UpdateCorporateSettings/",i,function(n){$("#SaveCorporateSettings").button("reset");$("#CorpoateSettingsEventMsg").html(n.EventSummary)})):gv2_CorporateSettings.CheckValidation()})},phoneMobileValidation:function(){var n=$("#Phone").val().replace(/\_/g,""),t=$("#MobilePhone").val().replace(/\_/g,""),i=!0;return n.length>0&&!(n.length>7&&n.length<=12)?($("#TelephoneNumber_span").html("Please specify a valid phone number").addClass("text-warning bg-warning warningProfilemsg"),i=!1):$("#TelephoneNumber_span").html("").removeClass("text-warning bg-warning warningProfilemsg"),t.length>0&&!(t.length>7&&t.length<=12)?($("#MobileNumber_span").html("Please specify a valid mobile number").addClass("text-warning bg-warning warningProfilemsg"),i=!1):$("#MobileNumber_span").html("").removeClass("text-warning bg-warning warningProfilemsg"),i},CheckValidation:function(){var i=$("#Address_Line1").val(),r=$("#Address_City").val(),u=$("#Address_Region").val(),f=$("#Address_Postcode").val().replace("/_/g",""),e=$("#Address_Country").val(),n,t;return i==""||i==null||i==undefined||r==""||r==null||r==undefined||u==""||u==null||u==undefined||f==""||f==null||f==undefined||e==""||e==null||e==undefined?($("#ProfcontactsdetailsTab").trigger("click"),$("input.k-invalid:first").focus(),!1):(n=$("#Phone").val().replace("/_/g",""),t=$("#MobilePhone").val().replace("/_/g",""),(n==""||n==null||n==undefined)&&(t==""||t==null||t==undefined))?($("#ProfcontactsdetailsTab").trigger("click"),$("input.k-invalid:first").focus(),!1):!1},actions:function(){gr2_KendoAddressAutoComplete.CityAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.RegionAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.PostCodeAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");gr2_KendoAddressAutoComplete.countryAutoComplete("Address_City","Address_Region","Address_Postcode","Address_CityID","Address_Country","Address_CountryID","Address_RegionID");$("#closecorporatesettings").off("click").on("click",function(){pageload("/Home/Welcome")})}};gv2_NotificationSettings={init:function(){},actions:function(){var n=$("#NotificationSettingForm").kendoValidator({rules:{},validateOnBlur:!0}).data("kendoValidator");$(document).off("click","#SaveNotificationSettings").on("click","#SaveNotificationSettings",function(){if(n.validate()){$("#SaveNotificationSettings").button("loading");var t=$("#NotificationSettingForm").serialize();$("#setupNotificationErrors").html("");$.post("/AccountSettings/SaveNotificationSettings/",t,function(n){$("#SaveNotificationSettings").button("reset");$("#setupNotificationErrors").html(n.EventSummary);n.IsSuccess&&pageload("/AccountSettings/NotificationSettings")})}else $("input.k-invalid:first").focus();return!1})}};gv2_EngagementSettings={init:function(){},actions:function(){var n=$("#EngagementSettingForm").kendoValidator({rules:{},validateOnBlur:!0}).data("kendoValidator");$("#EngagementSettingForm").off("click","#SaveEngagementSettings").on("click","#SaveEngagementSettings",function(){if(alert("Save"),n.validate()){$("#SaveEngagementSettings").button("loading");var t=$("#EngagementSettingForm").serialize();$("#setupEngagementErrors").html("");$.post("/AccountSettings/SaveEngagementSettings/",t,function(n){$("#SaveEngagementSettings").button("reset");$("#setupEngagementErrors").html(n.EventSummary);n.IsSuccess&&($(document).closeModal(),pageReload("/AccountSettings/MainBusinessSettings"))})}else $("input.k-invalid:first").focus();return!1})}};showreset=!1;gr2_CustomizePlan={init:function(){gr2_CustomizePlan.CalculateAmt();showreset=$("#PlanEdited").val().toLowerCase()=="true"?!0:!1;gr2_CustomizePlan.ShowHideResetMenu();$.ajax({url:"/Account/IsMoreServicesAvailable/",type:"POST",data:{key:$("#ServiceKeys").val()},success:function(n){n?$("#addmoreservices").removeClass("hide"):$("#addmoreservices").addClass("hide")},error:function(){}});$("#addmoreservices").off("click").on("click",function(){var n=$("#ServiceKeys").val(),t=$("#ReturnPageUrl").val();$(document).openModal({modalID:"myLargeModal",modalrequestType:"POST",modalBodyID:"myLarge-modal-body-content",modalUrl:"/Account/GetMoreServices",modalRequestData:{key:n,returnUrl:t,isRenewal:!0,tenantId:0},modalTitle:"Add More Services",modalTitleID:"myLarge-modal-label"})});$("#resetmoreservices").off("click").on("click",function(){$(document).openConfirmationModal({modalContent:"Are you sure to reset the changes?",submitContent:"Reset"});$("#confirm-modal").off("click").on("click",function(){$(document).closeModal();pageReload("/Subscription/CustomizePlan")})})},actions:function(){$(document).off("click","#btnSaveCustomizedPlan").on("click","#btnSaveCustomizedPlan",function(n){n.preventDefault();var t=$("#CustomizePlanSummaryGrid").data("kendoGrid").dataSource.data(),i=JSON.stringify(t);$("#CustomizePlanSummaryGridData").val(i);$("#btnSaveCustomizedPlan").button("loading");$.ajax({url:"/Subscription/CustomizePlanPost/",type:"POST",data:$("#customizeformPayment").serialize(),success:function(n){$("#btnSaveCustomizedPlan").button("reset");$("#customizeplansummary").html(n.EventSummary);showreset=!0;gr2_CustomizePlan.ShowHideResetMenu();n.IsSuccess&&$("#ReturnPageUrl").val()!=null&&$("#ReturnPageUrl").val()!=undefined&&pageload($("#ReturnPageUrl").val())},error:function(){GR_Notification.showDangerFixed("An error occurred, please try again later")}})})},fnCheckFieldHasValue:function(n){return n.val()==null||n.val()==""||n.val()==undefined||n.val()==NaN?!1:!0},CreditPriceChange:function(){var t=this.value(),r=1*t,u,i,n,f;this.element.closest("tr").find(".rowTotal").html(r.toFixed(2));this.element.closest("tr").find(".addItem").html(r.toFixed(2));u=this.element.closest("tr");i=$("#CustomizePlanSummaryGrid").data("kendoGrid").dataItem(u);i.Qty=1;i.UnitPrice=t;n=$("#ServiceKeys").val();f=n.split("|");$.each(f,function(i,r){r!=""&&r!=undefined&&(r.indexOf("CREDIT_")!=-1||r.indexOf("CREDITS_")!=-1)&&(n=n.replace(r,"CREDIT_"+t))});$("#ServiceKeys").val(n);gr2_CustomizePlan.CalculateAmt()},CalculateAmt:function(){var u=0,i=0,t,f,e,s,r,n,o;$(".addItem").each(function(){i=i+parseFloat($(this).html()!=null&&$(this).html()!=""?$(this).html():"0")});$("#SubTotalAmount").html(i.toFixed(2));t=parseFloat(i);$("#TotalAmount_span").html("$"+t.toFixed(2));$("#TotalAmount").val(t.toFixed(2));f=gr2_Payment.fnCheckFieldHasValue($("#GrandFatherDiscountPercent"))?parseFloat($("#GrandFatherDiscountPercent").val()).toFixed(2):0;f>0&&(e=0,s=$("#CustomizePlanSummaryGrid").data("kendoGrid").dataSource.data(),$.each(s,function(n,t){(t.ServiceCode=="SAVVY"||t.ServiceCode=="ONDEMAND"||t.ServiceCode=="GRUL")&&(e+=t.Qty*t.GetItemTotal)}),r=parseFloat(parseFloat(e)*parseFloat(f)/100),$("#GFDiscountAmount_span").html("$"+r.toFixed(2)),$("#GrandFatherDiscountAmount").val(r.toFixed(2)),t=parseFloat(t-r).toFixed(2));n=t>0?t:0;n>0&&n<50&&(u=.4,n=n+u,$(".surcharges_div").removeClass("hide"),$("#SurchargesAmount_span").html("$"+u.toFixed(2)));o=n-parseFloat(parseFloat(n)*100/110);$("#GrossAmount_span").html("");$("#GrossAmount_span").html("$"+o.toFixed(2));$("#Gst").val(o.toFixed(2));$("#NetTotal_span").html("$"+parseFloat(n).toFixed(2));$("#AmountDue").val(parseFloat(n).toFixed(2))},QtyChange:function(){var f=this.element.closest("tr").find(".upr").html(),t=this.value(),r=t*f,n,u;this.element.closest("tr").find(".rowTotal").html(r.toFixed(2));this.element.closest("tr").find(".addItem").html(r.toFixed(2));var i=this.element.closest("tr").find(".servUniCode").html(),e=this.element.closest("tr"),o=$("#CustomizePlanSummaryGrid").data("kendoGrid").dataItem(e);o.Qty=t;n=$("#ServiceKeys").val();u=n.split("|");$.each(u,function(r,u){if(u!=""&&u!=undefined)if(u.indexOf("UL_GRUL_")!=-1&&i.indexOf("UL_GRUL")!=-1)n=n.replace(u,"UL_GRUL_"+t);else if(u.indexOf("BL_GRBL_")!=-1&&i.indexOf("BL_GRBL")!=-1)n=n.replace(u,"BL_GRBL_"+t);else if(u.indexOf("AF_IAM")!=-1&&i.indexOf("AF_IAM")!=-1){var f=u,e=f.split("_");f=f.replace(e[2],t);n=n.replace(u,f)}});$("#ServiceKeys").val(n);gr2_CustomizePlan.CalculateAmt();showreset=!0;gr2_CustomizePlan.ShowHideResetMenu()},GridDataBound:function(n){for(var u=n.sender.tbody.children(),e=0,r=0;r<u.length;r++){var i=$(u[r]),t=n.sender.dataItem(i),f=t.Qty*t.UnitPrice;$(i).find(".rowTotal").html(f.toFixed(2));$(i).find(".addItem").html(f.toFixed(2));(t.ServiceCode.indexOf("CREDIT")!=-1||t.ServiceCode=="SAVVY"||t.ServiceCode=="ONDEMAND")&&$(i).find(".k-grid-Delete").hide();e++}(this.dataSource.totalPages()==1||this.dataSource.totalPages()==0)&&this.pager.element.hide();$(".templateCell").each(function(){eval($(this).children("script").last().html())});gr2_CustomizePlan.CalculateAmt()},onDelete:function(){return function(n){n.preventDefault();var i=$(n.target).closest("tr"),t=this.dataItem(i);$(document).openDeleteModal({modalContent:"Are you sure to delete the item?"});$(".confirm-delete").off("click").on("click",function(){var i=t.ServiceUniqueCode,r=$("#ServiceKeys").val().split("|"),n="";$.each(r,function(t,r){r==""||r.indexOf(i)!=-1||(n+=r+"|")});$("#ServiceKeys").val(n);$("#CustomizePlanSummaryGrid").data("kendoGrid").dataSource.remove(t);showreset=!0;gr2_CustomizePlan.ShowHideResetMenu();$(document).closeModal();$("#addmoreservices").html()!=undefined&&$("#addmoreservices").removeClass("hide")})}},ShowHideResetMenu:function(){showreset?$("#resetmoreservices").removeClass("hide"):$("#resetmoreservices").addClass("hide")}};gr2_PaymentCards={init:function(){},actions:function(){$(".btnCardRemove").off("click").on("click",function(){var t=$(this).attr("data-id"),i=$("#CardsCount").val(),n="Are you sure, want to delete?";i=="1"&&(n="At least one card is required for recurring payment. If you delete, recurring payment will not work. Are you sure, want to delete?");$(document).openConfirmationModal({modalContent:n,submitContent:"Delete"});$("#confirm-modal").off("click").on("click",function(){$("#confirm-modal").button("loading");$.post("/Subscription/DeletePaymentCard",{cardID:t},function(n){$("#confirm-modal").button("reset");n.IsSuccess&&($(document).closeModal(),pageReload("/Subscription/BillingSettings"));$("#DivEventSummary").html(n.EventSummary)})})});$(".btnCardMarkDefault").off("click").on("click",function(){var n=$(this),r=n.attr("id").replace("PaymentCard_",""),t=n.attr("data-cardstatus"),i=!1;t!="checked"&&(i=!0);$(document).openConfirmationModal({modalContent:"Are you sure, "+n.attr("data-msg"),submitContent:"Confirm"});$("#confirm-modal").off("click").on("click",function(){$("#confirm-modal").button("loading");$.post("/Subscription/PaymentCardChangeDefault",{cardID:r,changeDefaultTo:i},function(i){$("#confirm-modal").button("reset");i.IsSuccess&&($(".btnCardMarkDefault").each(function(){$(this).find(".defaultItems_icon").removeClass("fa-check-circle").addClass("fa-circle-thin");$(this).attr("data-cardstatus","unchecked");$(this).attr("data-msg","want to make as default?");$(this).attr("title","Click to make as default")}),t=="checked"?(n.find(".defaultItems_icon").removeClass("fa-check-circle").addClass("fa-circle-thin"),n.attr("data-cardstatus","unchecked"),n.attr("data-msg","want to make as default?"),n.attr("title","Click to make as default")):(n.find(".defaultItems_icon").removeClass("fa-circle-thin").addClass("fa-check-circle"),n.attr("data-cardstatus","checked"),n.attr("data-msg","want to remove default?"),n.attr("title","Click to remove default")));$(document).closeModal();$("#DivEventSummary").html(i.EventSummary)})})});$("#addpaymentcards").off("click").on("click",function(){gr2_PaymentCards.addpaymentcards()})},addpaymentcards:function(){$(document).openModal({modalID:"myMediumModal",modalrequestType:"POST",modalBodyID:"myMedium-modal-body-content",modalUrl:"/Subscription/AddPaymentCard",modalTitle:"Add Card",modalTitleID:"myMedium-modal-label"})}};gr2_PromotionCodes={init:function(){},actions:function(){$(document).off("click","#btnFilter").on("click","#btnFilter",function(){var n=$("#ToDate").val(),t=$("#FromDate").val(),i;n!=null&&n!=undefined&&n!=""&&n!=NaN&&t!=null&&t!=undefined&&t!=""&&t!=NaN&&(t=t.replace(/-/g,"/"),n=n.replace(/-/g,"/"),i=gr2_PromotionCodes.GetDateComparisionVal(t,n,$("#FromDate").attr("id")),i&&$("#promotion-grid").data("kendoGrid").dataSource.read())});$("#addpromotioncodes").off("click").on("click",function(){gr2_PromotionCodes.addpromotioncodes()})},getParameter:function(){return{fromDate:$("#FromDate").val(),toDate:$("#ToDate").val()}},GetDateComparisionVal:function(n,t,i){var r=!0,u;return $("#Msgbox").html("").removeClass("alert alert-danger"),u=compareDates(n,"dd/MM/yyyy",t,"dd/MM/yyyy"),u==-1?(r=!1,$("#Msgbox").html("Please enter a valid date Format(dd/MM/yyyy).").addClass("alert alert-danger"),$("#"+i).focus()):u==1?(r=!1,$("#Msgbox").html("Start date cannot be greater than end date").addClass("alert alert-danger"),$("#"+i).focus()):$("#Msgbox").html(""),r},addpromotioncodes:function(){$(document).openModal({modalID:"PromocodeModal",modalrequestType:"POST",modalBodyID:"Promocode-modal-body-content",modalUrl:"/Subscription/AddPromotionCode",modalTitle:"Create Promotional Code",modalTitleID:"Promocode-modal-label"})}};userLicarr=[];busLicarr=[];AllocateUserLicense={init:function(){userLicarr.length=0},actions:function(){$("#UserLicenseAllocationGridFilter").keyup(function(){var n=$("#UserLicenseAllocationGridFilter").val();grid=$("#UserLicenseAllocationGrid").data("kendoGrid");n?grid.dataSource.filter({logic:"or",filters:[{field:"Name",operator:"contains",value:n},{field:"UserName",operator:"contains",value:n}]}):grid.dataSource.filter({})});$(document).off("click",".allocatelicense").on("click",".allocatelicense",function(){var n=$(this).attr("data-id"),i=$(this).attr("data-title"),t=$.inArray(n,userLicarr);$(this).is(":checked")?t==-1&&userLicarr.push(n):t!=-1&&userLicarr.splice(t,1);AllocateUserLicense.UpdateLicenseCount(n,i)});$(document).off("click","#AllocateUserLicenseSubmit").on("click","#AllocateUserLicenseSubmit",function(){var t=$(this),n;userLicarr.length>0?($.each(userLicarr,function(t,i){n=n==null?i:n+","+i}),t.button("loading"),$.post("/ManageMyAccount/AllocateUserLicensePost/",{userIDs:n},function(n){$("#DivEventSummary").html(n.EventSummary);var i=parseInt($("#UserLicenseCount").val())-userLicarr.length;n.IsSuccess&&AllocateUserLicense.RefreshList();n.IsSuccess&&i<=0?$(document).closeModal():n.IsSuccess&&($("#UserLicenseCount").val(i),RemoveLicenseGridItem("UserLicenseAllocationGrid",userLicarr),userLicarr.length=0);t.button("reset")})):GR_Notification.showDangerFixed("Select any one user for license allocation")})},UpdateLicenseCount:function(n,t){var i=parseInt($("#UserLicenseCount").val()),r=userLicarr.length,u;i<r?(GR_Notification.showWarningFixed("No license availabe to allocate for "+t+". Please add new license or unallocate license from any other user"),u=$.inArray(n,userLicarr),userLicarr.splice(u,1),$("#AllocateLicense"+n).prop("checked",!1)):$("#UserLicenseCountCtrl").html(i-r);SelectLicenseGridItem("UserLicenseAllocationGrid",userLicarr,n)},onDataBound:function(){userLicarr.length=0},RefreshList:function(){$.ajax({type:"POST",url:"/ManageMyAccount/GetUserLicenseDetails",dataType:"json",success:function(n){var t=$("#UserLicensesGrid").getKendoGrid();t.dataSource.data(n)}})}};AllocateBusinessLicense={init:function(){busLicarr.length=0},actions:function(){$("#BusinessLicenseAllocationGridFilter").keyup(function(){var n=$("#BusinessLicenseAllocationGridFilter").val();grid=$("#BusinessLicenseAllocationGrid").data("kendoGrid");n?grid.dataSource.filter({logic:"or",filters:[{field:"Name",operator:"contains",value:n},{field:"ABN",operator:"contains",value:n},{field:"FormattedABN",operator:"contains",value:n}]}):grid.dataSource.filter({})});$(document).off("click",".allocatebuslicense").on("click",".allocatebuslicense",function(){var n=$(this).attr("data-id"),i=$(this).attr("data-title"),t=$.inArray(n,busLicarr);$(this).is(":checked")?t==-1&&busLicarr.push(n):t!=-1&&busLicarr.splice(t,1);AllocateBusinessLicense.UpdateLicenseCount(n,i)});$(document).off("click","#AllocateBusinessLicenseSubmit").on("click","#AllocateBusinessLicenseSubmit",function(){var t=$(this),n;busLicarr.length>0?($.each(busLicarr,function(t,i){n=n==null?i:n+","+i}),t.button("loading"),$.post("/ManageMyAccount/AllocateBusinessLicensePost/",{busIDs:n},function(n){$("#DivEventSummary").html(n.EventSummary);var i=parseInt($("#BusinessLicenseCount").val())-busLicarr.length;n.IsSuccess&&AllocateBusinessLicense.RefreshList();n.IsSuccess&&i<=0?$(document).closeModal():n.IsSuccess&&($("#BusinessLicenseCount").val(i),RemoveLicenseGridItem("BusinessLicenseAllocationGrid",busLicarr),busLicarr.length=0);t.button("reset")})):GR_Notification.showDangerFixed("Select any one business for license allocation")})},UpdateLicenseCount:function(n,t){var i=parseInt($("#BusinessLicenseCount").val()),r=busLicarr.length,u;i<r?(GR_Notification.showWarningFixed("No license availabe to allocate for "+t+". Please add new license or unallocate license from any other business"),u=$.inArray(n,busLicarr),busLicarr.splice(u,1),$("#AllocateLicense"+n).prop("checked",!1)):$("#BusinessLicenseCountCtrl").html(i-r);SelectLicenseGridItem("BusinessLicenseAllocationGrid",busLicarr,n)},onDataBound:function(){busLicarr.length=0},RefreshList:function(){$.ajax({type:"POST",url:"/ManageMyAccount/GetBusinessLicenseDetails",dataType:"json",success:function(n){var t=$("#BusinessLicenseGrid").getKendoGrid();t.dataSource.data(n)}})}};gr2_MyVouchers={init:function(){},actions:function(){$(document).off("click",".resend").on("click",".resend",function(){var n=$(this).attr("id");$(document).openConfirmationModal({modalContent:"Are you sure want to resend the referral link?",submitContent:"Confirm"});$("#confirm-modal").off("click").on("click",function(){$(this).html("Sending...");$("#"+n).html("Sending...");$("#"+n).attr("disabled","disabled");$.getJSON("/AccountSettings/ResendReferral/",{referralId:n},function(t){$("#"+n).removeAttr("disabled");$("#"+n).html("Resend");$("#DivEventSummary").html(t.EventSummary);$(document).closeModal()})})});$(document).off("click","#btnFilter").on("click","#btnFilter",function(){var n=$("#ToDate").val(),t=$("#FromDate").val(),i;n!=null&&n!=undefined&&n!=""&&n!=NaN&&t!=null&&t!=undefined&&t!=""&&t!=NaN&&(t=t.replace(/-/g,"/"),n=n.replace(/-/g,"/"),i=gr2_MyVouchers.GetDateComparisionVal(t,n,$("#FromDate").attr("id")),i&&$("#vouchers-grid").data("kendoGrid").dataSource.read())})},getParameter:function(){return{fromDate:$("#FromDate").val(),toDate:$("#ToDate").val()}},GetDateComparisionVal:function(n,t,i){var r=!0,u;return $("#Msgbox").html("").removeClass("alert alert-danger"),u=compareDates(n,"dd/MM/yyyy",t,"dd/MM/yyyy"),u==-1?(r=!1,$("#Msgbox").html("Please enter a valid date Format(dd/MM/yyyy).").addClass("alert alert-danger"),$("#"+i).focus()):u==1?(r=!1,$("#Msgbox").html("Start date cannot be greater than end date").addClass("alert alert-danger"),$("#"+i).focus()):$("#Msgbox").html(""),r}}