
    function applyForm() {
        var oForm = document.forms["surveyForm"];
        if(isValidForm(oForm)) {
            oForm.action = "/saveSondage.php";
            oForm.submit();
        }
        else {
            scroll(0,0);
        }
    }
    
    function validateForm(oForm, bValid) {
        
        if(!isEmpty(oForm["cellular"].value)) {
            oInput = oForm["idProvider"];
            if(oInput.options[oInput.options.selectedIndex].value == 0 || isEmpty(oInput.options[oInput.options.selectedIndex].value)) {
                writeMessage(oInput.name, "form.requiredField.message");
                bValid = false;
                swicthClassName(oInput,true);
            }
        }
        
        oInput = oForm["birthMonth"];
        if(oInput) {
            if(oInput.options[oInput.options.selectedIndex].value == 0 || isEmpty(oInput.options[oInput.options.selectedIndex].value)) {
                writeMessage("birthMonth", "form.requiredField.message");
                bValid = false;
                swicthClassName(oInput,true);
            }
        }
        
        return bValid;
    }
    
    function displayAvatar(oDivAvatar) {
        var oForm = document.forms['surveyForm'];
        
        if(document.all)
        {
            pWidth = document.documentElement.clientWidth;
        }
        else
        {
            pWidth = window.innerWidth;
        }
        
        var sSource = '/getImage.php?path='+oForm.avatar.value+'&canvasHeight=200&background=FFFFFF&centerd=1';
        if(pWidth < 800)
        {
            sSource = sSource + '&canvasWidth='+(pWidth - 100);
        }
        
        var oImage = document.createElement('img');
        oImage.src = sSource;
        
        oDivAvatar.appendChild(oImage);
        
        oPage = $("laPage");
        if(oPage)
        {
            if(pWidth < 800)
            {
                oPage.style.width = '100%';
            }
        }
    }
    
    // Birthdate processing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    {
        function onBirthDateChanged(useOriginalDay) {
            var oForm             = document.forms["surveyForm"];
            var oBirthYear        = oForm["birthYear"];
            var oBirthMonth       = oForm["birthMonth"];
            var oBirthDay         = oForm["birthDay"];
            
            var selectedYear  = oBirthYear.options[oBirthYear.selectedIndex].value;
            var selectedMonth = oBirthMonth.options[oBirthMonth.selectedIndex].value;
            var selectedDay   = oBirthDay.options[oBirthDay.selectedIndex].value;
            
            // prepare an array of days of each month
            var arrDay = Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
            
            // if the selected month is february...
            if(selectedMonth == 2) {
                // if the chosen birth year is not empty, and is bissectile...
                if(selectedYear > 0) {
                    if(selectedYear % 4 == 0) {
                        // then february has 29 days that year
                        arrDay[2] = 29;
                    }    
                }
            }
            
            // clear the options from the birthDay select element
            select_clearOptions("birthDay");
            
            // add a default option for the birthDay select element
            oBirthDay.options[oBirthDay.options.length] = new Option(Localization.getTranslation("form.field.birthDay"), 0);
            
            // build options for each available day of the selected month
            if(selectedMonth > 0) {
                var daysThatMonth = arrDay[selectedMonth];
                
                if(daysThatMonth > 0) {
                    for(var iDay = 1; iDay <= daysThatMonth; iDay += 1) {
                        oBirthDay.options[oBirthDay.options.length] = new Option(iDay, iDay);
                    }
                }
            }
        }
    }
