    
    var newPasswordRequest = {
    
        newPasswordRequestService:"/webservices/NewPasswordRequest.aspx",
        initialize:function()
        {
            this.formFields = {
                mail:$("mail"),
                SDEZCompany:$("SDEZCompany"),
                clientNumber:$("clientNumber")
            };
            this.messagePanel = $("messagePanel");
            
            
            if(!this.formFields.mail || !this.formFields.SDEZCompany || !this.formFields.clientNumber || !$("messagePanel"))
            {
                alert("MISSING NEW_PASSWORD_REQUEST DOM ELEMENTS !");
                return;
            }
        
            
            this.setupPasswordRequestProcess();
            this.formFields.mail.focus();
            this.messagePanel.update(Application.messages.NEW_PASSWORD_REQUEST__WELCOME)
            
        },
        
        setupPasswordRequestProcess:function()
        {
            if($("send"))
            {
                this.sendButton = new ActionButton("send");
                this.sendButton.addListener("sendMail", "click", function(e){this.sendMailAdress()}.bindAsEventListener(this));
                this.sendButton.enable();
            }
            else
            {
                alert("MISSING SEND DOM BUTTON ELEMENT !");
                return;
            
            }
        },
        
        getFormValues:function()
        {
            if(this.formFields.mail.value == "")
            {
                this.messagePanel.update(Application.errorsManager("MISSING_MAIL_ADRESS", true).message);
                return null;
            }
            if(!new RegExp(Application.regexFormatValidator.mail).test(this.formFields.mail.value))
            {
                this.messagePanel.update(Application.errorsManager("DATA_FORMAT_INVALID_MAIL", true).message);
                return null;
            }
            
            if(this.formFields.SDEZCompany.selectedIndex == 0)
            {
                this.messagePanel.update("Veuillez le site de rattachement du compte concern&eacute; !");
                return null;
            }
            
            if(this.formFields.clientNumber.value == "")
            {
                this.messagePanel.update("Veuillez le num&eacute;ro client du compte concern&eacute; !");
                return null;
            }
            
                    
            return {
                mail:this.formFields.mail.value,
                SDEZCompany:this.formFields.SDEZCompany.options[this.formFields.SDEZCompany.selectedIndex].value,
                clientNumber:this.formFields.clientNumber.value
            };
        
        },
        
        sendMailAdress:function()
        {
        
            var values = this.getFormValues();
            if(values == null) return;
            
            var postPackage = {};
            postPackage["action"] = "sendMailForNewPassword";
            postPackage["mail"] = encodeURIComponent(values.mail);
            postPackage["SDEZCompany"] = encodeURIComponent(values.SDEZCompany);
            postPackage["clientNumber"] = encodeURIComponent(values.clientNumber);

            //-> DISABLE TEXTBOXES
            this.toogleTextBoxes(false);
            //-> START LOADING
            this.sendButton.disable();
            this.messagePanel.update(Application.messages.LOADING);
            
            Utils.Ajax.webServiceCaller({
                url:this.newPasswordRequestService,
                method:"post",
                parameters:postPackage,
                onLoading:Prototype.emptyFunction,
                onComplete:function(transport, json){
                			                                            
                    var response = transport.responseText;
                    
                    //-> SEND SUCCESS
                    if(response == "OK")
                    {
                        this.confirmNewPasswordRequest();
                    }
                    else
                    {
                        this.messagePanel.update(Application.errorsManager(response, true).message);
                    
                        //-> ENABLE TEXTBOXES
                        this.toogleTextBoxes(true);
                        this.sendButton.enable();
                    } 

                }.bind(this)
				
            });                
        },
        
        confirmNewPasswordRequest:function()
        {
            //-> MODALBOX CONFIRMATION
            Application.modalBox.confirm.open({
                message:Application.messages.NEW_PASSWORD_REQUEST__CONFIRMATION,
                buttons:[
                    //-> OK BUTTON
                    {codeName:"ok", label:"Ok", action:Prototype.emptyFunction}
                ]
            });                    

            //-> ENABLE TEXTBOXES
            this.toogleTextBoxes(true);
            //-> ENABLE SEND_BUTTON
            this.sendButton.enable();
            //-> RESTORE DEFAULT MESSAGE PANEL
            this.messagePanel.update(Application.messages.NEW_PASSWORD_REQUEST__WELCOME)
            //-> EMPTY MAIL FIELD
            this.formFields.mail.value = "";
            this.formFields.SDEZCompany.selectedIndex = 0;
            this.formFields.clientNumber.value = "";

        
        },
        
        toogleTextBoxes:function(status)
        {            
            for(property in this.formFields)
            {
                eval("this.formFields[property]." + (!status?"disable":"enable") + "()");
            }
        }
    }
    
	Event.onDOMReady(function(){newPasswordRequest.initialize()});
