var displayCookie="SASUserDisplayName";
var serverURL="/profile/auth/";
function showLoginScreen(){var a=document.getElementById("loginOverlay");
a.style.display="block";var b=document.getElementById("loginFormOverlay");
b.style.display="block";document.getElementsByTagName("html")[0].style.overflow="hidden"
}function hideLoginScreen(){var b=document.getElementById("loginOverlay");
b.style.display="none";var a=document.getElementsByTagName("html")[0];
a.style.overflow="visible";var c=document.getElementById("loginFormOverlay");
c.style.display="none";document.getElementById("email").value="";
document.getElementById("password").value="";
clearLoginMessage("")}function showAnonMenu(){try{var e=document.getElementById("logout");
if(e!=undefined){e.style.display="none"
}var c=document.getElementById("login");
if(c!=undefined){c.style.display="block"
}var b=document.getElementById("logout2");
if(b!=undefined){b.style.display="none"
}var a=document.getElementById("logout3");
if(a!=undefined){a.style.display="none"
}var f=document.getElementById("login2");
if(f!=undefined){f.style.display="block"
}}catch(d){}}function showAuthMenu(h){try{var e=document.getElementById("logout");
if(e!=undefined){e.style.display="block"
}var c=document.getElementById("login");
if(c!=undefined){c.style.display="none"
}var b=document.getElementById("logout2");
if(b!=undefined){b.style.display="block"
}var a=document.getElementById("logout3");
if(a!=undefined){a.style.display="block"
}var g=document.getElementById("login2");
if(g!=undefined){g.style.display="none"
}var f=document.getElementById("loginDisplayName");
f.style.display="inline";f.innerHTML=h
}catch(d){}}function interpretFirstName(f){var c="";
var b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var h="nAwzLRWvhiobKSpxJaIUTeyHQcqBMtkXPZdgGfjCrFNYOEslVDmunAwzLRWvhiobKSpxJaIUTeyHQcqBMtkXPZdgGfjCrFNYOEslVDmu";
try{var g=f.split(":")[2];var a=g.length;
var d="";for(count=0;count<=a;count=count+1){d=g.charAt(count);
if(isLetter(d)){index=h.indexOf(d,46);
if(index>-1){c=c+b.charAt(index-count)
}else{c=c+d}}}}catch(e){}return c
}function handleLogin(){var a=window.location.href;
var b=window.location.protocol+"//"+window.location.hostname;
if(b==undefined||b==null){b=""}var c=b+"/apps/userid/login.jsp?headerReturnPage="+a;
window.location.href=c}function handleLogout(){var a=window.location;
window.location.href="/apps/userid/login.jsp?lologout=true&headerReturnPage="+a
}function processLoginRequest(){var b=document.getElementById("email").value;
var a=document.getElementById("password").value;
if(validateFields(b,a)){url=serverURL+"login";
login(b,a,url,completeLoginRequest,handleLoginError)
}}function processLogoutRequest(){success=false;
deleteCookie(displayCookie);url=serverURL+"logoff";
logoff(url,completeLogoffRequest,null)
}function validateFields(c,a){var b="";
if(c==null||c==""){displayLoginMessage("e-mail address is required");
return false}if(a==null||a==""){displayLoginMessage("password is required");
return false}return true}function displayLoginMessage(a){var b=document.getElementById("loginMessage");
b.innerHTML=a}function clearLoginMessage(){var a=document.getElementById("loginMessage");
a.innerHTML=""}function userProfileInit(){try{var b=readCookie(getAuthCookieName());
if(b!=null&&b!=""&&b.charAt(0)!=":"){showAuthMenu(interpretFirstName(b))
}else{showAnonMenu()}}catch(a){}}try{YAHOO.util.Event.onDOMReady(userProfileInit)
}catch(error){}function login(h,a,e,d,c){var g="application/x-www-form-urlencoded";
var f="username="+h+"&password="+a;
var b=new HTTPPost(f,e,g,d,c);b.doPost()
}function logoff(d,c,b){var f="application/x-www-form-urlencoded";
var e="";var a=new HTTPPost(e,d,f,c,b);
a.doPost()}function retrieveConfigInfo(d,c,b){var f="application/x-www-form-urlencoded";
var e="";var a=new HTTPPost(e,d,f,completeInit,handleLoginError);
a.doPost()}function getAuthCookieName(){host=document.location.host;
cookieName="SAStestp";var a=/prod/;
if(host=="support.sas.com"||host=="www.sas.com"||a.test(host)){cookieName="SASprofile"
}return cookieName}function completeLogoffRequest(c){var b=c.responseText;
var a=c.status;if(a=="200"){showAnonMenu()
}else{if(a=="401"){displayLoginMessage("Invalid username/password combination")
}else{displayLoginMessage("Login service unavailable. Try again later")
}}}function completeLoginRequest(c){var b=c.responseText;
var a=c.status;if(a=="200"){displayLoginMessage("success");
hideLoginScreen();displayLoginMessage("");
createCookie(displayCookie,b,1)
}else{if(a=="401"){displayLoginMessage("Invalid username/password combination")
}else{alert(a)}}}function handleLoginError(a){alert("login error");
displayLoginMessage("crossdomain issues (try IE)")
}function completeInit(e){var g=e.responseText;
var b=e.status;var f=convertXMLStringToObject(g);
var h="";var a="";if(b=="200"){try{h=f.getElementsByTagName("authCookieName")[0].childNodes[0].nodeValue;
a=f.getElementsByTagName("userCookieName")[0].childNodes[0].nodeValue;
var d=readCookie(h);if(d!=null&&d!=""){showAuthMenu(a)
}else{showAnonMenu()}}catch(c){showAnonMenu()
}}else{showAnonMenu()}}function HTTPPost(g,i,b,a,f){var d=g;
var c=i;var h=b;var e=a;var j=f;
this.doPost=function(){var l;try{l=this.xmlHttpRequest();
l.open("POST",c,true);l.setRequestHeader("Content-type",h);
l.setRequestHeader("Content-length",d.length);
l.onreadystatechange=function(){if(l.readyState!=4){return
}if(e!==undefined){e(l)}};l.send(d)
}catch(k){if(j!==undefined){j(k)
}else{alert("an error occured"+k)
}}return true};this.xmlHttpRequest=function(){try{return new XMLHttpRequest()
}catch(k){try{return new ActiveXObject("Msxml2.XMLHTTP")
}catch(k){}}alert("XMLHttpRequest not supported");
return null}}function createCookie(c,d,e){if(e){var b=new Date();
b.setTime(b.getTime()+(e*24*60*60*1000));
var a="; expires="+b.toGMTString()
}else{var a=""}document.cookie=c+"="+d+a+"; path=/"
}function deleteCookie(a){createCookie(a,"",-1)
}function readCookie(b){var a=document.cookie.split(";");
var e=b+"=";for(var d=0;d<a.length;
d++){var f=a[d];while(f.charAt(0)==" "){f=f.substring(1,f.length)
}if(f.indexOf(e)==0){return unescape(f.substring(e.length,f.length))
}}return null}function convertXMLStringToObject(c){var b=null;
if(c!=null){try{if(window.DOMParser){parser=new DOMParser();
b=parser.parseFromString(c,"text/xml")
}else{b=new ActiveXObject("Microsoft.XMLDOM");
b.async="false";b.loadXML(c)}}catch(a){alert("an error occurred"+a)
}}return b}function isLetter(b){var c=/^[a-zA-Z]+$/;
var a=c.test(b);return c.test(b)
};
