var ExecuteWithLogin={};$.extend(ExecuteWithLogin,{isUsing:!1,role:"",type:"",url:"",arguments:null,ajaxArguments:null,windowType:null,methodType:"GET",Waiting:!1,Init:function(n,t,i,r,u,f,e){if(typeof Authorize!="object")return alert("not included `Authorize`"),!1;if(this.type=this.type!=null?n.toLowerCase():"",this.role=u,this.url=t,this.arguments=i,this.ajaxArguments=r,this.methodType=e,this.arguments!=null&&typeof CustomHighlightingSettings!="undefined"){var o=$('input:hidden[id$="customHighlight"], input:hidden[id$="CustomHighlight"]');o.length>0&&(this.arguments.customHighlight=o.val())}return(this.windowType=f&&f!="null"&&f!="undefined"?f:PopupFormat.ImageViewer,this.methodType!="GET"&&this.methodType!="POST"&&(this.methodType="GET"),this.type==""||this.role==""||this.url=="")?!1:!0},Clear:function(){this.isUsing=!1;this.Waiting=!1},UnauthorizedForRole:function(){MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForRole")})},UnauthorizedForPack:function(){MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPack")})},UnauthorizedForFreeFeatures:function(){MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForFreeFeatures"),bottom:"UnauthorizedForPack_BottomDesc"})},UnauthorizedForPaidFeatures:function(){MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPaidFeatures"),bottom:"UnauthorizedForPaidFeatures_BottomDesc"})},Unauthorized:function(){MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPack")})},UnauthorizedShowFamilyTreeForPack:function(n,t,i){typeof i.url!=undefined?MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPack")}):MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPack")})},UnauthorizedShowFamilyTreeForPaidFeatures:function(n,t,i){typeof i.url!=undefined?MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPaidFeatures"),bottom:"UnauthorizedForPaidFeatures_BottomDesc"}):MessageBox.Show({message:Resources.Get("Global_Error","UnauthorizedForPaidFeatures"),bottom:"UnauthorizedForPaidFeatures_BottomDesc"})},ShowWithPack:function(n,t,i,r,u,f,e){this.Init(n,t,i,r,u,f,e)!=!1&&(this.isUsing=!0,this.Waiting=this.type!="newwindow"&&(typeof this.arguments.isNoRefresh=="undefined"||Common.StringToBool(this.arguments.isNoRefresh)!=!0)&&t.indexOf("/FullText/FullText")>=0,typeof FulltextHelper!="undefined"&&(FulltextHelper.Scrolling=!1),Authorize.CheckPack(u,function(n){return n<=10?!1:(n==100&&(ExecuteWithLogin.type=="newwindow"&&ExecuteWithLogin.Waiting==!1||typeof ExecuteWithLogin.arguments.isNoRefresh=="undefined"||typeof ExecuteWithLogin.arguments.isNoRefresh!="undefined"&&ExecuteWithLogin.arguments.isNoRefresh==!0)&&(ExecuteWithLogin.url.indexOf("/FullText/FullText")>=0&&window.navigator.userAgent.indexOf("Chrome")>0?setTimeout(function(){MessageBox.Show({message:Resources.Get("Global_JavaScript","IsOpenNewWindow"),type:"notice",buttons:[{text:Resources.Get("Global_Common","OK"),"class":"gray_btn btn mR5",click:function(){ExecuteWithLogin.Show();MessageBox.Hide()}},{text:Resources.Get("Global_Common","Cancel"),"class":"lightgray_btn btn",click:function(){MessageBox.Hide()}}]})},1e3):ExecuteWithLogin.Show()),!0)}))},ShowWithLogin:function(n,t,i,r,u,f,e){this.Init(n,t,i,r,u,f,e)!=!1&&(this.isUsing=!0,this.Waiting=this.type!="newwindow"&&(typeof this.arguments.isNoRefresh=="undefined"||Common.StringToBool(this.arguments.isNoRefresh)!=!0)&&t.indexOf("/FullText/FullText")>=0,typeof FulltextHelper!="undefined"&&(FulltextHelper.Scrolling=!1),Authorize.CheckRole(u,function(n){return n<0?!1:n==0?(ExecuteWithLogin.Clear(),ExecuteWithLogin.UnauthorizedForPaidFeatures(),!0):n>=1?((ExecuteWithLogin.type=="newwindow"&&ExecuteWithLogin.Waiting==!1||typeof ExecuteWithLogin.arguments.isNoRefresh=="undefined"||typeof ExecuteWithLogin.arguments.isNoRefresh!="undefined"&&ExecuteWithLogin.arguments.isNoRefresh==!0)&&(ExecuteWithLogin.url.indexOf("/FullText/FullText")>=0&&window.navigator.userAgent.indexOf("Chrome")>0?setTimeout(function(){MessageBox.Show({message:Resources.Get("Global_JavaScript","IsOpenNewWindow"),type:"notice",buttons:[{text:Resources.Get("Global_Common","OK"),"class":"gray_btn btn mR5",click:function(){ExecuteWithLogin.Show();MessageBox.Hide()}},{text:Resources.Get("Global_Common","Cancel"),"class":"lightgray_btn btn",click:function(){MessageBox.Hide()}}]})},1e3):ExecuteWithLogin.Show()),!0):!1}))},Execute:function(n,t,i,r,u,f,e){this.Init(n,t,i,r,u,f,e)!=!1&&this.Show()},Show:function(){this.isUsing=!1;this.Start();this.Waiting=!1},Start:function(){this.type=="newwindow"?this.ShowNewWIndow():this.type=="ajax"?this.ChangeContents():this.type=="off"||alert("invalid type")},ShowNewWIndow:function(){if(typeof PopupWindow=="object"){var n=this.GetNewWindowName();this.windowType.name=n;PopupWindow.WithForm(this.url,this.arguments,this.windowType,this.methodType)}},GetNewWindowName:function(){var n="WisNewWindow"+(new Date).getTime();return this.arguments!=null&&this.arguments.target!=null&&this.arguments.target!=""&&(n=this.arguments.target,delete this.arguments.target),n},ChangeContents:function(){var i=document.body,n;if(this.arguments&&typeof this.arguments.patn!=undefined&&typeof this.arguments.normalizeAssignee=="undefined"&&$('input[id$="CurrentEncryptedPatn"][value="'+this.arguments.patn+'"]').length>0){var t=$('input[id$="CurrentEncryptedPatn"][value="'+this.arguments.patn+'"]'),r=t.closest("tr").children().index(t.closest("td")),u=this.ajaxArguments.UpdateTargetId;t.closest("table").find("> tbody > tr").each(function(){var f=$(this),t=f.children("td"),n;t.length>1&&(n=$("#"+u,t.get(r)),n.length>0&&(i=n.closest("td")))})}n=$('[id$="'+this.ajaxArguments.UpdateTargetId+'"]',i);n.length>0?$.trim(n.html())==""?$.ajax({url:this.url,type:this.ajaxArguments.HttpMethod,data:this.arguments,_arguments:this.arguments,beforeSend:function(){typeof ExecuteWithLogin.ajaxArguments.beforeSend=="function"&&ExecuteWithLogin.ajaxArguments.beforeSend(this._arguments)},success:function(t,i){i=="success"&&(n.html(t),typeof ExecuteWithLogin.ajaxArguments.success=="function"&&ExecuteWithLogin.ajaxArguments.success(this._arguments))},complete:function(){typeof ExecuteWithLogin.ajaxArguments.complete=="function"&&ExecuteWithLogin.ajaxArguments.complete(this._arguments)},error:function(n){typeof ExecuteWithLogin.ajaxArguments.error=="function"&&ExecuteWithLogin.ajaxArguments.error(n)}}):typeof ExecuteWithLogin.ajaxArguments.success=="function"&&ExecuteWithLogin.ajaxArguments.success(this.arguments):alert("invalid target")}})