<script language="javascript" type="text/javascript">
        function Login_OnClick()
        {
            if (document.getElementById("txtUsername").value == "")
            {
                alert("Wprowad nazwę użytkownika.");
                document.getElementById("txtUsername").focus();
                return;
            }
            if (document.getElementById("txtPassword").value == "")
            {
                alert("Wprowad hasło");
                document.getElementById("txtPassword").focus();
                return;
            }
Sys.Services.AuthenticationService.set_defaultLoginCompletedCallback (OnLoginCompleted);
Sys.Services.AuthenticationService.set_defaultFailedCallback(OnFailed);
Sys.Services.AuthenticationService.set_defaultLogoutCompletedCallback (OnLogoutCompleted);
Sys.Services.AuthenticationService.login(document.getElementById ("txtUsername").value, document.getElementById("txtPassword").value, false,null,null,null,null,"User Context");
return;
}
        function Logout_OnClick()
        {
            Sys.Services.AuthenticationService.logout(null, null, null, null);
        }
        function OnLoginCompleted(validCredentials, userContext, methodName)
        {
            if (validCredentials == true)
            {
                document.getElementById("divLogin").style.display = 'none';
                document.getElementById("divHome").style.display = 'block';
            }
            else
            {
                alert("Nieprawidłowe dane!");
                document.getElementById("txtUsername").focus();
            }
            return;
        }
        function OnFailed(error, userContext, methodName)
        {
            alert("Próba zalogowania się w witrynie zakończyła się niepowodzeniem. Szczegóły: " + error.get_message() + ". " + error.get_statusCode());
            return;
        }
        function OnLogoutCompleted(result)
        {
            document.getElementById("divLogin").style.display = 'block';
            document.getElementById("divHome").style.display = 'none';
            return;
        }
</script>
