
var loginHandler=undefined;function setupPageLogin()
{var caller=commonCaller;if(caller.isExternalUser())
return true;var span=document.getElementById('loginAnchor');if(undefined==span)
return false;var elem=document.createElement('a');elem.href='javascript:void(null)';span.innerHTML='&nbsp;|&nbsp;';span.appendChild(elem);loginHandler=new LoginHandler();loginHandler.init(elem);window.onerror=loginHandler.authException;return true;}
function LoginHandler()
{this.caller=new PinkContentCalls();this.loginForm=new LoginFormDOM(this);}
LoginHandler.prototype.init=function(elem)
{this.anchor=elem;this.anchor.myCallback=this;var canAuthor=this.caller.canAuthor();var caption=canAuthor?CAPTION_LOGOUT:CAPTION_LOGIN;var action=canAuthor?this.doPageLogout:this.doPageLogin;elem.innerHTML=caption;elem.onclick=action;}
LoginHandler.prototype.authException=function(msg,url,line)
{if((undefined==window.lastPinkException)||!window.lastPinkException.isNotAuthenticatedException)
return;window.lastPinkException=undefined;loginHandler.openLogin();}
LoginHandler.prototype.openLogin=function(){this.loginForm.open();}
LoginHandler.prototype.handlePostLogin=function()
{this.anchor.innerHTML=CAPTION_LOGOUT;this.anchor.onclick=this.doPageLogout;if(undefined!=window.inlineEditor)
inlineEditor.init();}
LoginHandler.prototype.doLogin=function(userName,password)
{return this.caller.login(userName,password).isSuccess;}
LoginHandler.prototype.doLogout=function()
{this.caller.logout();this.anchor.innerHTML=CAPTION_LOGIN;this.anchor.onclick=this.doPageLogin;if(undefined!=window.inlineEditor)
inlineEditor.init();}
LoginHandler.prototype.doPageLogin=function(ev)
{this.myCallback.openLogin();}
LoginHandler.prototype.doPageLogout=function(ev)
{this.myCallback.doLogout();}
LoginHandler.prototype.doToken=function(userName,password,tokenCode,nextTokenCode)
{return this.caller.accessRSA(userName,password,tokenCode,nextTokenCode);}
LoginHandler.prototype.hasUserToken=function(userName)
{if(undefined==this.commonCaller)
this.commonCaller=new PinkCommonCalls();return this.commonCaller.hasUserToken(userName);}