var identity=(typeof identity=="undefined")?{}:identity;identity.status=function(){var B={},P,H,C,I,L={},E=false,K,A={},J=false;idProperties.panelAppearTimeout=8000;idProperties.panelActionTimeout=8000;idProperties.css_id_status="id-status";idProperties.css_element_status=["#",idProperties.css_id_status].join("");idProperties.css_element_status_loginLink="a#idLogin";idProperties.url_status=["/users/widget/status"].join("");var M=function(){if(L.login){I(L.login)}};var G=function(){if(E){identity.app.parseStatusLinks()}else{M();var Q;if(Q=H(idProperties.css_element_status_loginLink)){C(Q,"mousedown",function(R){identity.status.mousepressed=true});L.login=C(Q,"click",function(R){if(identity.status.mousepressed){R.preventDefault();M();if(!identity.status.hasChanged()){O("login",R)}}})}}};var O=function(S,Q){if(E){D(S,Q)}else{identity.status.showSpinner();if(typeof Q!="undefined"&&idProperties.env!="sandbox"&&idProperties.env!="dev"){K=setTimeout(function(){try{window.location=Q.source.href}catch(T){}},idProperties.panelAppearTimeout)}var R=P.dom.create('<div class="id-panel-css-load-test"></div>');H("body").append(R);if(typeof identity.app!="undefined"&&"init" in identity.app&&typeof identity.cta!="undefined"&&"init" in identity.cta&&typeof identity.util!="undefined"&&"init" in identity.util&&typeof idPanelObj!="undefined"&&"init" in idPanelObj&&typeof idInfoPanelObj!="undefined"&&"init" in idInfoPanelObj&&typeof identity.forms!="undefined"&&"init" in identity.forms&&R.width()==50){if(idProperties.env!="sandbox"&&idProperties.env!="dev"){clearTimeout(K)}F();identity.status.hideSpinner();identity.app.init(P);idPanelObj.init(P);idInfoPanelObj.init(P);identity.forms.init(P);E=true;D(S,Q)}}};var D=function(Q,R){switch(Q){case"login":identity.app.showPanel("login",R);break;default:break}};var F=function(){var Q;for(Q in L){P.events.removeListener(L[Q])}};var N=function(){identity.addLoginHandler=function(Q){return C(identity,"login",Q)};identity.removeLoginHandler=function(Q){I(Q)};identity.showLoginPanel=function(){O("login",null)}};B.mousepressed=false;B.refresh=function(){identity.status.showSpinner();P.net.get(idProperties.url_status,{onLoad:function(Q){identity.status.hideSpinner();H(idProperties.css_element_status).after(P.dom.create(Q.text())).remove();G();identity.cta.parseLinks();A=identity.status.getUserStatus()}})};B.showSpinner=function(){H(idProperties.css_element_status).addClass("id-status-working")};B.hideSpinner=function(){H(idProperties.css_element_status).removeClass("id-status-working")};B.getUserStatus=function(){var Q,R={},S=identity.util.getCookie("IDENTITY");Q=S?S.split("%7C"):null;if(S!=Q&&Q.length==4){R.username=S[1];R.userid=S[0];R.status="loggedin"}else{R.username="";R.status="loggedout";R.userid=0}return R};B.hasChanged=function(S){var U,Q=(typeof S!="undefined"&&S.suppressActions)?true:false,R=identity.status.getUserStatus();U=((R.status!=A.status)||(R.userid!=A.userid))?true:false;if(U&&!Q){var T;if(R.status=="loggedin"){T=new P.events.Event();P.events.fire(identity,"login",T)}}A=R;return U};B.loadAndShowPanel=function(Q,R){if(typeof R!="string"){R=false}O(R,Q)};B.enableJavaScript=function(){if(J){return }identity.util.init(P);identity.cta.init(P);G();identity.cta.parseLinks();N();identity.addLoginHandler(function(Q){identity.status.refresh()});J=true};B.init=function(Q){P=Q;H=P.dom.get;C=P.events.addListener;I=P.events.removeListener;A=identity.status.getUserStatus();if(!P.isSupported||navigator.userAgent.match(/^.*mobile.*$/i)||navigator.userAgent.match(/^.*blackberry.*$/i)||navigator.userAgent.match(/^.*opera mini.*$/i)||navigator.userAgent.match(/^.*windows ce.*$/i)||(navigator.userAgent.match(/^.*ppc.*$/i)&&!navigator.userAgent.match(/^.*ppc\smac.*$/i))||navigator.userAgent.match(/^.*symbian.*$/i)||navigator.userAgent.match(/^.*avantgo.*$/i)||navigator.userAgent.match(/^.*opera mini.*$/i)||navigator.userAgent.match(/^.*wii.*$/i)||navigator.userAgent.match(/^.*playstation.*$/i)){return }if(idProperties.dynamicServer==window.location.protocol+"//"+window.location.hostname||idProperties.env=="stage"||idProperties.env=="live"){identity.status.enableJavaScript()}};return B}();identity.cta=function(){var F,H,B,D,E={},A=[];var C="/users/authorized.bool";var G=function(I,J){if(typeof J.onSuccess!="function"){J.onSuccess=function(){}}H.net.get([C,"?url=",I].join(""),{onLoad:function(L){var K=L.text();if(K=="0"&&typeof J.onFailure=="function"){J.onFailure()}else{if(K=="1"&&typeof J.onSuccess=="function"){J.onSuccess()}}}})};E.parseLinks=function(){var I=F("a.id-cta,a.id-cta-login");for(l in A){D(A[l])}A=[];I.each(function(N){var R=F(this);var J=R.attr("href"),T;if(J.indexOf("?")!=-1){T=J.substring(0,J.indexOf("?"))}else{T=J.substring(0,J.length)}var P={},M;var Q=J.substring(J.indexOf("?")+1).split("&");for(M in Q){P[Q[M].substring(0,Q[M].indexOf("="))]=Q[M].substring(Q[M].indexOf("=")+1)}var O,L,K;if(P.target_resource){O=P.target_resource}if(P.ptrt){L=P.ptrt}if(typeof L=="undefined"){L=T}K=O||L;identity.migrationVars={};identity.migrationVars.ptrt=L;identity.migrationVars.target_resource=O;var S=["/users/dash/more?ptrt=",L].join("");if(O!="undefined"&&L!=O){S=[S,"&target_resource=",O].join("")}if(!identity.util.getCookie("IDENTITY")){A[A.length]=B(R,"click",function(W){W.preventDefault();if(!identity.status.hasChanged()){identity.status.loadAndShowPanel(W,"login");var U=function(X){G(K,{onFailure:function(){window.location=S},onSuccess:function(){window.location=L}})};var V=identity.addLoginHandler(U)}})}else{G(K,{onFailure:function(){A[A.length]=B(R,"click",function(U){U.preventDefault();if(!identity.status.hasChanged()){window.location=S}})},onSuccess:function(){A[A.length]=B(R,"click",function(U){U.preventDefault();if(!identity.status.hasChanged()){window.location=L}})}})}})};E.init=function(I){H=I;F=H.dom.get;B=H.events.addListener;D=H.events.removeListener};return E}();identity.util=function(){var C={},E,D,A,B;C.authorized=function(G){var F=E.net.get(["/users/authorized.bool?url=",G].join(""),{async:false});try{if(F.text()==1){return true}}catch(H){}return false};C.setCookie=function(H,I,J){var F,G;if(J){G=new Date();G.setTime(G.getTime()+(J*24*60*60*1000));F=["; expires=",G.toGMTString()].join("")}else{F=""}document.cookie=[H,"=",I,F,"; path=/"].join("")};C.getCookie=function(G){var I=[G,"="].join("");var F=document.cookie.split(";");for(var H=0;H<F.length;H++){var J=F[H];while(J.charAt(0)==" "){J=J.substring(1,J.length)}if(J.indexOf(I)===0){return J.substring(I.length,J.length)}}return null};C.deleteCookie=function(F){identity.util.setCookie(F,"",-1)};C.random=function(J){var H="";var I="bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ0123456789";for(var G=0;G<J;G++){var F=new Date();H=[H,I.charAt(Math.floor(Math.random(F.getTime())*I.length))].join("")}return H};C.var_dump=function(N,H,F){var I="";if(!H){H=20}if(!F){F=1}var G="  ";var L="";for(var J=0;J<F;J++){L=[L,G].join("")}if(typeof (N)=="object"){I=[I,"{\n"].join("");var K=true,M;for(M in N){I=[I,(F>=H)?"...":L,'"',M,'": ',var_dump(N[M],H,F+1),",\n"].join("");K=false}if(K){I=[I.substr(0,I.length-1),"}"].join("")}else{I=[I.substr(0,I.length-2),"\n",L.substr(0,L.length-G.length),"}"].join("")}}else{if(typeof (N)=="string"){I=[I,('"'+N+'"')].join("")}else{if(typeof (N)=="boolean"){I=[I,(N?"true":"false")].join("")}else{if(typeof (N)=="function"){I=[I,"function"].join("")}else{I=[I,(N)].join("")}}}}return I};C.getScrollPosition=function(G){if(typeof G=="undefined"){G=""}var F=0,H=0;if(typeof (window.pageYOffset)=="number"){F=window.pageXOffset;H=window.pageYOffset}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){F=document.body.scrollLeft;H=document.body.scrollTop}else{if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){F=document.documentElement.scrollLeft;H=document.documentElement.scrollTop}}}if(G=="x"){return F}else{if(G=="y"){return H}else{return{x:F,y:H}}}};C.init=function(F){E=F;D=E.dom.get;A=E.events.addListener;B=E.events.removeListener;if(!("console" in window)){window.console=function(){var H={},K,J,I,G=false;H.enable=function(){G=true};H.disable=function(){G=false};H.clear=function(){I.empty()};H.log=function(L){if(G){if(typeof (I)=="undefined"){I=K.dom.create('<p id="console-log" style="position: fixed; bottom: 0; left: 0; height: 100px; width: 100%; overflow-y: auto; overflow-x: noscroll;background: white;border-top: 1px solid gray;"></p>');J("body").append(I);J("body").css("padding-bottom","100px");if(K.env.ie&&K.env.ie<=6){J("#console-log").css("position","absolute");setInterval(function(){I.css("height","99px");I.css("height","100px")},250)}}I.append([L,"<br />"].join(""));I[0].scrollTop=I[0].scrollHeight}};H.init=function(L){K=L;J=K.dom.get};return H}();console.init(E)}};return C}();