$(document).ready(function(){$(document).on("click","[data-common-action]",function(n){n.preventDefault();var t=$(this).data("common-action");switch(t){case"login":GameWebCommon.Login(this);break;case"logout":GameWebCommon.Logout(this);break;case"helpdesk":GameWebCommon.HelpDesk(this);break;case"share-sns":GameWebCommon.ShareSns(this);break;case"copy-url":GameWebCommon.CopyUrl(this);break;case"open-cash":GameWebCommon.OpenCashWindow(this);break;case"open-coupon":GameWebCommon.OpenCouponWindow(this);break;case"off-today":GameWebCommon.OffToday(this);break;case"apply-necojang":GameWebCommon.ApplyNecojang(this)}});$.ajaxSetup({cache:!1})});var GameWebCommon=new function(){this.Alert=function(n,t){try{t?$.alertable.alert(n,{html:!0}).always(t):$.alertable.alert(n,{html:!0})}catch(i){alert(n)}};this.Confirm=function(n){try{$.alertable.confirm(n.msg,{html:!0,cancelButton:n.cancelButton,okButton:n.okButton}).then(n.yes,n.no)}catch(t){if(confirm(n.msg))try{n.yes()}catch(i){}else try{n.no()}catch(i){}}};this.GameStart=function(){$.post("/Common/GameStartControl",{},function(n,t){t=="success"?new Function(n)():GameWebCommon.Alert("에러가 발생하였습니다")})};this.GetCookie=function(n){for(var r=document.cookie.length,i=document.cookie.split("; "),t=0;t<i.length;t++)if(cookieName=i[t].indexOf("=")!=-1?i[t].substring(0,i[t].indexOf("=")):i[t],cookieName==n)return cookieVal=i[t].indexOf("=")!=-1?i[t].substr(i[t].indexOf("=")+1):"";return""};this.GetCookieValue=function(n,t){if(n.split("&").length>0)for(var i=0;i<n.split("&").length;i++)if(n.split("&")[i].split("=")[0]==t)return n.split("&")[i].split("=")[1];return""};this.GetNXCookie=function(n){for(var r=n+"=",t=0,i;t<=document.cookie.length;){if(i=t+r.length,document.cookie.substring(t,i)==r)return(endOfCookie=document.cookie.indexOf(";",i))==-1&&(endOfCookie=document.cookie.length),unescape(document.cookie.substring(i,endOfCookie));if(t=document.cookie.indexOf(" ",t)+1,t==0)break}return""};this.SetNXCookie=function(n,t,i){var r=new Date;r.setDate(r.getDate()+i);document.cookie=n+"="+escape(t)+"; path=/; expires="+r.toGMTString()+";domain=nexon.com;"};this.GetNecoCookie=function(n){for(var r=n+"=",t=0,i;t<=document.cookie.length;){if(i=t+r.length,document.cookie.substring(t,i)==r)return(endOfCookie=document.cookie.indexOf(";",i))==-1&&(endOfCookie=document.cookie.length),unescape(document.cookie.substring(i,endOfCookie));if(t=document.cookie.indexOf(" ",t)+1,t==0)break}return""};this.SetNecoCookie=function(n,t,i){var r=new Date;r.setDate(r.getDate()+i);document.cookie=n+"="+escape(t)+"; path=/; expires="+r.toGMTString()+"; domain=necoje.nexon.com"};this.WindowOpen=function(){var i,n,t,r,u,f;i=arguments[0];n=arguments[1];t=arguments[2];f=arguments.length>3?arguments[3]:"no";r=arguments.length>4?arguments[4]:screen.width/2-n/2;u=arguments.length>5?arguments[5]:screen.height/2-t/2;window.open(i,"pbml_win","left="+r+",top="+u+",width="+n+",height="+t+",scrollbars="+f+",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no")};this.IsLogin=function(){return NgbMember.IsLogin()};this.GetOid=function(){return this.IsLogin()?this.GetCookieValue(this.GetNXCookie("NXCH"),"OID"):0};this.Login=function(){NXMember.GoLogin()};this.Logout=function(){NgbLogin.Logout()};this.CheckLength=function(n){var r=$(n).data("counter-selector"),t=$(n).data("counter-max"),i=$(n).val().length,u=$(n).val();i>t&&(i=t,$(n).val(u.substr(0,t)));$(r).html(i)};this.HelpDesk=function(){return window.open("/common/helpdesk","pop_helpdesk","width=1024,height=770,scrollbars=yes"),!1};this.CopyUrl=function(n){var t,i=$(n).data("copy-url");NgbBrowser.msie()?(t=window.clipboardData.setData("Text",i),t?GameWebCommon.Alert("주소가 복사되었습니다."):GameWebCommon.Alert("주소 복사가 취소되었습니다.\n복사를 원하시면 클립보드 액세스를 허용해주세요.")):window.prompt("URL로 공유 시 전체 선택하여 복사하세요.",i)};this.ThousandCommas=function(n){return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")};this.OpenCashWindow=function(){};this.OpenCouponWindow=function(){};this.ShareSns=function(n){var e=$(n).data("share-service"),t=$(n).data("share-title"),r=$(n).data("share-url");t=t.replace("<","&lt;");t=t.replace(">","&gt;");switch(e){case"facebook":var u=encodeURIComponent(t),i=encodeURIComponent(r),f="http://www.facebook.com/sharer.php?u="+i+"&t="+u;i.length!=0&&GameWebCommon.WindowOpen(f,1e3,600,"yes");break;case"me2day":var u=encodeURIComponent(t),i=encodeURIComponent(r),f='http://me2day.net/posts/new?new_post[body]="'+u+'":'+i;i.length!=9&&GameWebCommon.WindowOpen(f,1e3,600,"yes");break;case"naver":var u=encodeURI(t),i=encodeURI(encodeURIComponent(r)),f="http://share.naver.com/web/shareView.nhn?url="+i+"&title="+u;i.length!=0&&GameWebCommon.WindowOpen(f,1e3,600,"yes");break;case"twitter":var u=encodeURIComponent(t),i=encodeURIComponent(r),f="https://twitter.com/intent/tweet?text="+u+"&url="+i;i.length!=0&&GameWebCommon.WindowOpen(f,1e3,600,"yes");break;case"kakaostory":var u=encodeURIComponent(t),i=encodeURIComponent(r),f="https://story.kakao.com/share?url="+r+"&text="+u;i.length!=0&&GameWebCommon.WindowOpen(f,500,400,"yes")}};this.OffToday=function(n){var t=$(n).data("intro-date");$.ajax({type:"POST",url:"/intro/hideintro?dt="+t,cache:!1,dataType:"json",success:function(){document.location.href="/main/index"},error:function(){}})};this.setHomeAgree=function(){confirm("네코제 커뮤니티는 넥슨 서비스 이용약관 및 개인정보처리방침에 따라 운영됩니다.\n이를 포함한 커뮤니티 운영정책에 동의하시겠습니까?")&&$.ajax({url:"/Account/SetAgree",dataType:"json",data:{},async:!1,type:"POST",success:function(n){n.resultCode==0?GameWebCommon.Alert(n.message,GameWebCommon.closeAgreeLayer):n.resultCode==-1?GameWebCommon.Alert(n.message,GameWebCommon.Login):GameWebCommon.Alert(n.message)},error:function(){GameWebCommon.Alert("에러가 발생하였습니다..")}})};this.showAgreeLayer=function(){$("#homeAgreeLayer").show();$(".overlay").show()};this.closeAgreeLayer=function(){$("#homeAgreeLayer").hide();$(".overlay").hide()};this.ApplyNecojang=function(){if(!GameWebCommon.IsLogin()){GameWebCommon.Confirm({msg:"로그인 후 신청 가능합니다.\n로그인 하시겠습니까?",yes:function(){GameWebCommon.Login()},no:function(){}});return}window.open("/necojang/regpopup","regpopup","width=800,height=750,scrollbars=yes")}};String.prototype.replaceAll=function(n,t){return this.split(n).join(t)};jQuery&&function(n){"use strict";function f(f,s,h){var c=n.Deferred();u=document.activeElement;u.blur();n(t).add(i).remove();h=n.extend({},n.alertable.defaults,h);t=n(h.modal).hide();i=n(h.overlay).hide();o=n(h.okButton);r=n(h.cancelButton);h.html?t.find(".alertable-message").html(s.replace("\n","<br />")):t.find(".alertable-message").text(s.replace("\n","<br />"));f==="prompt"?t.find(".alertable-prompt").html(h.prompt):t.find(".alertable-prompt").remove();n(t).find(".alertable-buttons").append(f==="alert"?"":r).append(o);n(h.container).append(i).append(t);h.show.call({modal:t,overlay:i});f==="prompt"?n(t).find(".alertable-prompt :input:first").focus():n(t).find(':input[type="submit"]').focus();n(t).on("submit.alertable",function(i){var r,u,o=[];if(i.preventDefault(),f==="prompt")for(u=n(t).serializeArray(),r=0;r<u.length;r++)o[u[r].name]=u[r].value;else o=null;e(h);c.resolve(o)});r.on("click.alertable",function(){e(h);c.reject()});n(document).on("keydown.alertable",function(n){n.keyCode===27&&(n.preventDefault(),e(h),c.reject())});n(document).on("focus.alertable","*",function(i){n(i.target).parents().is(".alertable")||(i.stopPropagation(),i.target.blur(),n(t).find(":input:first").focus())});return c.promise()}function e(f){f.hide.call({modal:t,overlay:i});n(document).off(".alertable");t.off(".alertable");r.off(".alertable");u.focus()}var t,i,o,r,u;n.alertable={alert:function(n,t){return f("alert",n,t)},confirm:function(n,t){return f("confirm",n,t)},prompt:function(n,t){return f("prompt",n,t)},defaults:{container:"body",html:!1,cancelButton:'<button class="alertable-cancel" type="button">Cancel<\/button>',okButton:'<button class="alertable-ok" type="submit">OK<\/button>',overlay:'<div class="alertable-overlay"><\/div>',prompt:'<input class="alertable-input" type="text" name="value">',modal:'<form class="alertable"><div class="alertable-message"><\/div><div class="alertable-prompt"><\/div><div class="alertable-buttons"><\/div><\/form>',hide:function(){n(this.modal).add(this.overlay).fadeOut(100)},show:function(){n(this.modal).add(this.overlay).fadeIn(100)}}}}(jQuery)