 window.onload = function(){
                var qsParm = new Array();
                var query = window.location.search.substring(1);
                var parms = query.split('&');
                for (var i = 0; i < parms.length; i++) {
                    var pos = parms[i].indexOf('=');
                    if (pos > 0) {
                        var key = parms[i].substring(0, pos);
                        var val = parms[i].substring(pos + 1);
                        qsParm[key] = val;
                    }
                }
                
                var address = null;
                
                if ((qsParm['street'] != null) && (qsParm['street'] != "")) {
                    address = qsParm['street'];
                }
                if ((qsParm['city'] != null) && (qsParm['city'] != "")) {
                    address = address + ', ' + qsParm['city'];
                }
                if ((qsParm['province'] != null) && (qsParm['province'] != "")) {
                    address = address + ', ' + qsParm['province'];
                }
                if ((qsParm['postal'] != null) && (qsParm['postal'] != "")) {
                    address = address + ', ' + qsParm['postal'];
                }
                
                if (address != null) {
                    document.list["MESSAGE"].value = window.unescape(address);
                }
                
                
                if (location.search) {
                    var f = document.forms['list'];
                    var hash = new HashMap(location.search.substr(1), '&', '=');
                    var keys = hash.getKeys();
                    for (var i = 0; i < keys.length; i++) {
                        var fd = eval("f." + keys[i]);
                        if (fd == null) 
                            continue;
                        if (fd.tagName == "INPUT" && hash.get(keys[i])) 
                            fd.value = window.unescape(hash.get(keys[i]).replace(/\+/g, ' '));
                        if (fd.tagName == "TEXTAREA") 
                            fd.innerHTML = window.unescape(hash.get(keys[i]).replace(/\+/g, ' '));
                        checkSize();
                    }
                    f.CODE.select();
                }
            }
            
            function checkForm(){
                var check_code = document.list.elements['CODE'].value;
                var check_num = document.list.elements['NUM'].value;
                
                var error_check = "no";
                var strValidNumChars = "0123456789";
                var strChar;
                var numericResult = true;
                
                //  code validation
                for (i = 0; i < check_code.length && numericResult == true; i++) {
                    strChar = check_code.charAt(i);
                    if (strValidNumChars.indexOf(strChar) == -1) {
                        numericResult = false;
                    }
                }
                
                if ((check_code == "") || (check_code.length != 3) || (numericResult == false)) {
                    error_check = "yes";
                    alert("Veuillez entrer un indicatif régional valide.");
                    return false;
                }
                
                //  num validation
                for (i = 0; i < check_num.length && numericResult == true; i++) {
                    strChar = check_num.charAt(i);
                    if (strValidNumChars.indexOf(strChar) == -1) {
                        numericResult = false;
                    }
                }
                
                if ((check_num == "") || (check_num.length != 7) || (numericResult == false)) {
                    error_check = "yes";
                    alert("Veuillez entrer un numéro de téléphone valide.");
                    return false;
                }
            }
            
            // Keeps track of the previous content in the message field
            var Oldmsg;
            var Oldmsg2;
            var Oldmsg3;
            var Oldmsg4;
            var Oldmsg5;
            
            
            
            function clearall(){
                document.list["MESSAGE"].value = "";
                document.list["CODE"].value = "";
                document.list["NUM"].value = "";
                document.list["FROM"].value = "";
                document.list["COUNT"].value = "0";
            }
            
            function Key_Up(e){
                if ((e.target == document.list["MESSAGE"])) {
                    checkSize();
                }
            }
            
            if (window.Event) {
                if (document.captureEvents) 
                    document.captureEvents(Event.KEYUP);
                document.onkeyup = Key_Up;
            }
            
            // function checkLength
            function checkSize(){
                var formElement = document.list["MESSAGE"];
                var formElement2 = document.list["FROM"];
                var Len1 = formElement.value.length;
                var Len2 = formElement2.value.length;
                
                Len = Len1 + Len2;
                
                if (Len > 250) {
                    formElement.value = Oldmsg;
                    formElement2.value = Oldmsg2;
                    
                    alert("Votre message a atteint la durée maximale autorisée!");
                    return false;
                }
                else {
                    document.list["COUNT"].value = Len;
                }
                Oldmsg = formElement.value;
                Oldmsg2 = formElement2.value;
            }
            
            function submitButton(vHandler, vAction){
                document.list.Handler.value = vHandler;
                document.list.Action.value = vAction;
                document.list.submit();
            }
            
            function autotab(){
                if (document.list.area.value.length == 3) {
                    document.list.nxx.focus();
                }
                if (document.list.area.value.length == 3 && document.list.nxx.value.length == 3) {
                    document.list.num.focus();
                }
                
            }
            
            function autotab(){
                if (document.list.CODE.value.length == 3) {
                    document.list.NUM.focus();
                }
                
                
            }
            
            function autotab_too(){
            
            }
            
            
            function setFocus(){
                document.list.CODE.focus();
            }
