
var ssa=Sys.Services.AuthenticationService;var txtLogin='ctl00_ht_lo_txtLogin';var txtPassword='ctl00_ht_lo_txtPassword';function prepLoginForm(){if(ssa.get_isLoggedIn()){$get('LoggedInView').style.display='';}else{if(!$get(txtLogin))alert('Login not available');$get('AnonymousView').style.display='';}}
function loginHandler(){var username=$get(txtLogin).value;var password=$get(txtPassword).value;if(username!=''&&password!=''){var isPersistent=false;var customInfo=null;var redirectUrl=null;ssa.login(username,password,isPersistent,customInfo,redirectUrl,onLoginComplete,onAuthenticationServiceError,null);}}
function logoutHandler(){var returnUrl='/logout.aspx';var userContext=null;ssa.logout(returnUrl,onLogoutComplete,onAuthenticationServiceError,userContext);}
function onLoginComplete(result,context,methodName){if(result){if(pageTracker!=null)pageTracker._setVar('Customer:'+$get(txtLogin).value.toLowerCase());$get('LoggedInView').style.display='';$get('AnonymousView').style.display='none';var service=new SiteService();service.GetLoginWarningHtml(onGetLoginWarningHtmlSuccess,null,null);}
else{var field1=document.createElement('input');field1.type='hidden';field1.name='logincode';field1.value=$get(txtLogin).value;var newForm=document.createElement('form');newForm.action='/login_failed.aspx?l='+Language;newForm.method="post";newForm.appendChild(field1);if(typeof(returnUrl)!='undefined'&&returnUrl!=''){var field2=document.createElement('input');field2.type='hidden';field2.name='returnUrl';field2.value=returnUrl;newForm.appendChild(field2);}
for(var i=0;i<document.childNodes.length;i++){document.removeChild(document.childNodes[i])}
document.replaceChild(newForm,document.childNodes[0]);newForm.submit();}}
function onGetLoginWarningHtmlSuccess(result,context,methodName){if(result!=''){reportMessage(result,true);}
else{if(typeof(returnUrl)!='undefined'&&returnUrl!=''){reportMessage('Redirecting...',true);document.location.href=returnUrl;}
else if(document.location.href.toLowerCase().indexOf('login_failed.aspx')!=-1){reportMessage('Redirecting...',true);document.location.href="/";}}}
function onLogoutComplete(result,context,methodName){$get('LoggedInView').style.display='none';$get('AnonymousView').style.display='none';}
function onAuthenticationServiceError(error,context,methodName){onWebserviceError(error,context,methodName);}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();