function AutoLogin(){function a(){f()}function f(){i=!1,r={}}function l(){i=!0,s=setTimeout(S,o),$("#login").html(funcObj.contentCon.getContent("autologin",{})),$("#login").removeClass("disp_off").addClass("disp_on"),c(),h(),isA4V?funcObj.devCon.addTestingDevice():funcObj.appcomm.appSend({method:"getDeviceList",params:null,id:null})}function c(){$("#login").on(transEndEvent,function(e){(useBoseTransitionEnd||e.originalEvent.propertyName=="opacity")&&$("#login").hasClass("ani_opacity_0")&&($("#login").removeClass("animate"),d())}).on(vdown,".account",function(e){(touchDevice||e.which==1)&&!$(this).hasClass("but_off")&&($($(this)).addClass("tLink_sel"),funcObj.UIMain.setCurBut(this))}).on(vup,".account",function(e){$(funcObj.UIMain.getCurBut()).removeClass("tLink_sel");if(this==funcObj["UIMain"].getCurBut()&&!outside&&!moved){$(e.target).data({origin:"login",dest:"main_play",callback:"login"});var t=$(this).data("aid").toString();w(t)}else(outside||moved)&&$(e.target).data({origin:"login",type:"scroll",collect:dc.trackScrolls})}).on(vdown,".tLink",function(e){(touchDevice||e.which==1)&&!$(this).hasClass("but_off")&&($($(this)).addClass("tLink_sel"),funcObj.UIMain.setCurBut(this))}).on(vup,".tLink",function(e){$(funcObj.UIMain.getCurBut()).removeClass("tLink_sel"),this==funcObj["UIMain"].getCurBut()&&!outside&&!moved&&$(this).hasClass("tLink_moreOptions")&&(funcObj.appcomm.appSend({method:"reloadWebview",params:{url:"setup/index.html"},id:null}),$(e.target).data({origin:"login",dest:"setup"}))})}function h(){touchDevice&&(u==undefined||u==null?(u=new IScroll("#accounts_scroll",{scrollbars:"custom",scrollY:!0,scrollX:!1,freeScroll:!1,preventDefault:!0,useTransition:!0}),u.on("scrollStart",function(e){scrolling=!0})):setTimeout(function(){u.refresh()},0))}function p(e){e?$("#login").addClass("animate ani_opacity_0").removeClass("ani_opacity_1"):($("#login").addClass("disp_off").removeClass("animate disp_on ani_opacity_1"),d())}function d(){v(),touchDevice&&u!==undefined&&u!==null&&(u.destroy(),u=null),$("#login").remove()}function v(){$("#login").off()}function m(e,t){if(r.hasOwnProperty(e))return;var n=!1;t.margeFullURL.replace(/\/+$/,"")==funcObj["margeComm"].getMargeURL().replace(/\/+$/,"")&&(n=!0);if(isA4V&&t.margeFullURL)funcObj.margeComm.setMargeURL(t.margeFullURL.replace(/\/+$/,"")+"/");else if(!n){showDebug==2&&console.log("marge server mismatch",t);return}r[e]={uID:t.uID,scmToken:null,email:null,margeToken:null},$.ajax({url:"http://"+t.ip+":8090/requestToken",cache:!0,success:function(t){var n=$(t).find("bearertoken").attr("value");r[e].scmToken=n,g(e)},error:function(){r[e]=null,delete r[e]}})}function g(e){var t={Authorization:r[e].scmToken};funcObj.margeComm.sendMsg("get","/streaming/account/"+e+"/emailaddress",null,function(t){y(e,t)},!0,t)}function y(e,t){var n=null;t!=null?(n=$(t).find("email").text(),r[e].email=n,showDebug==2&&console.log(r),b(e)):showDebug==2&&console.log("Marge error on email retrieval")}function b(e){clearTimeout(s);var t=funcObj.contentCon.getContent("autologinrow",{repl:{AID:e,EMAIL:r[e].email}});$("#accounts").append(t),h(),funcObj.login.sendHTMLReady(),isA4V&&w(e)}function w(e){var t={Authorization:r[e].scmToken};funcObj.margeComm.sendMsg("get","/streaming/device/"+r[e].uID+"/paired_token",null,function(t,n){E(e,t,n)},!0,t)}function E(e,t,n){var s=e,o=n.getResponseHeader("Authorization");r[e].margeToken=o,i=!1,funcObj.deviceQueue.clearQueue(),funcObj.margeComm.setCreds(s,o),funcObj.login.setup(),p(!0)}function S(){i=!1,clearTimeout(s),isA4V?($("#login").removeClass("disp_on").addClass("disp_off"),funcObj.login.sendHTMLReady(),funcObj.play.showPlayMessage("needAccountA4V")):funcObj.appcomm.appSend({method:"reloadWebview",params:{url:"setup/index.html"},id:null})}function x(){return i}function T(e){i=e}var e,t,n,r,i,s,o=3e3,u;this.init=f,this.setup=l,this.showAccount=b,this.addDevice=m,this.getModeAutoLogin=x,this.setModeAutoLogin=T,this.parseMargeEmail=y,this.cleanUp=d,a()};