/* JavaScript File  */
var IsUnknown;
var IsMSIE;
var IsFirefox;
var IsNetscape;
var IsOpera;
var IsSafari;
var IsKonqueror;
var IsOSWIN;
var IsOSLinux;
var IsOSUnix;
var IsOSMac;
var IsOSUnknown;
var eventAdded = false;
var loading = false;
var currTopMenuIndex;
var _DOC = new Document();
var _GUI = new GUI();
var _Client = new Client();
var _Browser = new Browser();
var _Validation = new Validation();
var _Cookies = new Cookies();
var isDebug = false;
var _String = new Strings();
var needToConfirm = false;
var isEnglish = false;

window.onload = function PageLoad() {
    _Client.Maximize()

    var pageName = _Browser.PageName();
    pageName = pageName.toLowerCase()
    try {
        if (pageName == 'jobsearch.aspx') {
            _DOC.AddEventListener("oEcandidatSearch", "click", SearchEcandidatJob);
        }
    } catch (err) { ShowError(err,GetmethodName()); }
    
    try {
        // Top Menu Assignation...
        if (pageName == 'default.aspx' || pageName == 'carriere.aspx' || pageName == 'faq.aspx' || pageName == 'equipes.aspx') { currTopMenuIndex = 1; }
        else if (pageName.indexOf("alerte") > -1) { currTopMenuIndex = 1; }
        else if (pageName.indexOf("emploi") > -1) { currTopMenuIndex = 3; }
        else if (pageName.indexOf("entreprise") > -1) { currTopMenuIndex = 4; }
        else if (pageName.indexOf("emptemp") > -1) { currTopMenuIndex = 5; }
        else if (pageName == 'apropos.aspx') { currTopMenuIndex = 6; }
        else if (pageName.indexOf("admin") > -1) {
            currTopMenuIndex = 1;
            PageLoadAdmin();
        }
        else { currTopMenuIndex = 1; }
        setTopMenu(currTopMenuIndex);

        // Default Pages Assignations...
        _DOC.SetElementValueById('AdeccoYear', GetDateTimeDetails('y'));

    } catch (err) { ShowError(err,GetmethodName()); }

    try {
        // Disable Autocomplete for client inputs.
        if (pageName == 'login.aspx') {
            _Client.DisableAutoComplete();
        }
    } catch (err) { ShowError(err,GetmethodName()); }
}
function FileName() {
    var firstpos;
    var lastpos;
    var Namer; 
    if (location.href.lastIndexOf('/') != -1)
    // Check whether '/' exists. 
    {
        // If it does then we ... 
        firstpos = location.href.lastIndexOf('/') + 1;

        // Find the first position (the file starts after this) 
        lastpos = location.href.length;
        /* Normally, the last position of the filename will be at the end of the complete URL - although it could have a # and a name at the end!*/
        Namer = location.href.substring(firstpos, lastpos);
        // We extract the string (the file's name). 
        // alert('My name is "'+Namer+'"'); 
        // And reveal all to the clicker! 
    }
    return Namer
} 
window.onbeforeunload = function beforeunload(e) {
    var pageName = '';
    var answer;

    return;

    try {
        e = e || window.event;
        pageName = _Browser.PageName();

        if (pageName == 'CandidatLogin.aspx') {
            //Cookie Assignment.
            var email = _DOC.GetElementValueById('txtEmail');
            if (email != '' && email != 'undefined' && email != null) {
                if (_Validation.isChecked('rememberme')) { _Cookies.SetCookie("adecco_rm", email); }
                else { _Cookies.SetCookie("adecco_rm", null); }
            }
        }
        /*
        if (pageName == 'CandidatInscription.aspx') {
        // Values to be remembered if postback.
        var value = '';
        value = _DOC.GetElementValueById('txtEmail');
        _DOC.SetElementValueById('_email', value);

            value = _DOC.GetElementValueById('txtPwd');
        _DOC.SetElementValueById('_pwd1', value);

            value = _DOC.GetElementValueById('txtPwdConfirm');
        _DOC.SetElementValueById('_pwd2', value);                        
            
        }
        */
        // This one must be the last!!
        if (pageName == 'CandidatInfo.aspx') {
            //e.cancelBubble = true;
            if (!Validate(false)) {
                return "Vous \352tes sur le point de quitter cette page et n''avez pas termin\351 le processus de soumission, \352tes vous certain de vouloir quitter?";
                //answer=confirm("Vous \352tes sur le point de quitter cette page et n''avez pas termin\351 le processus de soumission, \352tes vous certain de vouloir quitter?");
                //if(answer){e.returnValue = "";}else{event.returnValue = "This is the message!";}
                //window.unload = false;
            }
        }
    } catch (err) {
        ShowError(err,GetmethodName());
        return;
    }
}
window.onerror = function(msg) {
    try {
        if (isDebug) { alert(msg); }
        return false;
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
function setTopMenu(index) {
    if (loading) { return; }
    var tabCount = getMenuItemsCount('NavMenu'); // Get Top Menu Items Count.
    var i = 1;
    var over = false;

    try {
        if (index < 1 || index > tabCount) { return; }
        loading = true;

        for (i = 1; i <= (tabCount); i++) {
            if (i == index || i == currTopMenuIndex) {
                setTopMenuItem(i, "selected");
            }else{
                setTopMenuItem(i, "");
            }
        }
    } catch (err) { ShowError(err,GetmethodName()); }
    finally { loading = false; }
}
function getTopMenuDetailsByPos(pos, over) {
    var tabDetails = new Object();

    try {
        switch (pos) {
            case "l":
                if (over) {
                    tabDetails.left = 'TabLeftOverS.PNG';
                    tabDetails.right = 'TabRightOver.PNG';
                } else {
                    tabDetails.left = 'TabLeftOutS.PNG';
                    tabDetails.right = 'TabRightOut.PNG';
                }
                break;
            case "c":
                if (over) {
                    tabDetails.left = 'TabLeftOver.PNG';
                    tabDetails.right = 'TabRightOver.PNG';
                } else {
                    tabDetails.left = 'TabLeftOut.PNG';
                    tabDetails.right = 'TabRightOut.PNG';
                }
                break;
            case "r":
                if (over) {
                    tabDetails.left = 'TabLeftOver.PNG';
                    tabDetails.right = 'TabRightOverE.PNG';
                } else {
                    tabDetails.left = 'TabLeftOut.PNG';
                    tabDetails.right = 'TabRightOutE.PNG';
                }
                break;
        }

        if (over) {
            if (_Browser.Name == 'IE') { tabDetails.center = 'DBD7CE'; }
            else { tabDetails.center = '#E0DDD6'; }
            tabDetails.isOver = true;
        } else {
            if (_Browser.Name == 'IE') { tabDetails.center = '#A19882'; }
            else { tabDetails.center = '#A9A18C'; }
            tabDetails.isOver = false;
        }
        return tabDetails;
    } catch (err) { ShowError(err,GetmethodName()); }
    finally { }
}
function setTopMenuItem(menuIndex,className) {
    try {
        _DOC.SetElementClassName("mnu" + menuIndex, className)

    } catch (err) { ShowError(err,GetmethodName()); }
}
function getMenuItemsCount(objName) {
    // Should look into table to count cell items...
    return 6;
}
function GetListItemsCount() {
    var obj, list, content, cnt;
    try {
        obj = _DOC.GetElementById("dtgPostes");
        if (_DOC.IsObject(obj)) {
            content = obj.innerHTML;
            content = content.toLowerCase();
            content = content.replace("<tbody>", "");
            content = content.replace("</tbody>", "");
            list = content.split("<tr ");
            cnt = 0;
            cnt = list.length - 2;
            return cnt;
        }
    } catch (Error) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    } finally { delete list; delete content; delete list; }
}
function ShowNoResults(visible) {
    var obj, msg;
    try {
        obj = _DOC.GetElementById("NoItems");

        if (_DOC.IsObject(obj)) {
            if (visible == undefined) { visible = false; }
            if (visible) {
                obj.style.display = 'block';
                obj.style.height = '450px';
            } else {
                obj.style.display = 'none';
                obj.style.height = '0px';
            }
        } else { obj.style.display = 'none'; }
    } catch (Error) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return; }
    } finally { delete obj; }
}
function ShowMap(obj) {
    if (obj == null || obj == undefined || obj == 'undefined' || obj == 'undefined') { return; }
    var oGUI = new GUI(obj);
    var oDOC = new Document();
    var props = new Properties();
    var url = '';
    
    try{
        switch (obj.id) {
            case 'mapCV':
                props.top = '100px';
                props.left = '100px';
                props.height = '423px';
                props.width = '662px';
                props.visibility = 'visible';
                props.display = 'block';
                props.zindex = 1000000
                props.backgroundImageURL = 'http://www.adeccoqc.com/Ressources/images/maps/mapCV.PNG';
                break;
            default:
                return;
                break;
        }
        oDOC.AddElement(window.document.body, 'DIV', 'MapContainer', props);
        //oGUI.SetOpacityEx(0, 100, 1000);
    }catch(err){
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    }finally{
        delete _GUI;
    }
}
function SearchEcandidatJob() {
    var oDOC = new Document();

    try {
        var domaine = SearchJobParam("ddlDomaines");
        var region = SearchJobParam("ddlRegions");
        var keyword = SearchJobParam("oKeyword");
        var querystring = '';

        if (domaine == '0' && region == '0' && keyword == '') {
            ShowMsg(50);
            return;
        }
        if (domaine != '' && parseInt(domaine) > 0) {
            if (querystring == '') {
                querystring = "?domaine=" + domaine ;
            } else {
                querystring = +"&domaine=" + domaine;
            }
        }
        if (region != '' && parseInt(region) > 0) {
            if (querystring == '') {
                querystring = "?region=" + region ;
            } else {
                querystring += "&region=" + region ;
            }
        }
        if (keyword != '') {
            if (querystring == '') {
                querystring = "?keyword=" + keyword ;
            } else {
                querystring += "&keyword" + keyword ;
            }
        }
        if (querystring == '') {
            ShowMsg(50);
        } else {
        window.open("http://www.adeccoqc.com/appl/page/listepostes.aspx" + querystring, 'Adecco');
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    } finally {
        delete oDOC;
    }
}
function OpenInNewWindow(url,title,status,scroll,height,width,param) {
    var features = '';
    try {
        
        if (url == null && url == 'undefined' && url == '') { return; }
        if (title == null && title == 'undefined' && title == '') { title = 'Adecco'; }
        features = 'location=1,status=1,scrollbars=1,width=100,height=100'
        if (param == null && param == 'undefined' && param == '') {
            window.open(url, title);
        } else {
            window.open(url + '?' + param, title);
        }  
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    }
}
function OpenInCurrentWindow(url, title, status, scroll, height, width, param) {
    var features = '';
    try {

        if (url == null && url == 'undefined' && url == '') { return; }
        if (title == null && title == 'undefined' && title == '') { title = 'Adecco'; }
        features = 'location=1,status=1,scrollbars=1,width=100,height=100'
        if (param == null && param == 'undefined' && param == '') {
            //window.open(url, title);
            //self.focus();
            window.location.href=url;
        } else {
            //window.open(url + '?' + param, title);
            //self.focus();
            window.location.href = url;
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    }
}
function SearchJobParam(id) {
    var oDOC = new Document();
    var value = '';
    try {
        value = oDOC.GetElementValueById(id);
        return value;
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return ''; }
    } finally {
        delete oDOC;
    }
}
function ShowReportProblem() {
    var body = '';
    var subject = '';
    
    try{
        if (isEnglish) {
            body = '(www.adecco.qc.ca) Please specify in as much clarity as possible on your problem using this website!';
            subject = 'Adecco Web Site Usage problem...';
        }else{
            body = '(www.adecco.qc.ca) Veuillez expliquer le plus clairement possible l\'anomalie que vous venez de remarquer.';
            subject = 'Site web Adecco...';
        }
        //.replace(findstring,newstring)
        window.open("mailto:webmaster@adecco.qc.ca?Subject=" + subject + "&Body=" + body);
    }catch(err){
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return ''; }
    }
}
function urlencode(str) {
    //return escape(str).replace(/\+/g, '%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
function getHTMLEncode(t) {
    return t.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
function getHTMLEncodeEx(strHTML) {
    var html = "" + strHTML;
    var arrE = [["&", "&amp;"], ["\"", "&quot;"], ["<", "&lt;"], [">", "&gt;"]];
    var arrO = [];

    for (var i = 0, j = html.length, k = arrE.length; i < j; ++i) {
        var c = arrO[i] = html.charAt(i);
        for (var l = 0; l < k; ++l) {
            if (c == arrE[l][0]) {
                arrO[i] = arrE[l][1];
                break;
            }
        }
    }
    return arrO.join("");
}
function ShowMsg(id) {
    var msg = '';
    try {
        if (id == '' || id == 'undefined' || id == undefined || id == null) { id = 0; }
        switch (id) {
            case 50: if (isEnglish) { msg = 'At least one selection must be selected or a keyword entered to continue!' } else { msg = 'Aumoins une s\351lection ou un mot cl\351 doit \352tre entr\351 pour continuer!' } break;    // Missing job Search Params.
            //case 1: if (isEnglish) { msg = '' } else { msg = '' }  break; 
            default: msg = ''; break;
        }
        if (msg != '') { alert(msg); }
    }catch(err){ if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return ''; }}
}
/*
function ShowMapToClient(obj) {
    var x, y, h, w;
  
    try {
        switch (obj.id) {
            case 'mapCV':

                break;
            default:
                return;
                break;
        }

    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    } finally {

    }
}
function GetDisplayPosition(pos) {
    var x, y, h, w;

    try {
        switch (obj.id) {
            case 'mapCV':

                break;
            default:
                return;
                break;
        }

    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return 0; }
    } finally {

    }
}
*/
/*
function SetVisibility(selected) {
if (/Row (\d+)/.test(selected) && RegExp.$1 != '') {
var item = RegExp.$1;
document.getElementById('NoItems').style.display = '';
var node;
var ii = 1;
while (node = document.getElementById('option' + ii)) {
if (ii != item) {
node.style.display = 'none';
}
++ii;
}
}
}*/
function ValidateEmpTempLogin() {
    var _Validate = new Validation;
    var value;
    try {
        if (_Validate.IsEmpty('oCanTempPassword', true)) {
            alert('Un mot de passe est requis pour continuer!');
            return false;
        } else {
            return true;
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); return; }
    } finally {
        delete _Validate;
    }
}
function Validate(ShowMsg) {
    var _Validate = new Validation;
    var isValid = true;
    var i = 1;
    var msg = '';

    try {
        if (ShowMsg == undefined) { ShowMsg = true; }

        // Renseignements personnels
        if (_Validate.isRadioListSel('rblSexe', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtNom', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtPrenom', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtAdresse', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtVille', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlProvince', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlPays', true)) { isValid = false; }
        if (!_Validate.isValidPostalCode('txtCodePostal', true) || _Validate.IsEmpty('txtCodePostal', true)) { isValid = false; }
        if (!_Validate.isValidEmail('txtEmail', true) || _Validate.IsEmpty('txtEmail', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtTel1', false) && _Validate.IsEmpty('txtTel2', false) && _Validate.IsEmpty('txtTelBureau', false)) {
            isValid = false;
            _GUI.SetElementBGcolor('txtTel1', ReqValueColor);
        }
        // Mobilité. 
        if (!_Validate.isListChecked('cklMoyenTransport', true)) { isValid = false; }
        if (_Validate.isRadioListSel('rblPermisValide', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlClassePermis', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlRegion1', false) && !_Validate.isValidSelection('ddlRegion2', false) && !_Validate.isValidSelection('ddlRegion3', false) && !_Validate.isValidSelection('ddlRegion4', false)) {
            isValid = false;
            _GUI.SetElementBGcolor('ddlRegion1', ReqValueColor);
        }
        // Langue.		
        if (!_Validate.isValidSelection('ddlBureau', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlLangEvalFrancais', true)) { isValid = false; }
        if (!_Validate.isValidSelection('ddlLangEvalAnglais', true)) { isValid = false; }
        if (_Validate.isChecked('chkLangueAutre1', false)) {
            if (!_Validate.isValidSelection('ddlLangAutre1', true)) { isValid = false; }
            if (!_Validate.isValidSelection('ddlLangEvalAutre1', true)) { isValid = false; }
        } else {
            // Reset Lists & Backcolor!!
            _GUI.SetElementBGcolor('ddlLangAutre1', ReqNormalColor);
            _GUI.SetElementBGcolor('ddlLangEvalAutre1', ReqNormalColor);

        }
        if (_Validate.isChecked('chkLangueAutre2', false)) {
            if (!_Validate.isValidSelection('ddlLangAutre2', true)) { isValid = false; }
            if (!_Validate.isValidSelection('ddlLangEvalAutre2', true)) { isValid = false; }
        } else {
            // Reset Lists & Backcolor!!
            _GUI.SetElementBGcolor('ddlLangAutre2', ReqNormalColor);
            _GUI.SetElementBGcolor('ddlLangEvalAutre2', ReqNormalColor);
        }
        // Formation.
        for (i = 1; i <= 5; i++) {
            if (_Validate.isValidSelection('ddlDiplome' + i, false) || _Validate.isValidSelection('ddlDiscipline' + i, false) || !_Validate.IsEmpty('txtAnneeObtention' + i, false) || !_Validate.IsEmpty('txtInstitution' + i, false)) {
                if (!_Validate.isValidSelection('ddlDiplome' + i, true)) { isValid = false; }
                if (!_Validate.isValidSelection('ddlDiscipline' + i, true)) { isValid = false; }
                if (_Validate.IsEmpty('txtAnneeObtention' + i, true)) { isValid = false; }
                if (_Validate.IsEmpty('txtInstitution' + i, true)) { isValid = false; }
            } else {
                _GUI.SetElementBGcolor('ddlDiplome' + i, ReqNormalColor);
                _GUI.SetElementBGcolor('ddlDiscipline' + i, ReqNormalColor);
                _GUI.SetElementBGcolor('txtAnneeObtention' + i, ReqNormalColor);
                _GUI.SetElementBGcolor('txtInstitution' + i, ReqNormalColor);
            }
        }
        // Type de poste.
        if (_Validate.IsEmpty('txtSalMinHoraire', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtSalMinAnnuel', true)) { isValid = false; }
        if (!_Validate.isListChecked('cklPostes', true)) { isValid = false; }
        if (!_Validate.isListChecked('cklDispo', true)) { isValid = false; }
        // C.V.
        if (_Validate.IsEmpty('inputFileCV', true) || !_Validate.isValidDoc('inputFileCV', true)) {
            msg = '\n\n- Vous devez joindre un c.v.!';
            isValid = false;
        }
        // Autres renseignements.
        if (_Validate.isValidSelection('ddlSource', true)) {
            if (_DOC.GetElementValueById('ddlSource') == 393261) {
                if (_DOC.GetElementValueById('txtAutreSource') == '' || _DOC.GetElementValueById('txtAutreSource') == 'undefined' || _DOC.GetElementValueById('txtAutreSource') == null) {
                    _GUI.SetElementBGcolor('txtAutreSource', ReqValueColor);
                    isValid = false;
                } else {
                    _GUI.SetElementBGcolor('txtAutreSource', ReqNormalColor);
                }
            } else {
                _GUI.SetElementBGcolor('ddlSource', ReqNormalColor);
            }
        } else { isValid = false; }
        // Mot de passe.
        if ((!_Validate.IsEmpty('txtpw1', false) && _Validate.IsEmpty('txtpw2', false)) || (_Validate.IsEmpty('txtpw1', false) && !_Validate.IsEmpty('txtpw2', false))) {
            isValid = false;
            if (_Validate.IsEmpty('txtpw1', false)) { _GUI.SetElementBGcolor('txtpw1', ReqValueColor); isValid = false; }
            else { _GUI.SetElementBGcolor('txtpw1', ReqNormalColor); }
            if (_Validate.IsEmpty('txtpw2', false)) { _GUI.SetElementBGcolor('txtpw2', ReqValueColor); isValid = false; }
            else { _GUI.SetElementBGcolor('txtpw2', ReqNormalColor); }
        } else {
            if ((!_Validate.IsEmpty('txtpw1', false) && !_Validate.IsEmpty('txtpw2', false)) && !_Validate.IsTextMatch('txtpw1', 'txtpw2')) {
                _GUI.SetElementBGcolor('txtpw1', ReqValueColor);
                _GUI.SetElementBGcolor('txtpw2', ReqValueColor);
                msg = '\n\n- Les mot de passes ne sont pas identiques!';
                isValid = false;
            } else {
                _GUI.SetElementBGcolor('txtpw1', ReqNormalColor);
                _GUI.SetElementBGcolor('txtpw2', ReqNormalColor);
            }
        }
        needToConfirm = isValid;

        // Verifie validate Form...
        if (!isValid) {
            if (ShowMsg) {
                alert('Les zones marqu\351s en jaune requi\350rent votre attention!' + msg);
            }
            return false;
        } else {
            return true;
        }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; }
}
function ValidateLogin() {
    var _Validate = new Validation;
    var isValid = true;
    try {
        if (_Validate.IsEmpty('txtNom', true)) { isValid = false; }
        if (_Validate.IsEmpty('txtPwd', true)) { isValid = false; }
        delete _Validate;
        if (!isValid) { alert('Les zones marqu\351s en jaune requi\350rent votre attention!'); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; }
}
function ValidateEmail() {
    var _Validate = new Validation;
    var isValid = true;
    try {
        if (!_Validate.isValidEmail('txtEmailPass', true) || _Validate.IsEmpty('txtEmailPass', true)) { isValid = false; }
        delete _Validate;
        if (!isValid) { alert('Un courriel valide est requis pour continuer!'); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; }
}
function ValidatePassword() {
    var _Validate = new Validation;
    var isValid = true;
    try {
        if (_Validate.IsEmpty('txtEmailPass', true) || !_Validate.IsMinLength('txtEmailPass', 6, true, false)) { isValid = false; }
        delete _Validate;
        if (!isValid) { alert('Un courriel valide est requis pour continuer!'); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; }
}
function ValidateInscription() {
    var _Validate = new Validation;
    var _Doc = new Document;
    var msg = '';
    var i = 0;
    var pwd = false;
    var con = false;
    try {
        if (_Validate.IsEmpty('txtEmail', true)) {
            msg += '\n- Courriel manquant.';
            i += 1;
        } else if (!_Validate.isValidEmail('txtEmail', true)) {
            msg += '\n- Courriel invalide.';
            i += 1;
        } else { pwd = true; }
        if (_Validate.IsEmpty('txtPwd', true)) {
            msg += '\n- Mot de passe manquant.';
            i += 1;
        } else if (!_Validate.IsMinLength('txtPwd', 6, true, false)) {
            msg += '\n- Mot de passe pas assez long.';
            i += 1;
        } else { con = true; }
        if (_Validate.IsEmpty('txtPwdConfirm', true)) {
            msg += '\n- Confirmer mot de passe manquant.';
            i += 1;
        } else if (!_Validate.IsMinLength('txtPwdConfirm', 6, true, false)) {
            msg += '\n- Confirmer mot de passe pas assez long.';
            i += 1;
        }
        if (pwd && con) {
            if (_Doc.GetElementValueById('txtPwd') == _Doc.GetElementValueById('txtPwdConfirm')) {
                _GUI.SetElementBGcolor('txtPwd', ReqNormalColor);
                _GUI.SetElementBGcolor('txtPwdConfirm', ReqNormalColor);
            } else {
                msg += '\n- Les mots de passe ne sont pas identiques.';
                i += 1;
                _GUI.SetElementBGcolor('txtPwd', ReqValueColor);
                _GUI.SetElementBGcolor('txtPwdConfirm', ReqValueColor);
            }
        }
        if (!_Validate.IsEmpty('txtDynCode', true)) {
            if (!_Validate.IsMinLength('txtDynCode', 6, true, false)) {
                msg += "\n- Les caract\350res n''ont pas tous \351t\351 retranscrits.";
                i += 1;
                _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
            } else if (_Validate.IsMaxLength('txtDynCode', 6, true, false)) {
                msg += "\n- Le nombre de caract\350res entr\351 d\351passe celui du code g\351n\351r\351.";
                i += 1;
                _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
            } else {
                _GUI.SetElementBGcolor('txtDynCode', ReqNormalColor);
            }
        } else {
            msg += "\n- Le code n''a pas \351t\351 retranscrit.";
            i += 1;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        }
        if (i > 0) { alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; delete _Doc; }
}
function ValidateEmailJob() {
    var _Validate = new Validation;
    var _Doc = new Document;
    var msg = '';
    var i = 0;
    var pwd = false;
    var con = false;
    try {
        if (_Validate.IsEmpty('txtJobSenderName', true)) {
            msg += '\n- Nom manquant.';
            i += 1;
        } else if (IsMaxLength('txtJobSenderName', 30)) {
            msg += '\n- Nom trop long (maximum de 30 caract\350res).';
            i += 1;
            _GUI.SetElementBGcolor('txtJobSenderName', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtJobSenderName', ReqNormalColor); }

        if (_Validate.IsEmpty('txtJobMessage', true)) {
            msg += '\n- Un message est requis.';
            i += 1;
        } else if (_Validate.IsMaxLength('txtJobMessage', 100, true, false)) {
            msg += "\n- Le message d\351passe l''espace allou\351 (maximum de 100 caract\350res).";
            i += 1;
        }
        if (_Validate.IsEmpty('txtJobEmail', true)) {
            msg += '\n- Courriel manquant.';
            i += 1;
        } else if (!_Validate.isValidEmailCount('txtJobEmail', 3, true)) {
            msg += "\n- Le nombre d'adresses courriels d\351passe le nombre allou\351.";
            i += 1;
        } else if (!_Validate.isValidEmail('txtJobEmail', true)) {
            msg += '\n- Courriel invalide';
            i += 1;
        }

        if (i > 0) { alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; delete _Doc; }
}
function ValidateUnregEmail() {
    var _Validate = new Validation;
    var isValid = true;
    try {
        if (!_Validate.isValidEmail('txtEmail', true) || _Validate.IsEmpty('txtEmail', true)) { isValid = false; }
        delete _Validate;
        if (!isValid) { alert('Un courriel valide est requis pour continuer!'); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; }
}
function ValidateContest() {
    var _Validate = new Validation;
    var _Doc = new Document;
    var msg = '';
    var i = 0;
    var pwd = false;
    var con = false;
    try {
        if (_Validate.IsEmpty('txtRefererName', true)) {
            msg += '\n- Votre nom';
            isValid = false;
            i += 1;
        } else if (IsMaxLength('txtRefererName', 50)) {
            msg += '\n- Votre nom; est trop long (maximum de 50 caract\350res).';
            isValid = false;
            i += 1;
            _GUI.SetElementBGcolor('txtRefererName', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtRefererName', ReqNormalColor); }
        if (_Validate.IsEmpty('txtRefererPhone', false)) {
            msg += '\n- Votre num\351ro de t\351l\351phone.';
            isValid = false;
            i += 1;
            _GUI.SetElementBGcolor('txtRefererPhone', ReqValueColor);
        } else if ( !_Validate.isValidPhone('txtRefererPhone', false)) {
            msg += '\n- Votre num\351ro de t\351l\351phone. (Invalide)';
            isValid = false;
            i += 1;
            _GUI.SetElementBGcolor('txtRefererPhone', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtRefererPhone', ReqNormalColor); }
        
        if (!_Validate.isValidEmail('txtRefererMail', true)) {
            msg += '\n- Votre adresse courriel (Invalide).';
            i += 1;
            isValid = false;
        } else if (_Validate.IsEmpty('txtRefererMail', true)) {
        msg += '\n- Votre adresse courriel.';
            i += 1;
            isValid = false;
        } else { _GUI.SetElementBGcolor('txtRefererMail', ReqNormalColor); }

        if (_Validate.IsEmpty('txtCandidateName', true)) {
            msg += '\n- Nom de la personne r\351f\351r\351e.';
            isValid = false;
            i += 1;
        } else if (IsMaxLength('txtCandidateName', 50)) {
            msg += '\n- Nom de la personne r\351f\351r\351e; est trop long (maximum de 50 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtCandidateName', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtCandidateName', ReqNormalColor); }

        if (!_Validate.isValidEmail('txtCandidateMail', true)) {
            msg += '\n- Courriel de la personne r\351f\351r\351e (Invalide).';
            isValid = false;
        } else if (_Validate.IsEmpty('txtCandidateMail', true)) {
            msg += '\n- Courriel de la personne r\351fér\351e.';
        i += 1;
            isValid = false;
        } else { _GUI.SetElementBGcolor('txtCandidateMail', ReqNormalColor); }

        if (!_Validate.isValidSelection('ddlDomaines', true)) {
            msg += "\n- Cat\351gories d'emploi.";
            i += 1;
            isValid = false;
        }
        if (_Validate.IsEmpty('txtDynCode', true)) {
            msg += '\n- Le code n\'a pas \351t\351 retranscrit.';
            isValid = false;
            i += 1;
        } else if (!_Validate.IsMinLength('txtDynCode', 6)) {
            msg += '\n- Le code est trop court (minimum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else if (_Validate.IsMaxLength('txtDynCode', 50)) {
            msg += '\n- Le code est trop long (maximum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtDynCode', ReqNormalColor); }        
        

        if (_Doc.GetElementValueById("txtRefererMail") != '' && _Doc.GetElementValueById("txtCandidateMail") != '') {
            if (_Doc.GetElementValueById("txtRefererMail") == _Doc.GetElementValueById("txtCandidateMail")) {
                msg += "\n- Les courriels de la personne qui r\351f\350re et celle de la personne r\351f\351r\351e doivent \352tre diff\351rents!.";
                i += 1;
                _GUI.SetElementBGcolor('txtRefererMail', ReqValueColor);
                _GUI.SetElementBGcolor('txtCandidateMail', ReqValueColor);
                isValid = false;        
            } else { 
                _GUI.SetElementBGcolor('txtRefererMail', ReqNormalColor);
                _GUI.SetElementBGcolor('txtCandidateMail', ReqNormalColor);
            }
        }

        if (i > 0) { alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; delete _Doc; }
}
function ValidateAlerteEmploi() {
    var _Validate = new Validation;
    var _Doc = new Document;
    var msg = '';
    var i = 0;
    var pwd = false;
    var con = false;
    try {
        if (_Validate.IsEmpty('txtFName', true)) {
            msg += '\n- Votre pr\351nom';
            isValid = false;
            i += 1;
        } else if (IsMaxLength('txtFName', 50)) {
            msg += '\n- Votre pr\351nom; est trop long (maximum de 50 caract\350res).';
            isValid = false;
            i += 1;
            _GUI.SetElementBGcolor('txtFName', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtFName', ReqNormalColor); }

        if (_Validate.IsEmpty('txtLName', true)) {
            msg += '\n- Votre nom';
            isValid = false;
            i += 1;
        } else if (IsMaxLength('txtLName', 50)) {
            msg += '\n- Votre nom; est trop long (maximum de 50 caract\350res).';
            isValid = false;
            i += 1;
            _GUI.SetElementBGcolor('txtLName', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtLName', ReqNormalColor); }

        if (!_Validate.isValidEmail('txtEmail', true)) {
            msg += '\n- Votre adresse courriel (Invalide).';
            i += 1;
            isValid = false;
        } else if (_Validate.IsEmpty('txtEmail', true)) {
            msg += '\n- Votre adresse courriel.';
            i += 1;
            isValid = false;
        } else { _GUI.SetElementBGcolor('txtEmail', ReqNormalColor); }

        if ( _Doc.GetASPListCheckCountById('chkDomaines') == 0) {
            msg += "\n- Cat\351gories d'emploi.";
            _GUI.SetListElementBGColor('chkDomaines', ReqValueColor);
            i += 1;
            isValid = false;
        } else { _GUI.SetListElementBGColor('chkDomaines', ReqNormalColor); }

        if (_Doc.GetASPListCheckCountById('chkRegions') == 0) {
            msg += "\n- R\351gions.";
            _GUI.SetListElementBGColor('chkRegions', ReqValueColor);
            i += 1;
            isValid = false;
        } else { _GUI.SetListElementBGColor('chkRegions', ReqNormalColor); }

        if (!_Validate.isChecked('chkPermanent', true) && !_Validate.isChecked('chkTemporaire', true)) {
            msg += '\n- Aumoins un type d\'emploi doit \325tre s\351lectionn\351.';
            isValid = false;
            i += 1;
        } else {
            _GUI.SetElementBGcolor('chkPermanent', ReqNormalColor);
            _GUI.SetElementBGcolor('chkTemporaire', ReqNormalColor); 
        }
        
        if (_Validate.IsEmpty('txtDynCode', true)) {
            msg += '\n- Le code n\'a pas \351t\351 retranscrit.';
            isValid = false;
            i += 1;
        } else if (!_Validate.IsMinLength('txtDynCode', 6)) {
            msg += '\n- Le code est trop court (minimum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else if (_Validate.IsMaxLength('txtDynCode', 6)) {
            msg += '\n- Le code est trop long (maximum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtDynCode', ReqNormalColor); }

        if (!_Validate.isChecked('chkAcceptEmails',true)) {
            msg += "\n- Vous devez cocher l'acceptation de recevoir des courriels de Adecco.";
            isValid = false;
            i += 1;        
        } else { _GUI.SetElementBGcolor('chkAcceptEmails', ReqNormalColor); }
        
        if (i > 0) { alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    } finally { delete _Validate; delete _Doc; }
}
function ValidateAlerteEmploiModify() {
    var _Validate = new Validation;
    var _Doc = new Document;
    var msg = '';
    var i = 0;
    var pwd = false;
    var con = false;
    try {
        if (!_Validate.isValidEmail('txtEmail', true)) {
            msg += '\n- Votre adresse courriel (Invalide).';
            i += 1;
            isValid = false;
        } else if (_Validate.IsEmpty('txtEmail', true)) {
            msg += '\n- Votre adresse courriel.';
            i += 1;
            isValid = false;
        } else { _GUI.SetElementBGcolor('txtEmail', ReqNormalColor); }

        if (_Validate.IsEmpty('txtDynCode', true)) {
            msg += '\n- Le code n\'a pas \351t\351 retranscrit.';
            isValid = false;
            i += 1;
        } else if (!_Validate.IsMinLength('txtDynCode', 6)) {
            msg += '\n- Le code est trop court (minimum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else if (_Validate.IsMaxLength('txtDynCode', 6)) {
            msg += '\n- Le code est trop long (maximum de 6 caract\350res).';
            i += 1;
            isValid = false;
            _GUI.SetElementBGcolor('txtDynCode', ReqValueColor);
        } else { _GUI.SetElementBGcolor('txtDynCode', ReqNormalColor); }

        if (i > 0) { alert('Les zones marqu\351s en jaune requi\350rent votre attention...\n' + msg); return false; }
        else { return true; }
    } catch (err) {
        ShowError(err, GetmethodName());
        return true;
    } finally { delete _Validate; delete _Doc; }
    }
function GetCheckedCount(objID) {
    var _Doc = new Document;
    var oCB;
    var cnt = 0;
    
    try {
        if (objID == '' || objID == 'undefined' || objID == null) { return 0; }
        oCB = GetElements(objID,'input');
        if (oCB == '' || oCB == 'undefined' || oCB == null) { return 0; }

        for (var i = 0; i < oCB.length; i++) {
            if (oCB[i].checked) {
                cnt = cnt + 1;
            }
        }
        return cnt;
    } catch (err) {
        ShowError(err,GetmethodName());
        return 0;
    } finally { delete _Doc; }
}
function HighlightJobTypes() {
    var tmpContent = document.body.innerHTML;
    var tmpBefore = new Strings();
    var tmpAfter = new Strings();
    var tmpOutput = new Strings();
    var intBefore = 0;
    var intAfter = 0;
    var SearchFor = '>Permanent</td>';

    try {
        if (SearchFor.length == 0) { return; }
        while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
            // Get all content before the match
            intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
            tmpBefore = tmpContent.substring(0, intBefore);
            tmpOutput = tmpOutput + tmpBefore;

            // Get the string to replace
            tmpOutput = tmpOutput + '><span class="Highlited">Permanent</span></td>';
            // Get the rest of the content after the match until the next match or the end of the content.
            intAfter = tmpContent.length - SearchFor.length + 1;
            tmpContent = tmpContent.substring(intBefore + SearchFor.length);
        }
        tmpOutput = tmpOutput.replace('[object Object]', '');
        document.body.innerHTML = tmpOutput + tmpContent;
        //return tmpOutput + tmpContent;   
    } catch (err) { ShowError(err,GetmethodName()); }
}
function setcvpath(obj) {
    var docpath = _GetElementById("<%=cvpath.ClientID%>");
    docpath.value = obj.value;
    alert(docpath.value);
}
function setAutreSource() {
    var objSource = _DOC.GetElementById("ddlSource");
    var objAS = _DOC.GetElementById("oAutreSource");
    if (!_DOC.IsObject(_GUI)) { _GUI = new GUI(objAS.id); }

    if (_DOC.IsObject(objSource) && _DOC.IsObject(objAS)) {
        _GUI._element = objAS;
        if (objSource.value == 393261) {
            _GUI.ChangeVisibility(true);
        }
        else {
            _GUI.ChangeVisibility(false);
        }
    }
}
function ShowJobByMail() {
    try {
        var b = _Browser.Name;
        var v = _Browser.Version;

        switch (b) {
            case 'IE':
                if (v <= 6) { _Client.ResizeWindow(250, 400, 100, 100); }
                if (v >= 7) { _Client.ResizeWindow(250, 400, 100, 100); }
                break
            case 'FF':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            case 'OP':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            case 'SA':
                _Client.ResizeWindow(250, 400, 100, 100);
                break
            default:
                _Client.ResizeWindow(250, 400, 100, 100);
                break;
        }
    } catch (Error) {
        ShowError(err,GetmethodName());
    }
}
function addEvent(eventName) {
    if (document.addEventListener) { //code for Moz. 
        document.addEventListener(eventName, eventSink, false);
    } else {                         // Code for IE.
        document.attachEvent('on' + eventName, eventSink);
    }
}
function alertkey(e) {
    if (!e) {
        //if the browser did not pass the event information to the
        //function, we will have to obtain it from the event register
        if (window.event) {
            //Internet Explorer
            e = window.event;
        } else {
            //total failure, we have no way of referencing the event
            return;
        }
    }
    if (typeof (e.keyCode) == 'number') {
        //DOM
        e = e.keyCode;
    } else if (typeof (e.which) == 'number') {
        //NS 4 compatible
        e = e.which;
    } else if (typeof (e.charCode) == 'number') {
        //also NS 6+, Mozilla 0.9+
        e = e.charCode;
    } else {
        //total failure, we have no way of obtaining the key code
        return;
    }
    window.alert('The key pressed has keycode ' + e +
    ' and is key ' + String.fromCharCode(e));
}
document.onmouseout = function MouseOutEvent(e) {
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var parent;
    var oString = new Strings;
    var oDoc = new Document;
    try {
        e = e || window.event;

        if (typeof e.charCode != "undefined") { KeyCode = e.charCode; B = 'FF'; } // FF & Others.
        else if (e.which) { KeyCode = e.which; B = 'NN'; } 						// NN4.
        else { KeyCode = e.keyCode; B = 'IE'; } 								// IE.

        obj = oDoc.GetTargetElementByEvent(e);
        keyChar = String.fromCharCode(KeyCode);

        if (obj == '' || obj == 'undefined' || obj == null) { return; }
        if (obj.id == '' || obj.id == 'undefined' || obj.id == null) { return; }

        parent = oDoc.FindParentWithTagFromName(obj.id, 'LI');
        if (parent != 'undefined' && parent != '' && parent.id != '') {
            if (oString.Left(parent.id, 3) == 'mnu') {
                //currTopMenuIndex = Right(parent.id, 1);
                setTopMenu(currTopMenuIndex);
            }
        }

        parent = oDoc.FindParentWithTagFromName(obj.id, 'UL');
        if (parent != 'undefined' && parent != '' && parent.id != '') {
            if (parent.id == 'GlobalNavMenu') {
                //currTopMenuIndex = Right(parent.id, 1);
                setTopMenu(currTopMenuIndex);
            }
        }        

    } catch (err) { ShowError(err,GetmethodName()); }
    finally { delete oString; delete oDoc; }
}
document.onmousedown = function MouseClickEvent(e) {
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var parent;
    var oString = new Strings;
    var oDoc = new Document;
    try {
        e = e || window.event;

        if (typeof e.charCode != "undefined") { KeyCode = e.charCode; B = 'FF'; } // FF & Others.
        else if (e.which) { KeyCode = e.which; B = 'NN'; } 						// NN4.
        else { KeyCode = e.keyCode; B = 'IE'; } 								// IE.

        obj = oDoc.GetTargetElementByEvent(e);
        keyChar = String.fromCharCode(KeyCode);

        if (obj == '' || obj == 'undefined' || obj == null) { return; }
        if (obj.id == '' || obj.id == 'undefined' || obj.id == null) { return; }

        //if (obj.parentElement.parentElement.tagName == "LI") {}

        parent = oDoc.FindParentWithTagFromName(obj.id, 'LI');
        if (parent != 'undefined' && parent != '' && parent.id != '') {
            if (oString.Left(parent.id, 3) == 'mnu') {
                currTopMenuIndex = oString.Right(parent.id, 1);
                setTopMenu(currTopMenuIndex);
            }
        }
        /*if (obj.id == 'MainImage') {
            try {

            } catch (eer) {
                oDoc.SetElementValueById('msgcount', obj.value.length);
            }
        }*/

    } catch (err) { ShowError(err,GetmethodName()); }
    finally { delete oString; delete oDoc; }
}
document.onkeypress = function KeyPressEvent(e) {
    var field;             //field being processed
    var keyChar;           //the current character
    var KeyCode = 0;       //ascii value of character
    var obj;
    var B;
    var oString = new Strings;
    var oDoc = new Document;
    var oVal = new Validation;
    var controlID;

    try {
        e = e || window.event;

        if (typeof e.charCode != "undefined") { KeyCode = e.charCode; B = 'FF'; } // FF & Others.
        else if (e.which) { KeyCode = e.which; B = 'NN'; } 						// NN4.
        else { KeyCode = e.keyCode; B = 'IE'; } 								// IE.

        obj = oDoc.GetTargetElementByEvent(e);
        controlID = oDoc.GetElementShortName(obj.id);
        keyChar = String.fromCharCode(KeyCode);

        if (obj == '' || obj == 'undefined' || obj == null) { return; }
        if (controlID == '' || controlID == 'undefined' || controlID == null) { return; }

        // Phone No.
        if (controlID == 'txtRefererPhone') {
            if (oVal.IsMaxLength(controlID, 12)) { obj.value = oString.Left(obj.value, 12); }
            return IsNumericPhoneKey(e, KeyCode);
        }

        // Salary.
        if (controlID == 'txtSalMinHoraire' || controlID == 'txtSalMinAnnuel') {
            if (oVal.IsMaxLength(controlID, 10)) { obj.value = oString.Left(obj.value, 10); }
            return IsNumericAmountKey(e, KeyCode);
        }

        // Year.
        if (controlID == 'txtAnneeObtention1' || controlID == 'txtAnneeObtention2' || controlID == 'txtAnneeObtention3' || controlID == 'txtAnneeObtention4' || controlID == 'txtAnneeObtention5') {
            if (oVal.IsMaxLength(controlID, 4)) { obj.value = oString.Left(obj.value, 4); }
            return IsNumericKey(e, KeyCode);
        }

        if (controlID == 'txtJobMessage') {
            try {
                if (obj.value.length > 0) {
                    oDoc.SetElementValueById('msgcount', obj.value.length);
                }
            } catch (eer) {
                oDoc.SetElementValueById('msgcount', obj.value.length);
                //oDoc.SetElementValueById('msgcount',0);
            }
        }
    } catch (err) {
        ShowError(err,GetmethodName());
    } finally { delete oString; delete oDoc; delete oVal; }
}
document.onkeyup = function KeyUpEvent(e) {
    var field;
    var keyChar;
    var KeyCode = 0;
    var obj;
    var B;
    var oString = new Strings;
    var oDoc = new Document;
    var oVal = new Validation;
    var oStrings = new Strings;

    try {
        e = e || window.event;

        if (typeof e.charCode != "undefined") { KeyCode = e.charCode; B = 'FF'; }
        else if (e.which) { KeyCode = e.which; B = 'NN'; }
        else { KeyCode = e.keyCode; B = 'IE'; }

        obj = oDoc.GetTargetElementByEvent(e);
        keyChar = String.fromCharCode(KeyCode);

        if (obj == '' || obj == 'undefined' || obj == null) { return; }
        if (obj.id == '' || obj.id == 'undefined' || obj.id == null) { return; }

        if (obj.id == 'txtJobMessage') {
            if (obj.value.length > 0) {
                if (KeyCode == 8) {
                    oDoc.SetElementValueById('msgcount', obj.value.length);
                }
            }
        }
        if (obj.id == 'txtJobMessage') {
            try {
                if (obj.value.length > 0) {
                    if (KeyCode == 8) {
                        var v = oStrings.Left(obj.value, obj.value.length);
                        oDoc.SetElementValueById('txtJobMessage', v);
                        oDoc.SetElementValueById('msgcount', obj.value.length);
                    } else {
                        oDoc.SetElementValueById('msgcount', obj.value.length);
                    }
                } else {
                    oDoc.SetElementValueById('msgcount', 0);
                }
            } catch (eer) {
                oDoc.SetElementValueById('msgcount', obj.value.length);
            }
        }
    } catch (err) {
        ShowError(err,GetmethodName());
    } finally { delete oString; delete oDoc; delete oVal; delete oStrings; }
}
function Reload() {
    try {
        //var obj = _DOC.GetElementById("txtDynCode");
        _DOC.SetElementValueById('txtDynCode', '');

    } catch (err) { }
    try {
        window.location = self.location;
        return;
    } catch (err1) { ShowError(err,GetmethodName()); }
    try {
        window.location.reload(true);
        return;
    } catch (err2) { ShowError(err,GetmethodName()); }
    try {
        var pageName = _Browser.PageName();
        window.location.replace(pageName);
        return;
    } catch (err3) { ShowError(err,GetmethodName()); }

}
function SetStatusMessage(value) {
    try {
        if (value == undefined) { value = ''; }
        window.status = value;
    } catch (err) { ShowError(err,GetmethodName()); }
}
function typingVal(e) {
    var field;             //field being processed
    var keyChar;        //the current character
    var thisKey = 0;   //ascii value of character

    e = e || window.event;
    field = e.srcElement || e.target;

    if (typeof e.charCode != "undefined") {
        thisKey = e.charCode;     //zero if is editing key non IE
    } else if (e.which) {
        thisKey = e.which;          //NN4
    } else {
        thisKey = e.keyCode;      //zero if is editing key in IE
    }

    keyChar = String.fromCharCode(thisKey);

    if (field.id.slice(0, 4) == "time") {      //processing a time field
        if (thisKey && !/[0-9:]/.test(keyChar)) {         //only digits and colon
            if (e.returnValue) { e.returnValue = false; }
            else {
                //e.preventDefault();
            }
        }
        else if (keyChar == ":") {
            if (field.value.length != 2) {  //Allow : on in 3rd position
                if (e.returnValue) {
                    e.returnValue = false;
                } else {
                    e.preventDefault();
                }
            }
        } else if (thisKey && field.value.length >= 2 && field.value.indexOf(":") == -1) {
            //Make sure there is a : in 3rd position
            field.value = field.value.substring(0, 2) + ":" + field.value.substring(2, field.value.length);
        }
    }
}
function IsNumericKey(e, KeyCode) {
    try {
        if (typeof e.charCode != "undefined" && KeyCode == 0) { return true; }
        if (KeyCode < 48 || KeyCode > 57) { return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
function IsNumericAmountKey(e, KeyCode) {
    try {
        if (typeof e.charCode != "undefined" && KeyCode == 0) { return true; }
        if ((KeyCode < 48 || KeyCode > 57) && KeyCode != 46) { return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
function IsNumericPhoneKey(e, KeyCode) {
    try {
        if (typeof e.charCode != "undefined" && KeyCode == 0) { return true; }
        if ((KeyCode < 48 || KeyCode > 57) && KeyCode != 45) { return false; }
        else { return true; }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
function IsMaxLength(objID, len, truncate) {
    var mlength = 0;
    var obj;

    try {
        truncate = truncate || false
        if (objID == '' || objID == 'undefined' || objID == null) { return false; }
        obj = _DOC.GetElementById(objID);
        if (len == '' || len == 'undefined' || len == null || len == 0 || isNaN(len)) {
            mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
        } else {
            mlength = len;
        }
        if ((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0) {
            if (obj.getAttribute && obj.value.length > mlength) {
                if (truncate) {
                    obj.value = obj.value.substring(0, mlength);
                    return false;
                } else { return true; }
            }
        }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
function IsMinLength(objID, len) {
    var mlength = 0;
    var obj;

    try {
        if (objID == '' || objID == 'undefined' || objID == null) { return false; }
        obj = _DOC.GetElementById(objID);
        if (len == '' || len == 'undefined' || len == null || len == 0 || isNaN(len)) {
            mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
        } else {
            mlength = len;
        }
        if ((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0) {
            if (obj.getAttribute && obj.value.length < mlength) {
                obj.value = obj.value.substring(0, mlength);
            }
        }
    } catch (err) {
        ShowError(err,GetmethodName());
        return true;
    }
}
_GetNodeTextType = function(node) {
    if (node == '' || node == 'undefined') { return 0; }
    switch (node.nodeType) {
        case 1: return 'ELEMENT_NODE'; break;
        case 2: return 'ATTRIBUTE_NODE'; break;
        case 3: return 'TEXT_NODE'; break;
        case 4: return 'CDATA_SECTION_NODE'; break;
        case 5: return 'ENTITY_REFERENCE_NODE'; break;
        case 6: return 'ENTITY_NODE'; break;
        case 7: return 'PROCESSING_INSTRUCTION_NODE'; break;
        case 8: return 'COMMENT_NODE'; break;
        case 9: return 'DOCUMENT_NODE'; break;
        case 10: return 'DOCUMENT_TYPE_NODE'; break;
        case 11: return 'DOCUMENT_FRAGMENT_NODE'; break;
        case 12: return 'NOTATION_NODE'; break;
    }
}
function GetDateTimeDetails(detail) {
    var d = new Date();
    try {
        switch (detail) {
            case 'y':
                return d.getFullYear();
                break;
            case 'm':
                return d.getMonth();
                break;
            case 'd':
                return d.getDate();
                break;
            case 'h':
                return d.getHours();
                break;
            case 'm':
                return d.getMinutes();
                break;
            case 's':
                return d.getSeconds();
                break;
        }
    } catch (err) { ShowError(err,GetmethodName()); }
}
FormatDataGrid = function(DataGridID) {
    var navRoot = _DOC.GetElementById(DataGridID);

    alert(navRoot.style.width);

    // Get a reference to the TBODY element 
    var tbody = navRoot.childNodes[0];

    for (i = 0; i < tbody.childNodes.length; i++) {

        // Get Ref to Table Childs, Check only TR (Rows).
        node = tbody.childNodes[i];
        if (node.nodeName == "TR") {
            var rows = node.childNodes

            for (j = 0; j < rows.childNodes.length; j++) {
                if (rows.childNodes[j].nodeName == "TD") {

                    var className = _DOC.GetElementClassNameById(rows.childNodes[j]);
                    switch (className) {
                        case "Col1":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '11%';
                            break;
                        case "Col2":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '29%';
                            break;
                        case "Col3", "Col4", "Col6":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '14%';
                            break;
                        case "Col5":
                            _DOC.GetElementClassNameById(rows.childNodes[j]).style.width = '18%';
                            break;
                    }
                }
            }
        }
    }
}
DataGridHighlight = function(DataGridID) {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById(DataGridID);

        // Get a reference to the TBODY element 
        tbody = navRoot.childNodes[0];

        for (i = 0; i < tbody.childNodes.length; i++) {
            node = tbody.childNodes[i];
            if (node.nodeName == "TR") {
                node.onmouseover = function() {
                    this.className = "over";
                }
                node.onmouseout = function() {
                    this.className = this.className.replace("over", "");
                }
            }
        }
    }
}
