
var nLastLogin=0;function InitPageCode()
{setTimeout(OnLoad,100);}
function OnLoad()
{var oUserName=document.getElementById("userName");oUserName.focus();}
function Login()
{var oXmlRequest=new XmlRequest();oXmlRequest.getXml("GetSession.jsp",cbGetSessionResponse);}
function cbGetSessionResponse(oXml)
{var sPassword=new String(document.getElementById("password").value);sPassword=sPassword.trim();var oXmlRequest=new XmlRequest();oXmlRequest.addParameter("userName",document.getElementById("userName").value);oXmlRequest.addParameter("password",sha256_digest(sPassword));oXmlRequest.addParameter("loginType",4);oXmlRequest.getXml("Login.jsp",GetResponse);}
String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"");}
function GetResponse(oXml)
{var oResult=oXml.documentElement;var sSessionId=oResult.getAttribute("sessionId");var oRows=oXml.documentElement.getElementsByTagName("row");if(oRows.length==0)
{alert("Invalid username/password");}
else if(oRows.length==1)
{var oRow=oRows[0];if(oRow.getAttribute("suspended")=="true")
{alert("Your account access has been suspended.\nPlease contact Kansas City Scout at (816) 622-6500.");setTimeout(ExitSystem,100);return;}
nLastLogin=oRow.getAttribute("lastLogin");if(oRow.getAttribute("changePassword")==1)
{alert("You must change your password before continuing.");window.popupClosing=popupClosing;window.forceChange=1;window.open("MyProfilePassword.html?OpenForm","new_win","width=400, height=350");}
else
{setTimeout(DoSetupWizard,100);}}}
function ExitSystem()
{document.location="SubLogin.html";}
function DoSetupWizard()
{if(nLastLogin==0)
{document.location="SubSetupServices.html";}
else
{UpdateLastLogin();}}
function UpdateLastLogin()
{var oXmlRequest=new XmlRequest();oXmlRequest.getXml("SubUpdateLastLogin.jsp",cbUpdateResponse);}
function cbUpdateResponse(oXml)
{var oResult=oXml.documentElement;var nRowsAffected=oResult.getAttribute("rowsAffected");setTimeout(FinishLogin,100);}
function returnOnEnter(myfield,e)
{var key;var keychar;if(window.event)
key=window.event.keyCode;else if(e)
key=e.which;else
return true;if(key==13)
{setTimeout(Login,100);return(false);}}
function popupClosing()
{setTimeout(FinishLogin,100);}
function FinishLogin()
{document.location="SubHome.html";}
