    
    /* //-> INCLUDE CRYPTO SHA256 */
    document.write('<scr' + 'ipt src="/library/js/components/encrypt/sha2.js" type="text/javascript"><\/scr' + 'ipt>');
    
    var login = {
    
        connectionService:"/webservices/Authentification.aspx",
        destination:"/Dashboard.aspx",
        
        initialize:function()
        {
            this.messagePanel = $("messagePanel");
            
            this.setupLoginProcess();
            $("identifier").focus();
            
        },
        
        setupLoginProcess:function()
        {
            this.enterButton = new ActionButton("enter");
            this.enterButton.addListener("logIn", "click", function(e){this.connect()}.bindAsEventListener(this));
            this.enterButton.enable();
            
            Event.observe($("loginForm"), "keypress", function(evt){
                keyPressManager(evt,13,function(){
                    Event.stop(evt);
                    this.connect()
                }.bind(this));
            }.bindAsEventListener(this));
        },
        
        getFormValues:function()
        {
            if($("identifier").value == "" || $("password").value == "")
            {
                this.messagePanel.update("Veuillez saisir votre identifiant et votre mot de passe !");
                return null;
            }
        
            return {
                identifier:encodeURIComponent($("identifier").value),
                password:/*hex_sha256(*/$("password").value/*)*/,
                rememberUserPassword:($("rememberUser").checked == true?1:0)
            };
        
        },
        
        connect:function()
        {
        
            var values = this.getFormValues();
            if(values == null) return;
            
            var postPackage = {};
            postPackage["action"] = "logIn";
            postPackage["identifier"] = values.identifier;
            postPackage["password"] = values.password;
            postPackage["rememberUserPassword"] = values.rememberUserPassword;

            //-> DISABLE TEXTBOXES
            this.toogleTextBoxes(false);
            //-> START LOADING
            this.enterButton.disable();
            this.enterButton.update("");
            
            Utils.Ajax.webServiceCaller({
                url:this.connectionService,
                method:"post",
                parameters:postPackage,
                onLoading:Prototype.emptyFunction,
                onComplete:function(transport, json){
                			                                            
                    var response = transport.responseText;
                    
                    //-> LOGIN SUCCESS
                    if(response == "OK")
                    {
                        this.messagePanel.update("Authentification r&eacute;ussie.");
                        this.openAccess.bind(this).delay(.150);
                    }
                    else
                    {
                        this.messagePanel.update(Application.webservice.errorManager(response, true).message);
                    
                        //-> ENABLE TEXTBOXES
                        this.toogleTextBoxes(true);
                        this.enterButton.enable();
                        this.enterButton.update("Entrer");
                    } 

                }.bind(this)
				
            });                
        },
        
        openAccess:function()
        {
            //-> ENABLE TEXTBOXES
            this.toogleTextBoxes(true);
            this.enterButton.enable();
            this.enterButton.update("Entrer");
            location.href = this.destination;
        
        },
        
        toogleTextBoxes:function(status)
        {
            if(status)
            {
                $("identifier").enable();
                $("password").enable();
            }
            else
            {
                $("identifier").disable();
                $("password").disable();
            }
        }

    }
    
	Event.onDOMReady(function(){login.initialize()});    
    
